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

 Problems loading effect file
  Posted by: dellams
  When: 03/02/2012 at 17:34:53

 rotating a model around itself
  Posted by: maxcabalfin
  When: 03/02/2012 at 08:41:25

 bones and quaternions
  Posted by: D_A_V_E
  When: 02/02/2012 at 12:18:22

 import
  Posted by: Anonymous
  When: 02/02/2012 at 06:53:32

 remove internal walls in the city
  Posted by: Anonymous
  When: 02/02/2012 at 05:01:09

 XNA 4.0
  Posted by: dellams
  When: 30/01/2012 at 19:38:27

 Adding Glow around Street Lights
  Posted by: pranavbagur
  When: 30/01/2012 at 13:44:01

 error x3000:syntax error
  Posted by: Anonymous
  When: 30/01/2012 at 06:06:37

 Another Effects error
  Posted by: Anonymous
  When: 29/01/2012 at 15:43:01

 feedback
  Posted by: amtyler
  When: 29/01/2012 at 09:17:38


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!