Degrees Question?

This topic is 4124 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Hi all, I has postion x1,y1 and x2,y2. How to calculate Degrees?

Share on other sites
I like to use a little song:

~\. The dot product of the two position vectors is equal to the cosine of the angle between them ~\.

Sing it to the tune of "Do your ears hang low?"

Share on other sites
The second verse goes something like

~\. Consequently the angle is the arc cosine of the dot product of the two position vectors ~\.

Finally, the refrain is:

~\. Divide by pi and multiply by one hundred and eighty for degrees ~\.

Share on other sites
Bravo! Encore!

And an alternative method:

atan( (y2 - y1) / (x2 - x1) )

since tangent is the opposite over adjacent, you take the arc tangent of the opposite over adjacent to get the angle.

Though you have to check whether or not x2 - x1 is equal to zero before doing the division. Some languages (like C++) supply an "atan2" function which make this simpler:

atan2( y2 - y1, x2 - x1 )

No need to check for dividing by zero. It basically takes two parameters, the opposite and the adjacent side's lengths.

Share on other sites
Those two methods compute different things. Of course, the OP didn't specify which of the two he wanted, so it's not like one of them is correct and one is incorrect. Because he said "positions", he probably meant to get the atan answer. Anyway, two positions don't determine an angle, so the question needs to be posed better.

The acos version measures the angle (x1,y1)-(0,0)-(x2,y2), without sign. The atan version measures the angle (x1+1,y1)-(x1,y1)-(x2,y2), with sign.

Also, in the acos version, you need to divide the dot product by the sizes of the two vectors.

Share on other sites
Drilian and PfhorSlayer i think you 're talking about normalized vectors. For vectors of arbitary length, like position vectors, take the dot product of the two vectors, then divide the dot product by both the lengths of the two vectors, and then you have the cosine of the angle between the vectors.

Share on other sites
Quote:
 Original post by D_TrDrilian and PfhorSlayer i think you 're talking about normalized vectors. For vectors of arbitary length, like position vectors, take the dot product of the two vectors, then divide the dot product by both the lengths of the two vectors, and then you have the cosine of the angle between the vectors.

Multiplication is commutative in real algebra.

Share on other sites
So funny, these little songs! Thank you!

Share on other sites
@taby:

Sorry mate i didn't understand your comment. All i wanted to say is that the dot product of 2 vectors is not just the cosine of the angle between them, but it is the cosine multiplied by their lenghts, namely multplied by |v1|*|v2|. I don't think i murdered commutativeness of multiplication anywhere in my post :P. This is what alvaro is also saying in his last comment too.

1. 1
2. 2
Rutin
21
3. 3
4. 4
frob
15
5. 5

• 9
• 9
• 13
• 9
• 33
• Forum Statistics

• Total Topics
632592
• Total Posts
3007282

×