| Thread (16 posts) | ||
|---|---|---|
|
eric_w66 1/20/08 1:46:49 PM
|
||
|
Hard Core Member
Joined: 1/12/06 |
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. |
|
| |
||
|
tylerthedrui 1/20/08 1:51:03 PM
|
||
|
Novice Member
Joined: 3/20/07
RATING MMOS: |
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_w66 1/20/08 1:57:34 PM
|
||
|
Hard Core Member
Joined: 1/12/06 |
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 :). |
|
| |
||
|
tylerthedrui 1/20/08 5:15:39 PM
|
||
|
Novice Member
Joined: 3/20/07
RATING MMOS: |
I would prefer a clean way too, but the arccos has no negative range :(. (I think) |
|
| |
||
|
Nasica 1/20/08 5:17:30 PM
|
||
|
Advanced Member
Joined: 10/13/04
The Footprint of The Buddha |
Originally posted by tylerthedrui Your using length to calculate angles. |
|
| |
||
|
Adreal 1/20/08 7:08:54 PM
|
||
|
Apprentice Member
Joined: 2/05/04
Scripture is only as ambiguous as our ignorance of it allows it to be. |
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 |
||
|
eric_w66 1/20/08 7:43:14 PM
|
||
|
Hard Core Member
Joined: 1/12/06 |
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. |
|
| |
||
|
tylerthedrui 1/20/08 10:16:41 PM
|
||
|
Novice Member
Joined: 3/20/07
RATING MMOS: |
Originally posted by Nasica 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 :'( |
|
| |
||
|
Nasica 1/20/08 10:26:37 PM
|
||
|
Advanced Member
Joined: 10/13/04
The Footprint of The Buddha |
Originally posted by tylerthedrui My apologies, i actually didnt mean to quote you, but to quote the message above yours by the OP |
|
| |
||
|
Sharajat 1/20/08 10:26:42 PM
|
||
|
Novice Member
Joined: 12/14/07 |
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. |
|
| |
||
|
eric_w66 1/20/08 11:26:34 PM
|
||
|
Hard Core Member
Joined: 1/12/06 |
Originally posted by Sharajat
(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 |
|
| |
||
|
tylerthedrui 1/21/08 2:12:39 AM
|
||