Skip to main content
GameDev.net gamedev.net
🔒 Locked

Rotating coordinates

Started by jvff Mar 8, 2004 at 4:07 PM 3 replies 550+ views
Original Post
jvff
jvff
Hello, My problem is, given an object''s coordinate system (vectors x,y,z) and the world coordinate system (vectors u,v,w), I can transform a point given in world coordinates to object coordinates. I figured out that I must probable discover the angles between the vectors (x and u, y and v, z and w) and rotate the point by the angles around the origin of the world''s origin. Is this correct? Part two is doing that. Rotation is simple but to discover the angle in radians I just do a dot product? Thank you, JVFF
ThanQ, JVFF (Janito Vaqueiro Ferreira Filho)
KingJeihova9
KingJeihova9
No don''t use the dot product. Use the cross product to discover angles between vectors.

(My Wisdom) + (My Courage) + (My Will) > God''s Power - (ytilaerlariv) = [My] laissez faire [for] Liberatis
(My Wisdom) + (My Courage) + (My Will) > God's Power - (ytilaerlariv) = [My] laissez faire [for] Liberatis
jvff
jvff
I don''t understand. The cross product will return a vector. But I think I need a scalar value for rotation. Or am I wrong? Thank you,

JVFF
ThanQ, JVFF (Janito Vaqueiro Ferreira Filho)
JohnBolton
JohnBolton
You can create a matrix that transforms object coordinates into world coordinates very easily. Assuming that your X, Y, and Z vectors are unit vectors that specify the object''s coordinate system in world coordinates and the object''s origin is at [ Tx,Ty,Tz ] (in world coordinates), then the transformation matrix, A is this:


Xx Yx Zx Tx
Xy Yy Zy Ty
Xz Yz Zz Tz
0 0 0 1



Use it like this: W = AO, where W is the point in world coordinates, and O is the point in object coordinates.


Finally, to answer your question, the matrix that transforms world coordinates into object coordinates in the inverse of A -- A-1.
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!
healeyx76
healeyx76
Actually you''ll want to use the dot product right?

A*B = |A||B|cos(theta)


well, once you have the angles, you use rotation matrixes abouy X, Y , and Z. Or you could convert to quaternians, but the matrix should be fine. There are a lot of good explinations of this once you have the angles.

http://vered.rose.utoronto.ca/people/david_dir/GEMS/GEMS.html

theres one. Its a combination of the three matrices. And if you just have the matrix, but not the angles, you can extract them by things like Beta = arcsin(-R13) and Gamma = arctan(R12/R11) and Alpha = arctan(R23/R33)

where alph, beta, gam are rotation about x,y,z.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.