View Full Version : How to make a quat to rotate a vector to another?

07-23-2011, 02:59 PM
i want to make a function to make a quat to make a object rotate to face the direction given by a vector
so i code:
fn rotateFromZaxis vector =
rquat = quat (acos (dot (normalize vector) [0,0,1])) (cross vector [0,0,1])
rmatrix = matrix3 1
rmatrix.rotation = rquat

but things dont go as i want,when vector = [1,1,1] rquat = (quat 0.459701 -0.459701 0 0.888074) ,and i use lookat constraint, make the obj Zaxis face [1,1,1], i get$.transform.rotation (quat 0.455768 0.060003 0.704556 0.540625)
so what`s wrong?

CGTalk Moderation
07-23-2011, 02:59 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.