Help with matrix math
I need some help with the following theory matter:
I have a point initially at 0,0,0
Suppose i do some translations and rotations. How do i get the new point coordinates ?
I suppose i have to get the new matrix with the glGetfloatv function, but which matrix values hold the xyz info ?
Thanks
you do not get the (x,y,z) from the matrix ... the scaling, rotation, and translation matrices are multiplied by each other and then finally the <x,y,z,w> that neds to be transformed by that 'sequence of movements'. the resulting 1x4 (or 4x1 depending on order of operations == handedness) matrix is the transformed point you seek to 'get'.
i think* :)+)
i think* :)+)
April 28, 2005 12:28 AM
A vector can be represented by a 4x1 matrix. In fact a vector IS a 4x1 matrix. Usually 3D libraries have one class for vector and one class for matrix for optimization and simplication issues. Mathematically, vector and matrix are both representations of objects and their states in a vectorial space. By the way we can also say a matrix is a collection of vectors. Each rows and columns can give a 4x1 matrix and used as a vector. It can be very handy for different algorythm; frustrum culling for example.
Anyway that's why it makes sense to multiply a vector by a matrix. The result of the multiplication is a new vector (in fact a new 4x1 matrix). The sentence "a vector is transformed by a matrix to a new vector" is resumed by this multiplication. Let have a vector v and a matrix m. If m is the result of one translation and one rotation, v multiply m will give you a new vector "transformed" by the translation and the rotation. Numerically:
|m00 m01 m02 m03 |x |x * m00 + y * m01 + z * m02 + 1.0f * m03
|m10 m11 m12 m13 X |y = |x * m10 + y * m11 + z * m12 + 1.0f * m13
|m20 m21 m22 m23 |z |x * m20 + y * m21 + z * m22 + 1.0f * m23
|m30 m31 m32 m33 |1.0f |x * m30 + y * m31 + z * m32 + 1.0f * m33
If there is no scaling, x * m30 + y * m31 + z * m32 + 1.0f * m33 = 1.0f.
Sorry for my english, hope to be understable... :)
Anyway that's why it makes sense to multiply a vector by a matrix. The result of the multiplication is a new vector (in fact a new 4x1 matrix). The sentence "a vector is transformed by a matrix to a new vector" is resumed by this multiplication. Let have a vector v and a matrix m. If m is the result of one translation and one rotation, v multiply m will give you a new vector "transformed" by the translation and the rotation. Numerically:
|m00 m01 m02 m03 |x |x * m00 + y * m01 + z * m02 + 1.0f * m03
|m10 m11 m12 m13 X |y = |x * m10 + y * m11 + z * m12 + 1.0f * m13
|m20 m21 m22 m23 |z |x * m20 + y * m21 + z * m22 + 1.0f * m23
|m30 m31 m32 m33 |1.0f |x * m30 + y * m31 + z * m32 + 1.0f * m33
If there is no scaling, x * m30 + y * m31 + z * m32 + 1.0f * m33 = 1.0f.
Sorry for my english, hope to be understable... :)
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement