Angle between two points?

Member
Posts: 23
Joined: 2007.12
Post: #1
I am trying like crazy to get the angle of Rotation between two points an just can't seem to figure it out Mad

This is what I am trying to do

Object Position (First Points)
Object Position + Object Speed (Second Points)

Distance between = Rotation?

I have found a way to almost get the right angle but I need it to be FLAWLESS

opp= Object.y - Object.y + Speed;
adj = Object.x - Object.y + Speed;

Rotation Angle = atan(opp/adj) *180/PI;
Quote this message in a reply
Member
Posts: 254
Joined: 2005.10
Post: #2
I'm confused, do you mean the angle between two points and the origin? You need three points for an angle.
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #3
I'm not certain I understand the question fully, but that being said, look into atan2()... it's significantly more useful than vanilla atan()
Quote this message in a reply
Member
Posts: 23
Joined: 2007.12
Post: #4
i just tried tan2 & it to failed.

What I am trying to do is have

Object point to Object + Speed
Quote this message in a reply
Moderator
Posts: 1,560
Joined: 2003.10
Post: #5
Please provide more details. What inputs do you have, and what output are you trying to compute? What does "i just tried tan2 & it to failed" mean? What does "Object point to Object + Speed" mean? Your question is incomprehensible the way it was phrased.
Quote this message in a reply
Member
Posts: 23
Joined: 2007.12
Post: #6
If I launch a projectile what would the Angle be between the Objects present Position & the previous Position
Quote this message in a reply
Member
Posts: 81
Joined: 2007.05
Post: #7
I still think your confused. But I think you might be assuming its the angle in respect to the ground?

I suppose you could create a delta vector.

//create delta
delta_vec = position_new - position_old

//copy it
ground_ref = delta_vec
ground_ref.y = 0

Now you have two vectors. Normalize both of them. Take the dot product of both vetors. Now, cos( theta ) = dot( v1 , v2 ) . Just do inverse arc cos on the dot product and you should get theta in radians. To convert to degrees just multiply it by 180/pie . It will return a value betwen 0 and 180.

Hope that helps.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Formula for converting angle to vector? komirad 2 9,859 Jul 29, 2011 07:29 AM
Last Post: ThemsAllTook
  Question Regarding the Reflect Angle of a Transition iBaby 3 3,512 Apr 27, 2010 03:15 PM
Last Post: JustinFic
  ending location from angle and speed Kazooless 5 4,483 Apr 3, 2009 02:40 PM
Last Post: Gillissie
  calculating X and Y coordinates w/ an angle and distance ferum 13 14,904 Jun 25, 2008 10:53 PM
Last Post: rosenth
  Convert vector to angle? Leroy 35 30,281 Jun 27, 2007 08:15 PM
Last Post: unknown