Pregunta

Who is a math wiz and wants to check my math?

I'm trying to find the placement of a point(x,y) on the circumference of a circle in degrees. If I use x=radius*cos(Q)+xOrigin, I end up with arccos((x/2)-xOrigin) = Q which gives me the angle in radians. Then I go D = Q(180/Pi) to get degrees, but I keep coming up about 3-5 degrees off of target.

What's up with that?

¿Fue útil?

Solución

Your formula for Q should be

Q = acos((x-xOrigin)/radius)

Note that acos returns an angle between 0 and pi; if the angle is in the third or fourth quadrant you'll need to subtract the angle from 2 * pi.

Without knowing the actual values that are coming up wrong, it's hard to tell if that's the only problem. Your conversion from radians to degrees is correct.

Otros consejos

Most modern programming languages have atan2() somewhere, which takes a rise and a run and spits out the angle in radians in all four quadrants.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top