# Special Case Vector-Matrix Transformations

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

## 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 on other sites
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 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 on other sites
Quote:
 Original post by GondolinThanks 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 on other sites
Quote:
 Original post by GondolinThanks 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.

1. 1
2. 2
3. 3
Rutin
19
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633657
• Total Posts
3013197
×