Sign in to follow this  
FireSoul

Understanding Matrix Transformations

Recommended Posts

Hi, i have been working with matrices for a while now, and i think i am beginning to understand them a lot better, but i have a problem with understanding the individual parts to a matrix. The specific parts i am refering to are, basically, what does each row/column of a matrix represent. From debugging i have found out that _41, _42, _43 are the position coordinates in world space (unless im wrong). The reason why i am asking this is so that i can transform a normal vector(just a line or a shape) from world to model space and back again. Specifically, the mathematics behind this (ie. what parts of my existing vector do you multiply/add with what parts of a matrix). A simple formula used for transforming a D3DXVECTOR3 using a 4x4 Matrix would be much appreciated. Thanks for any replies.

Share this post


Link to post
Share on other sites
I don't know how to explain but here is the formula:

x = vector.x*matrix[0][0] + vector.y*matrix[0][1] + vector.z*matrix[0][2] + matrix[0][3];
y = vector.x*matrix[1][0] + vector.y*matrix[1][1] + vector.z*matrix[1][2] + matrix[1][3];
z = vector.x*matrix[2][0] + vector.y*matrix[2][1] + vector.z*matrix[2][2] + matrix[2][3];

Share this post


Link to post
Share on other sites
Hi there FireSoul,
How are you doing buddy?

The Problem
Understanding matrices and transformations.

The Solution
Object Space : This is where your vertices are defined for your object
World Space : This locates your object in world space... the world that you work with. We go here from object space using a world transformation matrix
View Space : Locates your camera in space and relocates your objects around your camera, we go here from world space using a view transformation matrix.
Clip Space : This space basically clips your view frustum into a cube. Which gives the impression of perspective/depth etc.. We go here from view space using a projection transformation matrix.

Matrices are nice since we can jam alot of information in them.
Translation matrix (Movement)
1 0 0 0
0 1 0 0
0 0 1 0
x y z 1
and so forth...
I would suggest reading this part of the DirectX SDK

It explains the transformations very well and how some of the math works.

Also, With regard to your second question.
You want to transform a normal vector from world to model space. This is done using an inverse world transformation matrix. You could use the D3DXMatrixInverse Function and transform the vector by the resulting matrix using D3DXVec3Transform. Also if you want to transform a vector from model space to world space you could just transform the vector by the world transformation matrix.

I hope this helps a bit buddy. Take care. If you have any more questions. Please do not hestitate to ask.



Share this post


Link to post
Share on other sites
the Directx matrix:

| Xx Yx Zx 0 |
| Xy Yy Zy 0 |
| Xz Yz Zz 0 |
| pX pY pZ 1 |

pX,pY,pZ is position in world space.
Xx,Xy,Yx,Zy..... is how jour object will look in world space, if u put Xx=1, Yy=1,Zz=1 and others 0, u will get the same object as jour object in local space, try to manipulate these to get cool effects.

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