Reputation: 259
I have an object moving in 3D space (origin at the center). I am calculating the direction vector as it moves and using that to apply the rotation before any transformations to the object at the origin.
direction vector (position, previousPos): positionX-previousPosX/mag etc
transformation
rX = acos(direction_vector_x); etc
rY = acos(direction_vector_y);
rZ = acos(direction_vector_z);
rotate(rZ, rX,rY) // axis rotation
draw object
The object is in position at first but then randomly appears diagonally and the wrong way round. After that the rotation is smooth, but sometimes goes backwards or upside down? Could someone let me know how to calculate this? Thanks.
Upvotes: 1
Views: 2597
Reputation: 51923
you are creating 3D coordinate system from single vector that is not enough ...
Upvotes: 1