Chinaunix首页 | 论坛 | 博客
  • 博客访问: 203478
  • 博文数量: 123
  • 博客积分: 1260
  • 博客等级: 中尉
  • 技术积分: 890
  • 用 户 组: 普通用户
  • 注册时间: 2011-05-06 07:35
文章分类

全部博文(123)

文章存档

2019年(1)

2018年(1)

2017年(7)

2016年(2)

2015年(15)

2014年(14)

2013年(25)

2012年(27)

2011年(31)

我的朋友

分类: 其他平台

2015-06-10 10:14:59

原文地址:

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:


阅读(2890) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~