DirectX:Change of Coordinate Transformation

Blog under Tag DirectX DirectX is mainly used for recording the learning process, the main reference "DirectX 12 3D games combat development." Data in this chapter is a review of linear algebra coordinate transformation rhythm along DX12 dragon in the book.

Coordinate transformation

Coordinate transformation of coordinate transformation is short. In computer graphics, often we need to study the same object in different coordinate systems, requiring transformed coordinate system. The object coordinate transformation vector or may be a point, the point where the pointing position, both for the coordinate conversion are different, need to be discussed separately.

Coordinate transformation vectors

Since the vector has no location information, so the coordinate transformation vectors can transform the coordinate system before and after the origin coincident be moved.

Consider a vector p = (x, y) in a two-dimensional coordinate system A, it can be expressed as a linear combination:
\ [\ VEC P} = {X \ VEC U_A} + {Y \ V_a VEC {} \]
wherein , u, v coordinate system a is a p-base form of formula written as a linear combination that is:
\ [\ VEC {p} = [X, Y] \ Times \ bmatrix the begin {} \ {VEC U_A} \\ \ VEC V_a} {\ bmatrix End {} \]
U, V are generally orthogonal base unit. At this time, if you want to change the coordinate system for the study of B, then B p in the coordinate system as:
\ [\ VEC {p} \ Prime = (X \ Prime, Y \ Prime) = [X, Y] \ Times \ begin {bmatrix} \ vec {u_B
} \\ \ vec {v_B} \ end {bmatrix} \] at this time, the u, v coordinates in the coordinate system B coordinates. That is, the respective axial direction vector if the group is known to be a vector in the transformed coordinate system to be transformed coordinate system representation, these basis vectors are sequentially arranged in a matrix rows i.e. vectors coordinate transformation matrix obtained. This conclusion is also clear that the establishment of high-dimensional coordinate system conversion. Coordinate conversion formula for the 3-dimensional vector:
\ [\ VEC p_B} = {X \ VEC U_B} + {Y \ VEC v_B} + {Z \ W_B VEC {} \]

Coordinate transformation point

Coordinate transformation point is different, to the point of translation will change the location of the point. Then, when the coordinate transformation of the point on the need to add a relative offset, this offset is represented by the vector V. Suppose before conversion coordinate system A, be transformed coordinate system is B, the coordinates of the point p, the offset is not considered, and the same coordinate transformation vector points:
\ [\ VEC p_B} = {X \ U_B VEC {} + y \ vec {v_B} +
z \ vec {w_B} \] obviously, V is the origin of the coordinate system B of the direction vector origin of the coordinate system a, that is:
\ [\ VEC {V} = O_A-O_B \]
Since the it is converted after adding the offset value, so the above equation should be expressed in the coordinate system B. Then, the complete formula of coordinate transformation point is:
\ [\ VEC p_B} = {X \ VEC U_B} + {Y \ VEC v_B} + {Z \ VEC W_B} + {\ \\ VEC {V} \ {VEC V} is equal to the respective component values in O_A \]

Matrix representation

\ [\ Begin {aligned} & vector for it, (x \ prime, y \ prime, z \ prime) = x \ vec {u_B} + y \ vec {v_B} + z \ vec {w_B} \\ & point, for, \ space \ space \ space (x \ prime, y \ prime, z \ prime) = x \ vec {u_B} + y \ vec {v_B} + z \ vec {w_B} + \ vec {V } \\ \ end {aligned} \]

Content reference to the previously homogeneous coordinates, the same can be easily unified treatment for both cases. Extended fourth dimension w, w 0 represents the vector, w is 1 represents a point, while the transformation matrix M extended four-dimensional homogeneous matrix C:
\ [transformation matrix C = \ begin {bmatrix} M & 0 \\ V & 1 \ end {bmatrix } = \ begin {bmatrix} u_x
& u_y & u_z & 0 \\ v_x & v_y & v_z & 0 \\ w_x & w_y & w_z & 0 \\ O_x & O_y & O_z & 1 \ end {bmatrix} \] this matrix is also well understood, in which each row is a homogeneous coordinate. The first three lines are the basis vectors in the original coordinate system to be homogeneous coordinate transformation of coordinate system, so the value of w 0; fourth row offset value corresponding to the coordinate origin in the original coordinate system to be transformed coordinate system, so the value of w 1.

Coordinate transformation matrix and inverse matrix composite

Coordinate transformation matrix composite remains essentially a composite matrix, only in the order from left to right in a given coordinate point is calculated to obtain the final vector or coordinate system. Here to point out, this series is a long book of reference method, which uses a matrix multiplying a row vector representation of transformation, in fact, can also put a representative point vector and vector transposed column vector, then take a right sub-matrix set, the result is the same.

And similar conventional matrix, the inverse matrix is equal to a series of coordinate transformation separately on each of the inverse matrix multiplication and then reverse. It is also well understood, the work of the inverse matrix is the "undo" the original transformation, it is clear that we need to change before pressing the reverse "undo" applied, namely:
\ [\ vec {v} \ Times (M_1M_2 ... M_n) ^ {- 1} = \ vec {v} \ times M_n ^ {- 1} ... M_2 ^ {- 1} M_1 ^ {- 1} \]

Guess you like

Origin www.cnblogs.com/Li-F/p/11502995.html