Results 1 to 7 of 7

Math Help - Angle between two points on a circle

  1. #1
    Newbie
    Joined
    Nov 2009
    Posts
    4

    [SOLVED] Angle between two points on a circle

    I'd like to calculate the angle between two points on a circle, in which the radius of the circle is known, as are the coordinates of the two points and the center point. The problem is similar to this one, except I don't want to be limited to one point being at the 12-o'clock position.

    Known:
    p1 - starting point on circle
    p2 - ending point on circle
    c - center point on circle
    r - radius of circle

    Calculate:
    central angle

    The incomplete solution I came up with is to calculate the distance between the two points first (lets call them p1 and p2):
    d = sqrt((x2 - x1)^2 + (y2 - y1)^2)

    With that, the angle can be calculated as (r is radius of the circle):
    angle = 2asin(d/2r)

    The problem with this solution is that it doesn't produce angles over 180 degrees. When it goes over 180 degrees it starts giving the minor angle again, which leaves me unable to determine if the degrees it is giving are clockwise or counter clockwise from the starting point. (Here's a demo showing how to calculate the central angle, and it also runs into the same problem I encountered. It doesn't seem to know how to calculate an angle greater than 180 degrees.)

    In other words, I always want this to calculate the angle clockwise from the starting point (p1) to the end point (p2), so that it produces angles up to 360 degrees.
    Last edited by bbagnall; November 14th 2009 at 02:05 PM. Reason: Solved. Updating title.
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Newbie
    Joined
    Nov 2009
    Posts
    4

    Inelegant solution

    I found a somewhat bloated solution by doing some additional calculations. The name of the game is to check if P2 lies to the left or right (relative) to the line formed by P1 and the opposite side of the circle. To test this condition, you need to create a third point (we'll call it Pa) that lies anywhere along the starting heading:

    1. Create a point somewhere on the heading line, an arbitrary distance d. Take heading, h, and subtract 180 degrees:
    h1 = h - 180

    Calculate Pa (x, y) using:
    xa = x1 - d cos h1
    ya = y1 - d sin h1

    2. Calculate the lengths of all three lines in the triangle formed by P1-P2-Pa:

    a = sqrt( (x2 - x1)^2 + (y2 - y1)^2) )
    b = sqrt( (xa - x1)^2 + (ya - y1)^2) )
    c = sqrt( (x2 - xa)^2 + (y2 - ya)^2) )

    3. Now take the law of cosines and rearange the variables to isolate the angle C:
    C = acos( (c^2 - a^2 - b^2) / (-2ab) )

    4. This generates an angle C. If the angle C is acute, then just use the regular value generated by the equations in my first post above (angle, a value 0-180). If the angle C is obtuse, then use the calculation (360 - angle) to generate values > 180.

    I find this pretty tedious, so if anyone has a more elegant solution to derive angles 0 to 360 without all this mumbo-jumbo that would be great.
    Follow Math Help Forum on Facebook and Google+

  3. #3
    MHF Contributor

    Joined
    Aug 2006
    Posts
    18,957
    Thanks
    1780
    Awards
    1
    I must really not understand this question.
    Because, if you know the coordinates of any three points it is simple to find all the angles.
    There is absolutely no reason to involve a circle.

    Say a_x,a_y)~,~Bb_x,b_y),~\&~Cc_x,c_y)" alt="Aa_x,a_y)~,~Bb_x,b_y),~\&~Cc_x,c_y)" /> then we can find the measure of <br />
