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

concatenate matrixces

Started by SubUrban Sep 26, 2002 at 12:00 PM 2 replies 350+ views
Original Post
SubUrban
SubUrban
Hi! If I have one matrix with the rotation of an object in Y and one matrix with rotation (for the same object) in X and Z. Can I now just use D3DXMatrixMultiply to concatenate them? I get some screwy results so I just have to check that this is how it is supposed to be done. If I haven''t rotated the X and Z matrix will there be any weird thing happening if I concatenate them? /thanks
WitchLord
WitchLord
Yes they can be concatenated by multiplying them. You just need to be careful with which one goes first, the RotY or RotXZ matrix. RotY*RotXZ is generally not the same as RotXZ*RotY. The rule is that the transform you want to apply first should be closest to the vector in the vector transform.

v'' = v*RotY*RotXZ = v*(RotY*RotXZ)

Also if you havent''t rotated the XZ matrix it is simply an identity matrix which for matrices works the same as 1 does for scalar numbers, i.e. multiplying with the identity matrix doesn''t modify the original matrix.

- WitchLord

www.AngelCode.com
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel
WitchLord
WitchLord
quote:

Well, I''m sorry mod, but I''m going to have to say that RotXZ*RotY is a totally diferent concept to RotY*RotXZ so we should NEVER use the word same anywhere near this (if you get the same result then it''s pure coincidence, or error).



Bad choice of words from my part, agreed. But I meant the same as you.

As for your definition of pitch, yaw and roll, you have them a little mixed up.

Pitch is the term used in aviation for the angle the plane is moving up or down, i.e its rotation around the x-axis.

Yaw is the direction it is moving, i.e. rotation around the y-axis (assuming the y-axis is aligned with the gravitational forces, or pointing upwards)

Roll is about the z-axis or the axis in which you are looking.

To get correct results for these three terms you should start by rotating around z, then around x, and finally around y. This will assure that roll doesn''t affect the view direction, yaw will correctly define the direction in the xz-plane, as pitch will show the angle between the view direction and the xz-plane.

This holds true for the world matrix, i.e the matrix used to place objects in the world.

www.AngelCode.com
AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - <a href="http://www.angelcode.com/tower" rel

Topic Locked

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

Sign in to reply to this topic.