# Is there any formula to find the coordinates with the distance and the angle

All I need is a formula, it will help me a lot

1 Like

You can calculate distance using something you learn in algebra: Distance formula (where d is distance)
I can’t write subscripts so I’m not going to write it here, you should be able to search it up.
You can find the angle using JR01’s angleto bundle.

Im actually looking for the coordinates, I already know the distance and the angle

Oh, so you want to know the coordinates. I haven’t taken algebra 2 yet, but I know a bit of it.
This is the equation for each coordinate if r was 5 and the angle was 45º
x = r cosθ

x = 5 cos45º

x = 5 (√2 / 2)

x = 5√2 / 2

y = r sinθ

y = 5 sin45º

y = 5 (√2 / 2)

y = 5√2 / 2

1 Like

If put it in an expression
ex: A*Math.cos(B), would that be correct

It doesn’t work, it gives me numbers that doesn’t make sense

Why not just send the coordinates in a message or global?

Because I’m raycasting, I only want the coordinates from which the raycast ended

hmm, the bad thing about that is that raycast isn’t precise with the distance and could lead you to be half an object off.

But thinking off my head, you could try this:
`X + Distance*MathCos(Angle*(Math.PI/180)) = X`
`Y + Distance*Math.Sin(Angle*(Math.PI/180)) = Y`

3 Likes