<
>
 Thread (16 posts)
eric_w66  1/20/08 2:46:49 PM

Rank: 46/100 Rank: 46/100 Rank: 46/100 Rank: 46/100 Rank: 46/100

Advanced Member

Joined: 1/12/06
Posts: 342

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 2:51:03 PM

Rank: 1/100 Rank: 1/100 Rank: 1/100 Rank: 1/100 Rank: 1/100

Novice Member

Joined: 3/20/07
Posts: 316

RATING MMOS:
Don''t rate a game based on what it will be, has been, or what it can potentially be.

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 2:57:34 PM

Rank: 46/100 Rank: 46/100 Rank: 46/100 Rank: 46/100 Rank: 46/100

Advanced Member

Joined: 1/12/06
Posts: 342

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 6:15:39 PM

Rank: 1/100 Rank: 1/100 Rank: 1/100 Rank: 1/100 Rank: 1/100

Novice Member

Joined: 3/20/07
Posts: 316

RATING MMOS:
Don''t rate a game based on what it will be, has been, or what it can potentially be.

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

 
Nasica  1/20/08 6:17:30 PM

Rank: 2/100 Rank: 2/100 Rank: 2/100 Rank: 2/100 Rank: 2/100

Novice Member

Joined: 10/13/04
Posts: 1924

The Footprint of The Buddha
The Heart of The Buddha
The Mind of The Buddha

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)

 
Adreal  1/20/08 8:08:54 PM

Rank: 32/100 Rank: 32/100 Rank: 32/100 Rank: 32/100 Rank: 32/100

Apprentice Member

Joined: 2/05/04
Posts: 2081

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
"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_w66  1/20/08 8:43:14 PM

Rank: 46/100 Rank: 46/100 Rank: 46/100 Rank: 46/100 Rank: 46/100

Advanced Member

Joined: 1/12/06
Posts: 342

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 11:16:41 PM

Rank: 1/100 Rank: 1/100 Rank: 1/100 Rank: 1/100 Rank: 1/100

Novice Member

Joined: 3/20/07
Posts: 316

RATING MMOS:
Don''t rate a game based on what it will be, has been, or what it can potentially be.

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 :'(

 
Nasica  1/20/08 11:26:37 PM

Rank: 2/100 Rank: 2/100 Rank: 2/100 Rank: 2/100 Rank: 2/100

Novice Member

Joined: 10/13/04
Posts: 1924

The Footprint of The Buddha
The Heart of The Buddha
The Mind of The Buddha

Originally posted by tylerthedrui

 

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 :'(

My apologies, i actually didnt mean to quote you, but to quote the message above yours by the OP

 
Sharajat  1/20/08 11:26:42 PM

Rank: 68/100 Rank: 68/100 Rank: 68/100 Rank: 68/100 Rank: 68/100

Hard Core Member

Joined: 12/14/07
Posts: 836

  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_w66  1/21/08 12:26:34 AM