Jump to content
  • Advertisement
Sign in to follow this  
Gondolin

Special Case Vector-Matrix Transformations

This topic is 4012 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

If you multiply a 4 component vector by 4x4 transformation matrix without shearing then can you simply ignore the 4th column of the matrix in the computation? I.e. If M is a transformation matrix (combined and inverted from anything except shearing transforms) then doesn't it always have the form: * * * 0 * * * 0 * * * 0 * * * 1 ? The w component of the output vector cannot change if this is true, so no calculations need to be done for it? But if this is true, then why does DirectX (note this is not a DirectX question, but an example) provide three transform functions: 1. D3DXVec3Transform (assumes w = 1) 2. D3DXVec3TransformCoord (assumes w = 1 and projects w back to 1) 3. D3DXVec3TransformNormal (assumes w = 0) I can see the use of (3), since you can eliminate the 4th row and column calculations entirely. But if the transform is like the one I defined, is there any difference between (1) and (2)? What I mean is, do you only have to care about the 4th column and projecting back to homogenous w = 1 space if you have possible shearing transforms? Or do I not understand something about the matrix transformation?

Share this post


Link to post
Share on other sites
Advertisement
DirectX provides all three functions because it isn't always the case that the last row/column of the transformation matrix is (0,0,0,1). And when it isn't, in some cases you might want the final W value to be preserved (1), while in other cases you don't care and want W divided out (2). It all depends on the context.

Otherwise, when you have (0,0,0,1), then you can use (1) and (2) interchangeably (although (1) is preferable since I presume it performs one less division), or even (3). Of course you have to be more careful with the Vec4 functions, since the input W could be anything.

Share this post


Link to post
Share on other sites
Thanks for the reply. I am I correct in saying the column will always be [0, 0, 0, 1] for normal transformations (i.e. non shearing)? And in what contexts would you not want the w component projected back to 1?

The real question is, if I know my transformation matrices will never contain shearing, is it possible for me to optimize the vector-matrix multiplication, by eliminating the multiplication of the vector and the last column?

Share this post


Link to post
Share on other sites
Quote:
Original post by Gondolin
Thanks for the reply. I am I correct in saying the column will always be [0, 0, 0, 1] for normal transformations (i.e. non shearing)?

It depends on what you mean by a "normal" transformation. For translation, rotation, and scaling, then the above case will always be true. But then again, I also consider projection to be a normal transformation. I'm not sure about shearing matrices. I learned about them a long time ago but I've never actually used them directly.

Quote:
And in what contexts would you not want the w component projected back to 1?

Whenever you're just doing a linear transformation, and the final result isn't to be interpreted as a homogeneous coordinate.

Quote:
The real question is, if I know my transformation matrices will never contain shearing, is it possible for me to optimize the vector-matrix multiplication, by eliminating the multiplication of the vector and the last column?

I can't say for sure, since I'm not that familiar with the shearing transformation. If it's the only transformation that produces a non-[0,0,0,1] last row/column, then sure you can optimize away the last coordinate for the other combinations of transformations.

Share this post


Link to post
Share on other sites
Quote:
Original post by Gondolin
Thanks for the reply. I am I correct in saying the column will always be [0, 0, 0, 1] for normal transformations (i.e. non shearing)?

Yes. That includes shearing, BTW.
Quote:
The real question is, if I know my transformation matrices will never contain shearing, is it possible for me to optimize the vector-matrix multiplication, by eliminating the multiplication of the vector and the last column?
Yes. And it'll work for shearing too. What it won't work for is projection matrices.

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!