Results 1 to 7 of 7

Math Help - Angle calculations

  1. #1
    Newbie chili5's Avatar
    Joined
    Mar 2009
    From
    Canada
    Posts
    17

    Angle calculations

    I had this problem on my last programming contest and my team had no idea as to how to approach it. I'm not asking for an exact answer to this but can anyone give me an general idea about how to do this, or what I should research to figure out how to do this?

    Thanks!
    Follow Math Help Forum on Facebook and Google+

  2. #2
    Super Member craig's Avatar
    Joined
    Apr 2008
    Posts
    748
    Thanks
    1
    Awards
    1
    Quote Originally Posted by chili5 View Post
    I had this problem on my last programming contest and my team had no idea as to how to approach it. I'm not asking for an exact answer to this but can anyone give me an general idea about how to do this, or what I should research to figure out how to do this?

    Thanks!
    Do you want the mathematical method to work it out, or how to turn this method into a piece of code?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Newbie chili5's Avatar
    Joined
    Mar 2009
    From
    Canada
    Posts
    17
    Math method.
    Follow Math Help Forum on Facebook and Google+

  4. #4
    MHF Contributor
    Grandad's Avatar
    Joined
    Dec 2008
    From
    South Coast of England
    Posts
    2,570
    Thanks
    1
    Hello chili5

    The mathematics required is very simple, but you'll have to look at the logic of the various possible positions of the pairs of points to solve the problem. I suggest you proceed as follows:

    Suppose that the line joining the origin to the point (x_1, y_1) makes an angle \theta_1 with the positive direction of the x-axis, measured clockwise, with 0\le\theta<360^o; and similarly for (x_2, y_2) and \theta_2. Then the output angle is the difference between these two angles: \theta_2 - \theta_1; or, if this is negative, 360^o +\theta_2 - \theta_1.

    So how do we find the angle \theta_1? The first thing to do is to calculate the acute angle that the line joining the origin to (x_1, y_1) makes with the horizontal. If this angle is denoted by \phi_1, then \phi_1=\arctan\left|\frac{y_1}{x_1}\right|. Note that:
    You will need to check for x_1=0 to avoid a division by zero error.

    If x_1\ne0, 0\le\phi_1<90.
    Then the value of \theta_1 will depend upon which quadrant (x_1, y_1) is in; as follows:
    QI: x_1>0, y_1>0: \theta_1 = 360-\phi_1

    QII: x_1<0, y_1>0: \theta_1 = 180+\phi_1

    QIII: x_1<0, y_1<0: \theta_1 = 180-\phi_1

    QIV: x_1>0, y_1<0: \theta_1 = \phi_1
    Also, if x_1 = 0 then:
    If y_1>0, \theta_1 = 270

    If y_1<0, \theta_1 = 90
    Clearly you find \phi_2, \;\theta_2 in the same way.

    I hope that makes sense. (Drawing a diagram should help to clarify things.)

    Grandad
    Follow Math Help Forum on Facebook and Google+

  5. #5
    Newbie chili5's Avatar
    Joined
    Mar 2009
    From
    Canada
    Posts
    17
    Thanks. I'll play around with it some and see if that makes any sense =)
    Follow Math Help Forum on Facebook and Google+

  6. #6
    Newbie chili5's Avatar
    Joined
    Mar 2009
    From
    Canada
    Posts
    17
    Quote Originally Posted by Grandad View Post


    So how do we find the angle \theta_1? The first thing to do is to calculate the acute angle that the line joining the origin to (x_1, y_1) makes with the horizontal. If this angle is denoted by \phi_1, then \phi_1=\arctan\left|\frac{y_1}{x_1}\right|. Note that:
    You will need to check for x_1=0 to avoid a division by zero error.

    If x_1\ne0, 0\le\phi_1<90.
    Then the value of \theta_1 will depend upon which quadrant (x_1, y_1) is in; as follows:
    QI: x_1>0, y_1>0: \theta_1 = 360-\phi_1

    QII: x_1<0, y_1>0: \theta_1 = 180+\phi_1

    QIII: x_1<0, y_1<0: \theta_1 = 180-\phi_1

    QIV: x_1>0, y_1<0: \theta_1 = \phi_1
    Also, if x_1 = 0 then:
    [INDENT]If y_1>0, \theta_1 = 270



    Well today in math we actually went over the arctan thing required to calculate the acute angle but what I'm not sure of is the four quadrant thing that you posted above. Sorry, I'm just so lost.
    Follow Math Help Forum on Facebook and Google+

  7. #7
    MHF Contributor
    Grandad's Avatar
    Joined
    Dec 2008
    From
    South Coast of England
    Posts
    2,570
    Thanks
    1
    Hello chili5
    Quote Originally Posted by chili5 View Post
    Well today in math we actually went over the arctan thing required to calculate the acute angle but what I'm not sure of is the four quadrant thing that you posted above. Sorry, I'm just so lost.
    Have a look at the attached diagram. I have indicated the four quadrants, and as an example the line in QIII with its angles \phi and \theta. You'll see that in this case
    \theta = 180-\phi
    If you look at the acute angles the lines in the other three quadrants make with the x-axis, and then the clockwise angles from the positive direction of the x-axis, I think you'll see where the other equations I gave you come from.

    Grandad
    Attached Thumbnails Attached Thumbnails Angle calculations-untitled.jpg  
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. Length of sides and angle calculations
    Posted in the Trigonometry Forum
    Replies: 4
    Last Post: February 3rd 2010, 02:45 AM
  2. calculations
    Posted in the Algebra Forum
    Replies: 1
    Last Post: January 4th 2010, 12:41 PM
  3. LOG and EXP Calculations
    Posted in the Algebra Forum
    Replies: 1
    Last Post: October 14th 2009, 11:39 AM
  4. Uncertainty calculations
    Posted in the Algebra Forum
    Replies: 1
    Last Post: March 9th 2009, 08:27 PM
  5. Calculations?
    Posted in the Business Math Forum
    Replies: 3
    Last Post: January 29th 2008, 06:40 AM

Search Tags


/mathhelpforum @mathhelpforum