# Re: Affine and Transposed Matrices

From: Michel Walsh (vanderghast_at_VirusAreFunnierThanSpam)
Date: 10/22/04

```Date: Fri, 22 Oct 2004 09:03:40 -0400

```

Hi,

When there are too much information, it is like there is none.

A matrix is a tableau of numbers. Being said that, it is like if I tell
you a number is represented by bit, in a computer. You don't need to
understand how the bits are disposed, internally, in a floating point number

An affine matrix can represent, among other things, a translation, a
reflection, a rotation, a scaling, a shearing. The matrix is the
"representation", and what is really important is the operation to be
performed. A little bit as you have to make the difference between + and *,
and when using one instead of the other, the goal is to use the "methods"
that will perform the desired "operation". If that method returns a matrix
of a whatever is internal working and, in an OOP environment, technically,
that can be "hidden". DirectX allows you to move an object with method
regrouped under the "library" Matrix. As example, Matrix.Translation( x, y,
z) will have, for effect, to eventually move (translation) an object.
Matrix.RotationX, and so on, are other "operators".

To move a mesh object, or an object stored in a vertex buffer, but where
this object is "centered" at (0, 0, 0), and you want to move its center at
(x1, y1, z1), you "speak" to DirectX with a "language" that looks like (C#)
:

device.Transform.World = Matrix.Translation( x1, y1, z1);

If, further, after the translation, you need to rotate it by 10 degree,
around the Y axis, the language to use is like:

float angle =(float)Math.Sin( 10.0*Math.PI /180.0);
device.Transform.World = Matrix.Translation( x1, y1, z1) *
Matrix.RotationY( angle );

( the argument of the Sin( ) must be in radians, not in degree ).

If you had just used the Matrix.RotationY, you would have got only this, a
rotation. Since we want a translation and THEN a rotation, the "way" to "say
it" to DirectX is through a multiplication.

Like 3 to the power of 2 is not the same as 2 to the power of 3, a times b
is not the same as b times a, for "matrixes". It is important to get the
ordering right. In A * B * C, read it as A is performed first, then B, then
C. If you just use translations, that is not a real problem, but the
difference in the order may become visible if you mix the translations with
rotations, scaling, etc.

Do you really need to know the IEEE format of floats to use multiplication?
It may help, it is not a wrong thing to know the IEEE format, but I doubt it
is essential.

Hoping it may help,
Vanderghast, Access MVP

"Jacky Luk" <jl@knight.com> wrote in message
news:OtvyuYntEHA.444@TK2MSFTNGP10.phx.gbl...
>I am sure this is the most suitable group to post, But as i found no
> mathematics groups elsewhere, i hope this one won't be too much annoying.
>
> I am looking for the definitions of affine matrices and transposed
> matrices, what do they mean? What are their applications in Direct3D?
> Could
> someone raise some examples?
> Thanks
> Jack
>
>

## Relevant Pages

• Re: Graphic transforms
... rotation is not about the desired rotation point. ... before rotating since scaling is on two different axis, ... one must apply scale, then rotate, then translation. ...
(microsoft.public.dotnet.languages.vc)
• Re: Properly combining a Rotation and Translation matrix? (linear algebra)
... Vector3 containing a translation I wish to perform, ... defining a rotation I wish to perform. ... rotates the object by the given rotation matrix, ... a single matrix multiplication unless you cheat on the notation by ...
(sci.math)
• Re: Cross Power Spectrum and Image Registration
... a separate test, for a rotated image, using phase correlation. ... When I apply both a rotation and a translation to the ... Can you please send me your code of transform and inverse transform of log polar code? ...
(comp.soft-sys.matlab)
• Register one image with another that has been both translated and rotated
... of this as the camera is moving over stationary objects). ... difference between the images will be BOTH a translation and rotation ... % Solve for phase correlation function. ...
(comp.soft-sys.matlab)
• Re: [c# .net 2005] problem with moving start of world
... > The problem i'm trying to solve is that when i rotate using yAngle, ... > bottom of my first cube. ... translation will produce a different result than translation * rotation - ...
(microsoft.public.win32.programmer.directx.graphics)