Jump to content
  • Advertisement
Sign in to follow this  
penetrator

Help with matrix math

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
Advertisement
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* :)+)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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... :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!