# Placement of player on top of world mesh

This topic is 3430 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## 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 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

1. 1
Rutin
32
2. 2
3. 3
4. 4
5. 5

• 11
• 13
• 87
• 11
• 10
• ### Forum Statistics

• Total Topics
632973
• Total Posts
3009615
• ### Who's Online (See full list)

There are no registered users currently online

×