XNA for C#
DirectX 9 for C#
DirectX 9 for C++
DirectX 9 for VB
Forum
   
My XNA Book
      
       Go to section on this site

Additional info


Latest Forum posts

 Tutorial 3 for Windows Phone 7
  Posted by: Anonymous
  When: 20/05/2013 at 02:30:13

 No download link for 2d series: shooter
  Posted by: zaboleq
  When: 07/05/2013 at 15:46:28

 Collision Class?
  Posted by: Anonymous
  When: 05/05/2013 at 19:03:59

 stack overflow
  Posted by: cityguy
  When: 07/04/2013 at 01:58:38

 Meshes looks strange.
  Posted by: ab_saratov
  When: 01/04/2013 at 04:31:08

 Lamppost Not loaded
  Posted by: Anonymous
  When: 22/03/2013 at 06:43:52

 Collision Class?
  Posted by: Da_Boom
  When: 21/03/2013 at 01:23:09

 Math boggles me
  Posted by: cityguy
  When: 17/03/2013 at 03:44:48

 Collision Class?
  Posted by: Da_Boom
  When: 16/03/2013 at 03:44:42

 Tree update
  Posted by: Anonymous
  When: 15/03/2013 at 21:11:22


Ads

Homogeneous matrices

If you access one of the matrices used by DirectX, you’ll see they have 16 components, which means they consist of 4 rows and 4 columns. This format was chosen, to allow these matrices to also represent translations.

To translate a point, we need to ADD a number to each of its components. By using 3x3 matrices, we can only get coordinates that are multiples of the original coordinates. So next to X,Y and Z, we’ll add a constant to our coordinates. For simplicity, let’s set this to 1. So from now on, we’re going to represent 3D points by 4 coordinates. For example, the point at position (10,5,0) will get coordinates (10,5,0,1). These coordinates are called the homogeneous coordinates of a point.

The scaling and rotation matrices remain the same, but the get an additional row and columns that are 0, except for the point m44, which is 1. Here you can see what the scaling and Y-rotation matrices look like in their homogenous form:



This looks a little bit more complex, but now we can at last also define a translation matrix:



Let’s have a look at a small example. Suppose we want to translate the point (10,5,0) into the direction (-8,2,4). This is how it’s done:



So this gives use the point (2,7,4). This result is of course very obvious, but the point I’m trying to make here is that now we fulfill the 3 basic properties:

1) We have a matrix corresponding to every basic transformation
2) Multiplying such a matrix with the coordinates of a point will give the coordinates of the transformed point
3) Multiplying 2 matrices gives a new matrix, that corresponds to the combined transformations, corresponding to the 2 starting matrices

If you have been following up to this point, you’ll notice the 4th coordinate has absolutely NO geometrical meaning. It’s just there to allow us to define a translation matrix, that has the same shape as a scaling and rotation matrix.

This actually concludes these pages on matrices. One final remark however: sometimes you’ll notice this constant is not 1, as was the case in this theory. In fact, the general rule says you simply have to divide the X,Y and Z coordinate by this 4th coordinate. Let’s call this 4th coordinate W from now on.

Put simply: (20,10,0,2) = (10,5,0,1) both represent the same 3D point (10,5,0). So the simple rule to derive the 3D point out of 4 coordinates is:






Click here to go to the forum on this chapter!

Or click on one of the topics on this chapter to go there:
  • Confused with homegenous
          Hi riemer, Long time no see, I've been busy ;)...
  • Laatste deel van deze homogene matrices
          Can you explain the last part of it? If you wan't...





    Google
     
    Webwww.riemers.net


    If you appreciate the amount of time I spend creating and updating
    these pages, feel free to donate -- any amount is welcome !



    - Website design & XNA + DirectX code : Riemer Grootjans -
    ©2003 - 2011 Riemer Grootjans
  • Translations

    This site in English
    This site in Korean
    This site in Czech

    Microsoft MVP Award



    2007 - 2011 MVP Award
    DirectX - XNA

    Contents

    News
    Home
    Forum
    XNA 2.0 Recipes Book (8)
    XNA 3.0 Recipes Book (8)
    Downloads
    Extra Reading (3)
    Matrices: geometrical
    Matrix Mathematics
    Homogenous matrices
    Community Projects (1)
    Tutorials (160)
    -- Expand all --


    Thank you!

    Support this site --
    any amount is welcome !

    Stay up-to-date

    I don't have the time to keep a News section, so stay informed about the updates by clicking on this RSS file!