Send to a Friend

gorillapaws's avatar

Geometry Gurus. Can you help me solve for an angle?

Asked by gorillapaws (30526points) February 22nd, 2015

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.

Using Fluther

or

Using Email

Separate multiple emails with commas.
We’ll only use these emails for this message.