Calculate rotation between two Vector2s around a pivot
Posted
by
Nick
on Stack Overflow
See other posts from Stack Overflow
or by Nick
Published on 2011-01-09T13:33:34Z
Indexed on
2011/01/09
13:53 UTC
Read the original article
Hit count: 309
Hello all.
After a good long Sunday google I am going to have to hang my head in shame and ask the question...
What I have is a pivot vector2, a "Previous" vector2 and a "Current" vector2.
I would like to be able to calculate the rotation in radians between them. A slight complication is the fact that the pivot may moved between previous and current but ill deal with the offsetting as a separate issue if you don't have the time to bring that into the fold.
To clarify, an object which has two vectors, a pivot and a base ... the pivot sitting in the centre and the base at the bottom is rotated around an external pivot. I need to work out the rotation of the object itself around its centre using the two mentioned vectors.
Very big thanks to anyone that can help.
Background to problem
I have a game where an object is rotated around an external pivot. By using using two points (one in the centre, one at the base of the object) I am wanting to to work out the rotation that needs to be applied to the objects sprite around its centre to conform to the larger rotation that has been applied.
© Stack Overflow or respective owner