General Question
Geometry Gurus. Can you help me solve for an angle?
I’m working on an app and I need to solve for an angle. I have 2 points and I need to solve for the angle that would be produced from an arc that began drawing at “3 o’clock” counterclockwise to a point on it’s circumference. That’s not a great description, so I’ve uploaded a diagram.
The centerPoint can be arbitrary but the coordinates are known. I’ve been using the following expression:
angle = acos( (radialPoint.x – centerPoint.x) / radiusLength )
This seems to work when the angle is < 180 but it fails when the angle is > 180.
Is there a function to easily calculate the angle with the coordinates of both points known? I’m sure I could come up with something crazy involving slopes and checking for various cases, but that seems pretty ugly if there is an easy answer.
2 Answers
Answer this question
This question is in the General Section. Responses must be helpful and on-topic.