Sign in to follow this  
cntz

Placement of player on top of world mesh

Recommended Posts

Hi everybody, My problem is as follows: Given initial orientation and normal vectors and target orientation and normal vectors, I want to be able to transform the initial vectors to the target vectors. Assume that the orientation and normal vectors are orthogonal. My current, non working, solution's pseduo-code: 1. Let N,O be the initial normal and orientation vectors respectivly, Let N',O' be the TARGET normal and orientation vectors respectivly. 2. NormalRotationAxis = CrossProduct(N,N') 3. Normalize(NormalRotationAxis) 4. AngleBetweenNormals = GetAngle(N,N') 5. targetN = Rotate N AngleBetweenNormals degress about NormalRotationAxis axis 6. newOrientation = Rotate O AngleBetweenNormals degress about NormalRotationAxis axis 7. AngleBetweenOrientations = GetAngle(newOrientation,O') 8. targetO = Rotate newOrientation AngleBetweenOrientations degrees about targetN. At the end of this code targetN = N' but targetO != O'. I can't figure out why. As you can see, i'm taking a 2 step approach. First Match normals, then find out how much to rotate about the matched normal or match the orientations. Is this approach wrong? Is there an easier approach? If there's nothing wrong with this i'll post a more detailed implementation. Thanks! Y.

Share this post


Link to post
Share on other sites
If i understand correctly u wanna
rotate one vector to another vector (thus u want a rotation matrix that describes this)
see here Q 39/40
http://www.j3d.org/matrix_faq/matrfaq_latest.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this