Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Stupid math problem, help!

eric_w66eric_w66 Member UncommonPosts: 1,006

I'm 20ish years removed from trig, so I've forgotten most of what I knew.

I've searched the net, but can't find a "simple" answer, everything I've found deals with problems more complicated than mine...

All I need to do is to be able to find the angle to a specific point on a grid.

For instance, the angle to (5, 5) is 45 degrees. I can do that.  acos(5 / sqrt(5*5 + 5*5)) / (2pi) * 360.

And the angle to (2, 20) is acos(2 / sqrt(2 * 2 + 20 * 20)) / (2pi) * 360 = 84 degrees.

But... my problem comes in when I want to find, say, (2, -20). I still come up with 84 degrees.

What am I overlooking (something with signs I'm sure)?

Thanks in advance.

Comments

  • tylerthedruitylerthedrui Member Posts: 304

    2, -20 would still be 84 degrees from the x-axis.

    You could find the 'actual' angle by

    Degrees are always positive unless you've moved clockwise from the origin. So this point would be -84 degrees. or, if you were moving counterclockwise from origin, it would be 276 degrees (360-84)

    There are four quadrants, and 2, -20 is in the fourth (the bottom right one).

  • eric_w66eric_w66 Member UncommonPosts: 1,006

    So the only thing I can really do is just check the signs of the x and y coords to find the quadrant and work it from there? Poopy, I hate inelegant solutions like that :).

     

    I wanted some clean way to come up with the 276 :).

  • tylerthedruitylerthedrui Member Posts: 304

    I would prefer a clean way too, but the arccos has no negative range :(. (I think)

  • AdrealAdreal Member Posts: 2,087

    Ah, to be young and work with numbers in math... *sigh* I guess it's back to practicing my sideways 8's.

    "Put your foot where your mouth is." - Wisdom from my grandfather
    "Paper or plastic? ... because I'm afraid I'll have to suffocate you unless you put this bag on your head..." - Ethnitrek
    AC1: Wierding from Harvestgain

  • eric_w66eric_w66 Member UncommonPosts: 1,006

    Hehe, that's the problem, I'm not young anymore, and I've forgotten how to do the easy stuff LOL. I have a super fancy computer and a super fancy calculator, but I can barely remember how to do this stuff.

  • tylerthedruitylerthedrui Member Posts: 304

    Originally posted by Nasica

    Originally posted by tylerthedrui


    I would prefer a clean way too, but the arccos has no negative range :(. (I think)

    Your using length to calculate angles.

    The concept of a negative length is nonsensical, it purely defines direction (well thats my understanding in this highly excitable pre-greenbay game state)


    Wasn't talking about a negative length. Negative angles are measured clockwise from the origin.

    GB lost because we were calling stupid plays and trying to be heroes rather than jump on the fumble :'(

  • SharajatSharajat Member Posts: 926

      Remember, the Tangent of an angle is the opposite over the adjacent.  Divide the Y coordinate by the X coordinate, then take the inverse tangent of that number, and boom, you have the angle.  Its a joke, really, when you remember the method.

    In every country and in every age, the priest has been hostile to liberty. He is always in alliance with the despot, abetting his abuses in return for protection to his own.

    -Thomas Jefferson

  • eric_w66eric_w66 Member UncommonPosts: 1,006

     

    Originally posted by Sharajat


      Remember, the Tangent of an angle is the opposite over the adjacent.  Divide the Y coordinate by the X coordinate, then take the inverse tangent of that number, and boom, you have the angle.  Its a joke, really, when you remember the method.



    I thought about that way, but it still suffers the "lack of inelegance" (unless I'm making a mistake somewhere).

     

    (20, -2) comes up with -5.7 degrees (I'd prefer it to be 354 without having to modify it, but I can deal with it)...

    (-20, -2) comes up with 5.7 degrees, which is the same result as (20, 2), which is 180 degrees opposite it.

    So I'm still stuck looking at the signs to figure out which quadrant it is and working from there. Bleh... :)

    What I guess I am wanting is a "clockface" type of function/algorithm that knows I want the number of degrees from the positive X-axis counterclockwise around to the point on the grid. /sigh

  • tylerthedruitylerthedrui Member Posts: 304

     

    Originally posted by eric_w66


     
    Originally posted by Sharajat


      Remember, the Tangent of an angle is the opposite over the adjacent.  Divide the Y coordinate by the X coordinate, then take the inverse tangent of that number, and boom, you have the angle.  Its a joke, really, when you remember the method.



    I thought about that way, but it still suffers the "lack of inelegance" (unless I'm making a mistake somewhere).

     

    (20, -2) comes up with -5.7 degrees (I'd prefer it to be 354 without having to modify it, but I can deal with it)...

    (-20, -2) comes up with 5.7 degrees, which is the same result as (20, 2), which is 180 degrees opposite it.

    So I'm still stuck looking at the signs to figure out which quadrant it is and working from there. Bleh... :)

    What I guess I am wanting is a "clockface" type of function/algorithm that knows I want the number of degrees from the positive X-axis counterclockwise around to the point on the grid. /sigh

     

    The range of the arctangent function is -pi/2 to pi/2. So the values it returns are -90 degrees to 90 degrees. You have to do the hoofwork of making that into a counterclockwise angle on your own.

    life sucks, I know. This is because the trigonometric functions do not consider the unit circle. They merely work as a ratio between arc length and hypotenuse length. The unit circle is all in our heads. All trig functions care about is the triangle.

  • AkaJetsonAkaJetson Member Posts: 1,167

    ...i have absolutely no idea.

    ?

  • GodliestGodliest Member Posts: 3,486

    I was about to say it before, but now I definitely have to. Math in English is damn hard! I would probably have understood and maybe solved the problem if I had come across it in school, but in English at free time, no wai!

    image

    image

  • SharajatSharajat Member Posts: 926

     

    Originally posted by tylerthedrui


     
    Originally posted by eric_w66


     
    Originally posted by Sharajat


      Remember, the Tangent of an angle is the opposite over the adjacent.  Divide the Y coordinate by the X coordinate, then take the inverse tangent of that number, and boom, you have the angle.  Its a joke, really, when you remember the method.



    I thought about that way, but it still suffers the "lack of inelegance" (unless I'm making a mistake somewhere).

     

    (20, -2) comes up with -5.7 degrees (I'd prefer it to be 354 without having to modify it, but I can deal with it)...

    (-20, -2) comes up with 5.7 degrees, which is the same result as (20, 2), which is 180 degrees opposite it.

    So I'm still stuck looking at the signs to figure out which quadrant it is and working from there. Bleh... :)

    What I guess I am wanting is a "clockface" type of function/algorithm that knows I want the number of degrees from the positive X-axis counterclockwise around to the point on the grid. /sigh

     

    The range of the arctangent function is -pi/2 to pi/2. So the values it returns are -90 degrees to 90 degrees. You have to do the hoofwork of making that into a counterclockwise angle on your own.

    life sucks, I know. This is because the trigonometric functions do not consider the unit circle. They merely work as a ratio between arc length and hypotenuse length. The unit circle is all in our heads. All trig functions care about is the triangle.

    Just check if the X value is positive or negative, and then you'll know if you have the right angle, or if you need to mirror it.  Easy as that. If you truly want a more elegant function, here it is:



    Use the cotangent model to find the angle.  Then find the hypotinuse (I can't spell that anymore) by summing the squares of each coordinate, then taking the square root.  Use the opposite over the adjacent and take inverse sine.  Then you have the following:





    Sin and Tan are the same: Quadrant 1

    Tangent is in Quadrant 2, sin in Quadrant 1:  Quadrant 2

    Tangent is in Quadrant 2, sin in Quadrant 4:  Quadrant 3

    Tangent in Quadrant 1, sin in Quadrant 4: Quadrant 4

     

    Again, nothing gives a crap about the unit circle, but such is life. 

     

     

    If you want a less elegant version... tough.  Each coordinate can form a right angle triangle by drawing a line to an axis and a line to the origin from the point.  OBVIOUSLY you use angle functions like Sine, Cosine, and Tangent functions to solve it. 

    In every country and in every age, the priest has been hostile to liberty. He is always in alliance with the despot, abetting his abuses in return for protection to his own.

    -Thomas Jefferson

  • soldier2440soldier2440 Member Posts: 2

    even i dont nkow that and im good at most math problems

Sign In or Register to comment.