D3dx Matrix Functions

Source: Internet
Author: User
1: d3dxmatrixaffinetransformation (): creates an ry transform matrix. The null parameter is treated as a matrix of units. Define d3dxmatrix * winapi plugin (d3dxmatrix * pout, float scaling, const d3dxvector3 * protationcenter, const d3dxquaternion * protation, const d3dxvector3 * ptranslation); parameter pout [in, out] refers to the matrix of the returned results in the d3dxmatrix structure. Scaling [in] scaling factor. Protationcenter [in] points to the d3dxvector3 structure pointer and rotates the center vector. If it is set to null, a unit matrix is used instead of MRC. Protation [in] points to the d3dxquaternion structure rotation matrix. If the parameter is null, the unit matrix Mr is used. Ptranslation [in] points to the d3dxvector3 structure transformation vector. If it is null, the unit matrix MT is used. Return Value: point to the Family matrix of the d3dxmatrix structure. (This function is to use the following formula to calculate an affined transformation matrix: mout = MS * (MRC)-1 * Mr * MRC * Mt where: mout = output matrix (pout) MS = scaling MRC = protationcenter mr = protation Mt = ptranslation returns the same value as pout, in this way, d3dxmatrixaffinetransformation can be used as other function parameters. 2d ry transformation matrix using d3dxmatrixaffinetransformation2d2: d3dxmatrixaffinetransformation2d (): Create an ry transformation matrix on the X-Y plane. The null parameter is treated as a unit matrix 3: d3dxmatrixdecompose (): decomposes a 3D transformation matrix into a scaling factor, rotating component, and moving vector. 4: d3dxmatrixdeterminant (): calculates the matrix determine value. 5: d3dxmatrixidentity (): Create a unitized Matrix 6: d3dxmatrixinverse (): Calculate the inverse matrix of the matrix. If the inverse array does not exist, null is returned. 7: d3dxmatrixisidentity (): determines whether a matrix is a unit array. 8: d3dxmatrixlookatlh (): builds a left-handed, look-at matrix. d3dxmatrixlookatrh (): 9: d3dxmatrixmultiply (): the product of the matrix; 10: d3dxmatrixmultiplytranspose (): transpose After calculating the product of two matrices. This function is often used in vertex and pixel shaders: d3dxmatrixortholh (), d3dxmatrixorthorh (): builds a left-handed Orthographic Projection matrix.12: d3dxmatrixorthooffcenterlh (), d3dxmatrixorthooffcenterrh (): 13: Fill (), d3dxmatrixperspectivefovrh (): 14: d3dxmatrixperspectivelh (), d3dxmatrixperspectiverh (): 15: d3dxmatrixreflect () create a plane reflection matrix from the plane equation. Note: This function first standardizes the coefficients of the flat equation, and then creates the reflection matrix of the flat equation. The Return Value of the function is the same as that of the pout parameter. In this way, the d3dxmatrixreflect function can be used as a parameter of other functions. This function uses the following formula to calculate the plane reflection matrix: P = normalize (plane);-2 * P. A * P. A + 1-2 * P. B * P. a-2 * P. C * P. A 0-2 * P. A * P. b-2 * P. B * P. B + 1-2 * P. C * P. B 0-2 * P. A * P. c-2 * P. B * P. c-2 * P. C * P. c + 1 0-2 * P. A * P. d-2 * P. B * P. d-2 * P. C * P. D 1 if an object is mirrored along a plane, you can use this function; 16: d3dxmatrixrotationaxis (): Creates a matrix that rotates around an axis; 17: d3dxmatrixrotatioxnx; d3dxmatrixrotationy; d3dxmatrixrotationz; 18: d3dxmatrixrotationquaternion (): B Uilds a rotation matrix from a quaternion19: d3dxmatrixrotationyawpitchrollbuilds a matrix with a specified yaw, pitch, and roll. d3dxmatrix * d3dxmatrixrotationyawpitchroll (d3dxmatrix * pout, float yaw, float pitch, float roll); parameterspout [In, out] pointer to the d3dxmatrix structure that is the result of the operation. yaw [in] yaw around the y-axis, in radians. pitch [in] pitch around the X- Axis, in radians. roll [in] roll around the z-axis, in radians. return valuespointer to a d3dxmatrix structure with the specified yaw, pitch, and roll. note that the conversion sequence is roll first, then pitch, and then yaw; that is, first rotate around the Z axis, then rotate around the X axis, and then rotate around the X axis; 20: d3dxmatrixscaling (): create a scaling matrix; 21: d3dxmatrixshadow (): Create a plane shadow matrix. Definition: d3dxmatrix * winapi d3dxmatrixshadow (d3dxmatrix * pout, const d3dxvector4 * plight, const d3dxplane * pplane); parameter: pout [In, out] indicates the operation result matrix of the d3dxmatrix structure. Plight [in] points to the light position vector of the d3dxvector4 structure. Pplane [in] points to the plane equation of the d3dxplane structure. Return Value: point to the matrix of the d3dxmatrix structure, which is used to transform the ry in the plane shadow matrix. Note: if there is a shadow on a geometric object from the light source, you can use the d3dxmatrixshadow function to calculate the shadow transformation matrix. The Return Value of the function is the same as that of the pout parameter. In this way, the d3dxmatrixshadow function can be used as a parameter of other functions. Calculate the matrix using the following method: P = normalize (plane); L = light; D = dot (P, L) p. A * L. X + D p. A * L. Y p. A * L. z p. A * L. w p. B * L. x P. B * L. Y + D p. B * L. z p. B * L. w p. C * L. x P. C * L. Y p. C * L. Z + D p. C * L. w p. D * L. x P. D * L. Y p. D * L. z p. D * L. W + d if the W component of the light is 0, it indicates the direction of light from the origin. If W is 1, it indicates that it is a point light source. In a demo that generates a plane shadow of an object, you can see the following code: // position shadow d3dxvector4 lightdirection (0.707f,-0.707f, 0.707f, 0.0f ); /* xz */d3dxplane groundplane (0.0f,-1.0f, 0.0f, 0.0f); d3dxmatrix s; d3dxmatrixshadow (& S, & lightdirection, & groundplane ); d3dxmatrix t; d3dxmatrixtranslation (& T, teapotposition. x, teapotposition. y, teapotposition. z); d3dxmatrix W = T * s; device-> settransform (d3dts_world, & W); 22: d3dxmatr Ixtransformation (), d3dxmatrixtransformation2d () to create a transformation matrix. If the parameter is set to null, it is processed as a matrix of units. Definition: d3dxmatrix * winapi Centers (d3dxmatrix * pout, const d3dxvector3 * pscalingcenter, const limit * pscalingrotation, const limit * pscaling, const d3dxvector3 * protationcenter, const limit * protation, const d3dxvector3 * ptranslation); parameter: pout [In, out] points to the operation result matrix of the d3dxmatrix structure. Pscalingcenter [in] points to the zoom center vector of the d3dxvector3 structure. If it is null, the MSC matrix is the unit matrix. Pscalingrotation [in] points to the zooming and rotating tuples of the d3dxquaternion structure. If the parameter is null, the MSR matrix is the unit matrix. Pscaling [in] points to the zoom vector of the d3dxvector3 structure. If the parameter is null, The MS matrix is the unit matrix. Protationcenter [in] points to the rotation center vector of the d3dxvector3 structure. If the parameter is null, the MRC matrix is a matrix of units. Protation [in] points to the four tuples that rotate the d3dxquaternion structure. If the parameter is null, the Mr matrix is the unit matrix. Ptranslation [in] points to the translation vector of the d3dxvector3 structure. If the parameter is null, the MT matrix is the unit matrix. Return Value: point to the transformation matrix of the d3dxmatrix structure. Matrix. (This function uses the following formula to calculate the transformation matrix: mout = (MSC)-1*(MSR)-1 * MS * MSR * MSC * (MRC) -1 * Mr * MRC * Mt where: mout = output matrix (pout) MSC = pscalingcenter MSR = pscalingrotation MS = pscaling) MRC = protationcenter mr = protation Mt = ptranslation returns the same values as those returned by the pout parameter. In this way, the d3dxmatrixtransformation function can be used as a parameter of other functions. If it is a 2D transformation matrix, you must use the d3dxmatrixtransformation2d function. 23: d3dxmatrixtranslation (): builds a matrix using the specified offsets.24: d3dxmatrixtranspose (): transpose the Matrix

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.