\angle ACB.
    m(\angle ACB) = \arccos \left( {\frac{{\left( {a_x  - c_x } \right)\left( {b_x  - c_x } \right) + \left( {a_y  - c_y } \right)\left( {b_y  - c_y } \right)}}<br />
{{\sqrt {\left( {a_x  - c_x } \right)^2  + \left( {a_y  - c_y } \right)^2 } \sqrt {\left( {b_x  - c_x } \right)^2  + \left( {b_y  - c_y } \right)^2 } }}} \right)
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Newbie
    Joined
    Nov 2009
    Posts
    4
    Hi Plato,

    The angle I was looking for was the central angle, I believe it's called, which is the angle formed by one point on the circle (p1) the center of the circle, and the other point (p2). Since all three points are known, I assume you are correct if your calculation above can produce angles > 180 degrees. Does it?

    As it turns out, if you take the angle calculated in my second post above and multiply it by 2, it also comes up with a central angle between 0 - 360 degrees. This was completely by accident, but it does the trick, so the calculations in my first post are redundant. I think the reason it worked out has something to do with the property of central angles shown in this Java applet:
    Central Angle Theorem - Math Open Reference

    Quote Originally Posted by Plato View Post
    I must really not understand this question.
    Because, if you know the coordinates of any three points it is simple to find all the angles.
    There is absolutely no reason to involve a circle.

    Say a_x,a_y)~,~Bb_x,b_y),~\&~Cc_x,c_y)" alt="Aa_x,a_y)~,~Bb_x,b_y),~\&~Cc_x,c_y)" /> then we can find the measure of <br />
\angle ACB.
    m(\angle ACB) = \arccos \left( {\frac{{\left( {a_x  - c_x } \right)\left( {b_x  - c_x } \right) + \left( {a_y  - c_y } \right)\left( {b_y  - c_y } \right)}}<br />
{{\sqrt {\left( {a_x  - c_x } \right)^2  + \left( {a_y  - c_y } \right)^2 } \sqrt {\left( {b_x  - c_x } \right)^2  + \left( {b_y  - c_y } \right)^2 } }}} \right)
    Follow Math Help Forum on Facebook and Google+

  5. #5
    MHF Contributor

    Joined
    Aug 2006
    Posts
    18,957
    Thanks
    1780
    Awards
    1
    No angle has a measure greater than \pi\text{ or }180^o.
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie
    Joined
    Nov 2009
    Posts
    4

    angle versus arc

    Quote Originally Posted by Plato View Post
    No angle has a measure greater than \pi\text{ or }180^o.
    Is that even true? The Wikipedia article talks about positive and negative angles of 325 degrees:
    Angle - Wikipedia, the free encyclopedia

    I take it your equation above is unable to produce anything greater than 180 degrees so you're trying to get me with some sort of semantic difference here between an angle and arc. Can an arc have >180 degrees? If that's the case, I'm looking for an arc between 0 and 360 degrees.

    In any event, my equation above is able to deliver a thingamajig between 0 and 360 degrees. Problem solved.
    Last edited by bbagnall; November 14th 2009 at 01:42 PM. Reason: Added Wiki article
    Follow Math Help Forum on Facebook and Google+

  7. #7
    Newbie
    Joined
    Dec 2009
    Posts
    1

    Another solution

    Hi all,

    I actually ran into this, too. I needed to be able to find both the clockwise and counter clockwise degrees(radians) around a circle from one point on it to another. I tried to figure out bbagnall's solution, but didn't have much luck.

    A post over at gamedev.net was pretty helpful though: Rotation with atan2() problem - GameDev.Net Discussion Forums

    It uses atan2 pretty cleverly. Keep in mind that mine is a programming standpoint. Just thought I'd leave a comment since I've been working at this for days and this particular post has been on my browser at least that long.
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Angle in a circle.
    Posted in the Geometry Forum
    Replies: 3
    Last Post: April 22nd 2011, 06:29 PM
  2. Points on a circle, calculating angle
    Posted in the Geometry Forum
    Replies: 6
    Last Post: May 7th 2010, 01:51 PM
  3. Replies: 4
    Last Post: May 2nd 2010, 04:34 PM
  4. Replies: 7
    Last Post: March 15th 2010, 05:10 PM
  5. Replies: 2
    Last Post: September 4th 2009, 11:19 PM

Search Tags


/mathhelpforum @mathhelpforum