Results 1 to 7 of 7

Thread: 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 $\displaystyle (x_1, y_1)$ makes an angle $\displaystyle \theta_1$ with the positive direction of the $\displaystyle x$-axis, measured clockwise, with $\displaystyle 0\le\theta<360^o$; and similarly for $\displaystyle (x_2, y_2)$ and $\displaystyle \theta_2$. Then the output angle is the difference between these two angles: $\displaystyle \theta_2 - \theta_1$; or, if this is negative, $\displaystyle 360^o +\theta_2 - \theta_1$.

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

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

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

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

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

    If $\displaystyle y_1<0, \theta_1 = 90$
    Clearly you find $\displaystyle \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 $\displaystyle \theta_1$? The first thing to do is to calculate the acute angle that the line joining the origin to $\displaystyle (x_1, y_1)$ makes with the horizontal. If this angle is denoted by $\displaystyle \phi_1$, then $\displaystyle \phi_1=\arctan\left|\frac{y_1}{x_1}\right|$. Note that:
    You will need to check for $\displaystyle x_1=0$ to avoid a division by zero error.

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

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

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

    QIV: $\displaystyle x_1>0, y_1<0: \theta_1 = \phi_1$
    Also, if $\displaystyle x_1 = 0$ then:
    [INDENT]If $\displaystyle 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 $\displaystyle \phi$ and $\displaystyle \theta$. You'll see that in this case
    $\displaystyle \theta = 180-\phi$
    If you look at the acute angles the lines in the other three quadrants make with the $\displaystyle x$-axis, and then the clockwise angles from the positive direction of the $\displaystyle 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: Feb 3rd 2010, 02:45 AM
  2. calculations
    Posted in the Algebra Forum
    Replies: 1
    Last Post: Jan 4th 2010, 12:41 PM
  3. LOG and EXP Calculations
    Posted in the Algebra Forum
    Replies: 1
    Last Post: Oct 14th 2009, 11:39 AM
  4. Uncertainty calculations
    Posted in the Algebra Forum
    Replies: 1
    Last Post: Mar 9th 2009, 08:27 PM
  5. Calculations?
    Posted in the Business Math Forum
    Replies: 3
    Last Post: Jan 29th 2008, 06:40 AM

Search Tags


/mathhelpforum @mathhelpforum