Matrices (Matrix)

Monday to Friday, a day, 7 am Beijing time on time updates -

The matrix is ​​not just a Hollywood movie trilogy, but an exceptionally powerful mathematical tool that greatly simplifies the process of solving one or more equations with variables that have complex relationships with one another (not Han College matrix as a Huahuachangzai, like every day multi punctuate the fans, want to sell finished the course, want to promote their own engine, it is simply ill, it allows the expression of matrix spatial location relationships are simplified, so it seems, the matrix is ​​indeed a good man say. but compared to this as Ko Wen-je like to read into huan fan of the Eastern Han Dynasty academy or at least to force it a little higher grid). One common example of this, near and dear to the hearts of graphics programmers, is coordinate transformations (matrix this classmate More common posture is to coordinate conversion). For example, if you have a point in space represented by x, y, and zcoordinates, and you need to know where that point is if you rotate it some number of degrees around some arbitrary point and ori entation, you use a matrix (for example, you use the space in the matrix along an axis of rotation to a point, you need to know where this point is to go).

Mathematically, a matrix is ​​nothing more than a set of numbers arranged in uniform rows and columns-in programming terms, a two-dimensional array (the mathematical sense, the matrix is ​​composed of a lot of data ranks cook something in the programmer's eyes, is a two-dimensional array). a matrix does not have to be square, but all of the rows must have the same number of elements and all of the columns must have the same number of elements (not necessary have to be a square matrix , but the required number of elements in each row or each column of the same line). the following are a selection of matrices. they do not represent anything in particular but serve only to demonstrate matrix structure (the following is a series of matrices, they does not represent anything, just shows the structure of the matrix). Note that it is also valid for a matrix to have a single column or row (matrix may contain only one row or one element). a single row or column of numbers would more simply be called a vector, as discussed previously (if a moment Only one row or array, it can be seen as a vector). In fact, as you will soon see,
Matrices (Matrix)
Matrix "and" vector "are two important terms that you see often in 3D graphics programming literature (in 3D graphics, the matrices and vectors are very important things). When dealing with these quantities, you also see the term" scalar. "(when the processing of these data, you often will see scalar, a scalar is a number length or what data other things of expression) a scalar is just an ordinary single number used to represent a magnitude or a specific quantity (you know-a regular old, plain, simple number ... like before you cared or had all this jargon added to your vocabulary). Matrices can be multiplied and added together, but they can also be multiplied by vectors and scalar values (inter-matrix may be multiply-add operation, it can be multiplied with the vector and scalar). multiplying a point (represented by a vector) by a matrix (representing a transformation) yields a new transformed point (another vector) (dot and a matrix multiplication can be converted to point).

In the meantime, as previously for vectors, you will find a number of useful matrix functions and features available in the vmath library (as explained above and the same content, vmath library also contains a number of functions can be used for matrix calculation). The source code to this library is also available in the file vmath.h in the book's source code folder (source code in vmath.h years). this 3D math library greatly simplifies many tasks in this chapter and the ones to come (this 3D math library is really great, and it simplifies a lot of work to do things behind, however, feel that students with learning nothing, just let him teaching content author looks back will be easy). One useful feature of this library is that it lacks incredibly clever and highly optimized code! (a very important feature is that the library code silly, totally did not how optimized) this makes the library highly portable and easy to understand (which would make the library easily to be understood, the results obtained with our actual experience is not Will look at those obscure codes, especially behind the mathematical theory of time, even if they are no longer willing to see finished second time). You'll also find it has a very GLSL-like syntax (you'll find it with GLSL grammar is like).

In your 3D programming tasks with OpenGL, you will use three sizes of matrices extensively: 2 × 2, 3 × 3, and 4 × 4 (in our OpenGL, you will use three different sizes of matrix, 2,3 , 4-dimensional matrix). the vmath library has matrix data types that match those, defined by GLSL, such as (vmath implementation code to provide a corresponding matrix, as follows :)

vmath::mat2 m1;
vmath::mat3 m2;
vmath::mat4 m3;

As in GLSL, the matrix classes in vmath define common operators such as addition, subtraction, unary negation, multiplication, and division, along with constructors and relational operators (like GLSL in the same, vmath library defines the basic operation matrix operation function interface). Again, the matrix classes in vmath are built using templates and include type definitions for single- and double-precision floating-point, and signed- and unsigned-integer matrix types (Again, this function is performed by the C ++ template, you can use any type of data, such as float, double, or ××× you can. in fact, as a college student or a junior player 3D graphics, you will not see his vmath achieve these foreigners write something you need to have cattle X C ++ base, barely able to read their C ++ code, this is extremely not recommended, learning a language in order to do the project, not to use the language of high-level syntax, C ++ learning should stop, the focus is back Graphics look overdone. As for 3D graphics, I The suggestion is that if you want to understand, or down to earth step by step to put together your foundation engineering college books have turned again, is simply a passing of here, limited knowledge content)

Translations of this day to get here, see you tomorrow, bye ~

Get the latest plot first time, please pay attention to the Eastern Han Dynasty academy and the heart of the public graphic No.

Han College, waiting for you to play Oh

Guess you like

Origin blog.51cto.com/battlefire/2425457