-
Notifications
You must be signed in to change notification settings - Fork 515
Matrix
Chuck Walbourn edited this page Nov 3, 2015
·
18 revisions
A four by four row-major matrix modeled after the XNA Game Studio math library.
#include <SimpleMath.h>
using namespace DirectX::SimpleMath;
Matrix m; // Creates an identity matrix
Matrix m(1, 2, 3, 4,
5, 6, 7, 8,
9, 10, 11, 12,
13, 14, 15, 16); // Creates a matrix [1 2 3 4
// | 5 6 7 8
// | 9 10 11 12
// | 13 14 15 16 ]
Matrix m( Vector3(1,2,3),
Vector3(4,5,6),
Vector(7,8,9) ); // Creates a matrix [1 2 3 0
// | 4 5 6 0
// | 7 8 9 0
// | 0 0 0 1 ]
Matrix m( Vector4(1, 2, 3, 4),
Vector4(5, 6, 7, 8),
Vector4(9, 10, 11, 12),
Vector4(13, 14, 15, 16) ); // Creates a matrix [1 2 3 4
// | 5 6 7 8
// | 9 10 11 12
// | 13 14 15 16 ]
float arr[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 };
Matrix m( arr ); // Creates a matrix [1 2 3 0
// | 4 5 6 0
// | 7 8 9 0
// | 0 0 0 1 ]
- _11, _12, _13, _14: First row of matrix
- _21, _22, _23, _24: Second row of matrix
- _31, _32, _33, _34: Third row of matrix
- _41, _42, _43, _44: Fourth row of matrix
- Up: The up direction vector from the matrix
- Down: The down direction vector from the matrix
- Right: The right direction vector from the matrix
- Left: The left direction vector from the matrix
- Forward: The forward direction vector in right-handed (RH) coordinates from the matrix
- Backward: The backward direction vector in right-handed (RH) coordinates from the matrix
- Translation: Returns the translation in the matrix
- Comparison operators:
==
and!=
- Assignment operators:
=
,+=
,-=
,*=
,/=
- Unary operators:
+
,-
- Binary operators:
+
,-
,*
,/
- Decompose
- Transpose
- Invert
- Determinant
- CreateBillboard
- CreateConstrainedBillboard
- CreateTranslation
- CreateScale
- CreateRotationX
- CreateRotationY
- CreateRotationZ
- CreateFromAxisAngle
- CreatePerspectiveFieldOfView
- CreatePerspective
- CreatePerspectiveOffCenter
- CreateOrthographic
- CreateOrthographicOffCenter
- CreateLookAt
- CreateWorld
- CreateFromQuaternion
- CreateFromYawPitchRoll
- CreateShadow
- CreateReflection
- Lerp
- Transform
- Identity: An identity matrix
Matrix can freely convert to and from a XMFLOAT4X4
and XMMATRIX
.
You can copy or assign a Matrix from a XMFLOAT3X3
or XMFLOAT4X3
.
All content and source code for this package are subject to the terms of the MIT License.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact [email protected] with any additional questions or comments.
- Universal Windows Platform apps
- Windows desktop apps
- Windows 11
- Windows 10
- Windows 8.1
- Xbox One
- x86
- x64
- ARM64
- Visual Studio 2022
- Visual Studio 2019 (16.11)
- clang/LLVM v12 - v18
- MinGW 12.2, 13.2
- CMake 3.20