View Full Version : Vector * Matrix
Is there any significance to why Position3 * Matrix3 is ok, but Matrix3 * Position3 is incompatible?
|
|
EverZen
10-23-2007, 04:20 PM
I think it comes down to the fact that when 3dsmax is multiplying a point3 by a matrix3 then it is effectively doing a matrix multiplication (and matrix multiplication is not commutative meaning Matrix A * MatrixB != MatrixB * Matrix A). In fact it is only possible to perform an A*B and a B*A multiplication when then number of rows and columns are the same in both matricies. I.e Both A and B are nxn matricies (where n is an integer).
In this case, I assume that we are Mutliplying a point3 which is effectively a (1 x 3) Matrix (1 row and 3 columns) by a (3 x 3) matrix which is fine. However to try and do it the other way around i.e multiplying a (3x3) by a (1x3) is impossible which might be 3DsMax is not allowing it.
I might be wrong here since, I do not fully understand the inner workings of 3dsmax, but I hope I might have shed a little light on the matter.....
EverZen
I believe that you are correct.
try this:
matrix3*(transMatrix point3)
martinB
10-24-2007, 12:03 AM
Hope I get this right... ;)
A matrix3 value really is a 4x3 matrix (four rows). And a point3 value is a (1x3) row vector, therefore goes to the left of the matrix, not to the right.
The pure math would be to use "homogeneous coordinates" with a four element vector and a 4x4 matrix. Then a simple matrix multiplication as we learned it in school can represent all the (affine) 3D transformations we normally need.
I guess 3ds Max takes a shortcut here to save memory and computation time: If you multiply a vector with a matrix in 3ds Max, it will internally multiply the vector with the 3x3 sub-matrix and then add the fourth row. Therefore, some 3D transformations (projections) cannot be represented with matrices in 3ds Max IIRC.
-- MartinB
Is there any significance to why Position3 * Matrix3 is ok, but Matrix3 * Position3 is incompatible?
Well, your multipling a vector by each row of the matrix in the first instance. Where as if your multiply your 4X3 (columns * rows) matrix about 3 vectors its expecting a 4th vector because its multipling each unit of each row by a unit of the vector. The rule is if you multiply a matrix by a vector, the vector has to have the same amount of parts as columns in the matrix. (so if the matrix has 4 columns the vector has 4 parts: [x,y,z,w])
So for example:
|a1 a2 a3 a4|
|b1 b2 b3 b4|
|c1 c2 c3 c4| * [d,e,f,g] = a1*d + a2*e + a3*f + a4*e, b1*d etc, etc so:
COLUMNS X ROWS =
4X3 can multiply by a 4point vector [x,y,z,w]
3X3 can multiply by a 3point vector [x,y,z]
2X3 can multiply by a 2point vector [x,y]
1X3 can multiply by a float or integer
cheers,
That makes a lot of sense. Thanks to everyone for their input.
Khye
That makes a lot of sense. Thanks to everyone for their input.
Khye
Khye,
On an OT note, congratulations on your marriage! :)
Khye,
On an OT note, congratulations on your marriage! :)
Thanks. I look forward to using my gift.
Khye
CGTalk Moderation
10-25-2007, 02:20 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.