Directx11 study notes 5-d3dxmath Library

Source: Internet
Author: User

Directx11 introduced a mathematical library for vector matrix calculation, and used 128 bits to calculate four 32-bit data records simultaneously (SIMD)

Previously, we basically used the directx10math. h header file. Since this math library is new, it must have been much faster and optimized in terms of convenient hardware processing. Technology is endless. We recommend that you use a new

Now, you can use the xnamath. h directx9 10 11 library separately, which is very convenient. The following table can quickly find the replacement function from the previous Math library.

By the way, we met a pitfall last night. It has been solved for a long time. It turns out that the xmatrix xmvector in xnamath involves an alignment problem.

If it is a local variable or a global variable, it cannot be felt. The hardware is automatically aligned. However, if it is placed in a class member variable, it is easy to report an error. And you cannot see the problem.

Debugging has been performed for a long time. Therefore, when using this library, we try to avoid setting it as a class member variable.

In the next section, I will attach the complete source code of the previous package to the xnamath library and draw a triangle. All subsequent tutorials will be demonstrated on this source code.

Quick query of their differences:

D3DXMath TypeDirectXMath EquivalentD3DXFLOAT16HALFD3DXMATRIXA16XMMATRIX or XMFLOAT4X4AD3DXQUATERNIOND3DXPLANED3DXCOLORXMVECTOR is used rather than having unique types, so you will likely need to use an XMFLOAT4Note  D3DXQUATERNION::operator * calls the D3DXQuaternionMultiply function, which multiplies two quaternions. But, unless you explicitly use the XMQuaternionMultiply function, you get an incorrect answer when you use XMVECTOR::operator * on a quaternion.D3DXVECTOR2XMFLOAT2D3DXVECTOR2_16FXMHALF2D3DXVECTOR3XMFLOAT3D3DXVECTOR4XMFLOAT4(or if you can guarantee the data is 16-byte aligned, XMVECTOR or XMFLOAT4A )D3DXVECTOR4_16FXMHALF4 Note  There is no direct equivalent to D3DXVECTOR3_16F in XNAMath.D3DXMath MacroDirectXMath EquivalentD3DX_PIXM_PID3DX_1BYPIXM_1DIVPID3DXToRadianXMConvertToRadiansD3DXToDegreeXMConvertToDegrees D3DXMath FunctionDirectXMath EquivalentD3DXBoxBoundProbeBoundingBox::Intersects(XMVECTOR, XMVECTOR, float&)D3DXComputeBoundingBoxBoundingBox::CreateFromPointsD3DXComputeBoundingSphereBoundingSphere::CreateFromPointsD3DXSphereBoundProbeBoundingSphere::Intersects(XMVECTOR, XMVECTOR, float&)D3DXIntersectTriFunctionTriangleTests::IntersectsD3DXFloat32To16ArrayXMConvertFloatToHalfStreamD3DXFloat16To32ArrayXMConvertHalfToFloatStreamD3DXVec2LengthXMVector2Length or XMVector2LengthEstD3DXVec2LengthSqXMVector2LengthSqD3DXVec2DotXMVector2DotD3DXVec2CCWXMVector2CrossD3DXVec2AddXMVectorAddD3DXVec2SubtractXMVectorSubtractD3DXVec2MinimizeXMVectorMinD3DXVec2MaximizeXMVectorMaxD3DXVec2ScaleXMVectorScaleD3DXVec2LerpXMVectorLerp or XMVectorLerpVD3DXVec2NormalizeXMVector2Normalize or XMVector2NormalizeEstD3DXVec2HermiteXMVectorHermite or XMVectorHermiteVD3DXVec2CatmullRomXMVectorCatmullRom or XMVectorCatmullRomVD3DXVec2BaryCentricXMVectorBaryCentric or XMVectorBaryCentricVD3DXVec2TransformXMVector2TransformD3DXVec2TransformCoordXMVector2TransformCoordD3DXVec2TransformNormalXMVector2TransformNormalD3DXVec2TransformArrayXMVector2TransformStreamD3DXVec2TransformCoordArrayXMVector2TransformCoordStreamD3DXVec2TransformNormalArrayXMVector2TransformNormalStreamD3DXVec3LengthXMVector3Length or XMVector3LengthEstD3DXVec3LengthSqXMVector3LengthSqD3DXVec3DotXMVector3DotD3DXVec3CrossXMVector3CrossD3DXVec3AddXMVectorAddD3DXVec3SubtractXMVectorSubtractD3DXVec3MinimizeXMVectorMinD3DXVec3MaximizeXMVectorMaxD3DXVec3ScaleXMVectorScaleD3DXVec3LerpXMVectorLerp or XMVectorLerpVD3DXVec3NormalizeXMVector3Normalize or XMVector3NormalizeEstD3DXVec3HermiteXMVectorHermite or XMVectorHermiteVD3DXVec3CatmullRomXMVectorCatmullRom or XMVectorCatmullRomVD3DXVec3BaryCentricXMVectorBaryCentric or XMVectorBaryCentricVD3DXVec3TransformXMVector3TransformD3DXVec3TransformCoordXMVector3TransformCoordD3DXVec3TransformNormalXMVector3TransformNormalD3DXVec3TransformArrayXMVector3TransformStreamD3DXVec3TransformCoordArrayXMVector3TransformCoordStreamD3DXVec3TransformNormalArrayXMVector3TransformNormalStreamD3DXVec3ProjectXMVector3ProjectD3DXVec3UnprojectXMVector3UnprojectD3DXVec3ProjectArrayXMVector3ProjectStreamD3DXVec3UnprojectArrayXMVector3UnprojectStreamD3DXVec4LengthXMVector4Length or XMVector4LengthEstD3DXVec4LengthSqXMVector4LengthSqD3DXVec4DotXMVector4DotD3DXVec4AddXMVectorAddD3DXVec4SubtractXMVectorSubtractD3DXVec4MinimizeXMVectorMinD3DXVec4MaximizeXMVectorMaxD3DXVec4ScaleXMVectorScaleD3DXVec4LerpXMVectorLerp or XMVectorLerpVD3DXVec4CrossXMVector4CrossD3DXVec4NormalizeXMVector4Normalize or XMVector4NormalizeEstD3DXVec4HermiteXMVectorHermite or XMVectorHermiteVD3DXVec4CatmullRomXMVectorCatmullRom or XMVectorCatmullRomVD3DXVec4BaryCentricXMVectorBaryCentric or XMVectorBaryCentricVD3DXVec4TransformXMVector4TransformD3DXVec4TransformArrayXMVector4TransformStreamD3DXMatrixIdentityXMMatrixIdentityD3DXMatrixDeterminantXMMatrixDeterminantD3DXMatrixDecomposeXMMatrixDecomposeD3DXMatrixTransposeXMMatrixTransposeD3DXMatrixMultiplyXMMatrixMultiplyD3DXMatrixMultiplyTransposeXMMatrixMultiplyTransposeD3DXMatrixInverseXMMatrixInverseD3DXMatrixScalingXMMatrixScalingD3DXMatrixTranslationXMMatrixTranslationD3DXMatrixRotationXXMMatrixRotationXD3DXMatrixRotationYXMMatrixRotationYD3DXMatrixRotationZXMMatrixRotationZD3DXMatrixRotationAxisXMMatrixRotationAxisD3DXMatrixRotationQuaternionXMMatrixRotationQuaternionD3DXMatrixRotationYawPitchRollXMMatrixRotationRollPitchYaw (Note the order of parameters is different: D3DXMatrixRotationYawPitchRoll takes yaw, pitch, roll, XMMatrixRotationRollPitchYaw takes pitch, yaw, roll)D3DXMatrixTransformationXMMatrixTransformationD3DXMatrixTransformation2DXMMatrixTransformation2DD3DXMatrixAffineTransformationXMMatrixAffineTransformationD3DXMatrixAffineTransformation2DXMMatrixAffineTransformation2DD3DXMatrixLookAtRHXMMatrixLookAtRHD3DXMatrixLookAtLHXMMatrixLookAtLHD3DXMatrixPerspectiveRHXMMatrixPerspectiveRHD3DXMatrixPerspectiveLHXMMatrixPerspectiveLHD3DXMatrixPerspectiveFovRHXMMatrixPerspectiveFovRHD3DXMatrixPerspectiveFovLHXMMatrixPerspectiveFovLHD3DXMatrixPerspectiveOffCenterRHXMMatrixPerspectiveOffCenterRHD3DXMatrixPerspectiveOffCenterLHXMMatrixPerspectiveOffCenterLHD3DXMatrixOrthoRHXMMatrixOrthographicRHD3DXMatrixOrthoLHXMMatrixOrthographicLHD3DXMatrixOrthoOffCenterRHXMMatrixOrthographicOffCenterRHD3DXMatrixOrthoOffCenterLHXMMatrixOrthographicOffCenterLHD3DXMatrixShadowXMMatrixShadowD3DXMatrixReflectXMMatrixReflectD3DXQuaternionLengthXMQuaternionLengthD3DXQuaternionLengthSqXMQuaternionLengthSqD3DXQuaternionDotXMQuaternionDotD3DXQuaternionIdentityXMQuaternionIdentityD3DXQuaternionIsIdentityXMQuaternionIsIdentityD3DXQuaternionConjugateXMQuaternionConjugateD3DXQuaternionToAxisAngleXMQuaternionToAxisAngleD3DXQuaternionRotationMatrixXMQuaternionRotationMatrixD3DXQuaternionRotationAxisXMQuaternionRotationAxisD3DXQuaternionRotationYawPitchRollXMQuaternionRotationRollPitchYaw (Note the order of parameters is different: D3DXQuaternionRotationYawPitchRoll takes yaw, pitch, roll, XMQuaternionRotationRollPitchYaw takes pitch, yaw, roll)D3DXQuaternionMultiplyXMQuaternionMultiplyD3DXQuaternionNormalizeXMQuaternionNormalize or XMQuaternionNormalizeEstD3DXQuaternionInverseXMQuaternionInverseD3DXQuaternionLnXMQuaternionLnD3DXQuaternionExpXMQuaternionExpD3DXQuaternionSlerpXMQuaternionSlerp or XMQuaternionSlerpVD3DXQuaternionSquadXMQuaternionSquad or XMQuaternionSquadVD3DXQuaternionSquadSetupXMQuaternionSquadSetupD3DXQuaternionBaryCentricXMQuaternionBaryCentric or XMQuaternionBaryCentricVD3DXPlaneDotXMPlaneDotD3DXPlaneDotCoordXMPlaneDotCoordD3DXPlaneDotNormalXMPlaneDotNormalD3DXPlaneScaleXMVectorScaleD3DXPlaneNormalizeXMPlaneNormalize or XMPlaneNormalizeEstD3DXPlaneIntersectLineXMPlaneIntersectLineD3DXPlaneFromPointNormalXMPlaneFromPointNormalD3DXPlaneFromPointsXMPlaneFromPointsD3DXPlaneTransformXMPlaneTransformD3DXPlaneTransformArrayXMPlaneTransformStreamD3DXColorNegativeXMColorNegativeD3DXColorAddXMVectorAddD3DXColorSubtractXMVectorSubtractD3DXColorScaleXMVectorScaleD3DXColorModulateXMColorModulateD3DXColorLerpXMVectorLerp or XMVectorLerpVD3DXColorAdjustSaturationXMColorAdjustSaturationD3DXColorAdjustContrastXMColorAdjustContrastD3DXFresnelTermXMFresnelTerm




Directx11 study notes 5-d3dxmath Library

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.