🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

easiest way to find angle btween 2 points?

Started by
7 comments, last by VECTOR 23 years, 12 months ago
using simple trignometry?
The object of war is not to die for your country, but to make the other bastard die for his . . -General MacArthur
Advertisement
I would use trig, but if you plan on doing alot of this.....
then put your sin and cos in a lookup table as it is very expensive on your cpu


"Now go away or I shall taunt you a second time"
- Monty Python and the Holy Grail
themGames Productions

There is no such thing as an angle between two points. Please flesh out your question a little more.

Later,
Eck

EckTech Games - Games and Unity Assets I'm working on
Still Flying - My GameDev journal
The Shilwulf Dynasty - Campaign notes for my Rogue Trader RPG

If you meant to say the angle between two vectors, then you can use the dot product to find that... but there''s no such thing as an angle between two points...

..-=ViKtOr=-..
Any angle with only 2 points is 0 degrees.

Protozone
Okay, I asked the same question as VECTOR a while ago amd didn''t get an answer, so I know what he''s talking about. Let''s say point 2 rotates around point 1, then what is the ange that point 2 is at around point 1?

Morgan
yes that''s exactly what I mean
The object of war is not to die for your country, but to make the other bastard die for his . . -General MacArthur
i think

double ang = atan((y - y2)/(x - x2));

get it?
morgan what u described are 2 vectors

vector 1 is pt1->pt2
vector 2 is pt1-> (pt2 in a new place)

im no maths wizz but this is what i use

float top = pt1 DOTPRODUCT pt2
float bot = pt1.length() * pt2.length();
float answer = acos(top/bot)*RAD2DEG;

This topic is closed to new replies.

Advertisement