3Д БУМ

3Д принтеры и всё что с ними связано

Understanding and Using Matrices

Just what is a matrix you ask? Well, simply put, a matrix is a rectangular array of numbers. A few examples of matrices are shown in Figure 1.1. You know what they look like, but just what are they good for? Well, mathematicians like to use them to represent systems of linear equa­tions. Using matrix operations, it is possible to solve these systems with much less work than using other methods, such as substitution, to solve them. In computer graphics, however, matrices are used to represent transformations. Transformations are essentially rotations and translation values for an object. The nice thing about using matrices for this type of thing is the fact that transformations can be combined using simple algebra, making it easy for you, and fast within your programs.

Most of the matrices that are used in graphics programming are square matrices. A square matrix is simply a matrix that has the same number of rows as columns. The leftmost matrix in Figure 1.1 is a square matrix. Generally, 3D math only requires matrices that are 3×3 or 4×4 elements. For clarity, and to simply keep the size of the figures

2

1

3

4

4

1

2

3

1

4

3~

[1-

12

7

1

4

~ 2

5

7

2

4

Figure 1.1 A few examples of matrices. Notice that they can be square or rectangular; two dimensions or one.

down, all the matrices in this chapter from now on will be 3×3 square matrices. Keep in mind that the same principles that apply to 3×3 matrices will also work on 4×4 matrices.

As you work with OpenGL, D3D, or any other graphics API, you will notice that they use mostly 4×4 matrices. There is a very good reason for this. A 4×4 matrix is capable of not only storing rotation values, but they can also store the translation, or movement values, at the same time. This eliminates the need to keep track of two separate sets of values for rotation and translation.

Individual elements of a matrix are denoted by the notation a^ The a is standard notation, the i is the number of the row the element resides in, and the j is the number of the column. Therefore, a matrix could be written as shown in Figure 1.2.

®11

Й12

Й13

&21

3.22

Э23

Э31

Э32

a33

Figure 1.2 A 3×3 matrix drawn using matrix notation. Note that the first subscript represents the row and the second subscript represents the column of the element.

Для любых предложений по сайту: [email protected]