News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests

Main Menu

You wont believe this ??

Started by K_F, March 16, 2014, 08:29:45 PM

Previous topic - Next topic

K_F

From Msofts Direct2d

If I'm not mistaken... this is a big stuffup.

The function from D2D1Helper.h

QuoteMultiplies two matrices and returns the result.

D2D1_MATRIX_3X2_F operator*(
  const D2D1_MATRIX_3X2_F &matrix1,
  const D2D1_MATRIX_3X2_F &matrix2
)
Well, first of all, multiplying two MxN (M != N) matrices is undefined ??
Anyway they proceed to...

Quote
void SetProduct(
            const Matrix3x2F &a,
            const Matrix3x2F &b
            )
        {
            _11 = a._11 * b._11 + a._12 * b._21;
            _12 = a._11 * b._12 + a._12 * b._22;
            _21 = a._21 * b._11 + a._22 * b._21;
            _22 = a._21 * b._12 + a._22 * b._22;
            _31 = a._31 * b._11 + a._32 * b._21 + b._31;
            _32 = a._31 * b._12 + a._32 * b._22 + b._32;

Doing it this way they should end up with a 3x3 matrix !!

Are they twiddling something or have they lost the plot completely?
:dazzled: :dazzled: :dazzled:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Gunther

Hi K_F,

Quote from: K_F on March 16, 2014, 08:29:45 PM
Well, first of all, multiplying two MxN (M != N) matrices is undefined ??

that's not necessary. The matrix multiplication isn't commutative, that's clear. Two matrices must be concatenated for multiplication. They are concatenated, if the number of columns of the first factor is equal to the number of rows of the second factor.

Gunther
You have to know the facts before you can distort them.

K_F

My Bad, Sorry.. I meant in this case of a 3x2 (Rows x Columns).

The only way I can see this working if they extend the matrices to 3x3 placing Zero's in the newly invented vectors.
The last two calculations makes it look like the A[3,3] = 1 and the B[3,3] = 0 ..
They fudging the factors... I'll dig into this
:biggrin:
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

Gunther

Hi K_F,

Quote from: K_F on March 16, 2014, 09:14:41 PM
My Bad, Sorry.. I meant in this case of a 3x2 (Rows x Columns).

yes, these matrices are not concatenated. The multiplication isn't possible.

Quote from: K_F on March 16, 2014, 09:14:41 PM
The only way I can see this working if they extend the matrices to 3x3 placing Zero's in the newly invented vectors.
The last two calculations makes it look like the A[3,3] = 1 and the B[3,3] = 0 ..
They fudging the factors... I'll dig into this
:biggrin:

It would be interesting to figure out that point.

Gunther
You have to know the facts before you can distort them.

FORTRANS

Hi,

   Multiplying two matrices is possible when the number of columns
of the first is equal to the number of rows of the second.  You can
not multiply a 3 x 2 matrix by a 3 x 2 matrix.  You can do a
3 x 2 by a 2 x 3 matrix.  And when you consider a vector as a
1 x N matrix, you can find many examples of vectors multiplied
by a N x N matrix.  Or an N x N matrix with an N x 1 vector.

   From the "CRC HANDBOOK of tables for MATHEMATICS", 4th
edition:

   cij = [ sum of k from 1 to n ] aik * bkj

They have an example of a 2 x 3 multiplied by a 3 x 3 giving a
2 x 3 if wanted.

   Think of vector multiplication giving either a scalar, a 1 x 1 matrix,
or a cross product, an N x 1 matrix, depending on the order of
multiplication.

Regards,

Steve N.

Gunther

Hi Steve,

Quote from: FORTRANS on March 16, 2014, 11:47:40 PM
Hi,

   Multiplying two matrices is possible when the number of columns
of the first is equal to the number of rows of the second. ... 

yes, see my reply #1.

Gunther
You have to know the facts before you can distort them.

qWord

When working in the XY plane, the third column of the 3x3 matrix is always {0,0,1} thus it can be omitted (see also XFORM struct)
MREAL macros - when you need floating point arithmetic while assembling!

K_F

Yeah.. I know, but they seem to be missing the 1 in the second Matrix

If they multiplying as it is in the code, they should end up with _13 = 0, _23 = 0 and _33 = 1 - this seems to be conveniently left out ?
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'

qWord

Quote from: K_F on March 17, 2014, 04:18:17 AMIf they multiplying as it is in the code, they should end up with _13 = 0, _23 = 0 and _33 = 1 - this seems to be conveniently left out ?
yes, it is redundant information.
MREAL macros - when you need floating point arithmetic while assembling!

K_F

OK.. maybe they concatenated it with an end 3x2 matrix to get it back into 2D.
I was worried they'd gone off the edge, no explanation in the header files..  :biggrin:


Thanks
'Sire, Sire!... the peasants are Revolting !!!'
'Yes, they are.. aren't they....'