XMMATRIX structure (directxmath.h)

Describes a 4*4 matrix aligned on a 16-byte boundary that maps to four hardware vector registers.

DirectXMath uses row-major matrices, row vectors, and pre-multiplication. Handedness is determined by which function version is used (RH vs. LH).

For a list of additional functionality such as constructors and operators that are available using XMMATRIX when you are programming in C++, see XMMATRIX Extensions.

Note  See DirectXMath Library Type Equivalences for information about equivalent D3DDECLTYPE, D3DFORMAT, and DXGI_FORMAT objects.
 

Syntax

struct XMMATRIX {
  union {
    XMVECTOR r[4];
    struct {
      float _11;
      float _12;
      float _13;
      float _14;
      float _21;
      float _22;
      float _23;
      float _24;
      float _31;
      float _32;
      float _33;
      float _34;
      float _41;
      float _42;
      float _43;
      float _44;
    };
    float    m[4][4];
  };
  XMVECTOR              r[4];
  void                  XMMATRIX();
  void                  XMMATRIX(
    const XMMATRIX & unnamedParam1
  );
  XMMATRIX &            operator=(
    const XMMATRIX & M
  ) noexcept;
  XMMATRIX &            operator=(
    const XMMATRIX & unnamedParam1
  );
  void                  XMMATRIX(
    XMMATRIX && unnamedParam1
  );
  XMMATRIX &            operator=(
    XMMATRIX && unnamedParam1
  );
  void                  XMMATRIX(
    FXMVECTOR R0,
    FXMVECTOR R1,
    FXMVECTOR R2,
    CXMVECTOR R3
  ) noexcept;
  void                  XMMATRIX(
    float m00,
    float m01,
    float m02,
    float m03,
    float m10,
    float m11,
    float m12,
    float m13,
    float m20,
    float m21,
    float m22,
    float m23,
    float m30,
    float m31,
    float m32,
    float m33
  ) noexcept;
  void                  XMMATRIX(
    const float *pArray
  ) noexcept;
  float                 operator()(
    size_t Row,
    size_t Column
  ) noexcept;
  float &               operator()(
    size_t Row,
    size_t Column
  ) noexcept;
  XMMATRIX              operator+() noexcept;
  XMMATRIX              operator-() noexcept;
  XMMATRIX &XM_CALLCONV operator+=(
    FXMMATRIX M
  ) noexcept;
  XMMATRIX &XM_CALLCONV operator-=(
    FXMMATRIX M
  ) noexcept;
  XMMATRIX &XM_CALLCONV operator*=(
    FXMMATRIX M
  ) noexcept;
  XMMATRIX &            operator*=(
    float S
  ) noexcept;
  XMMATRIX &            operator/=(
    float S
  ) noexcept;
  XMMATRIX XM_CALLCONV  operator+(
    FXMMATRIX M
  ) noexcept;
  XMMATRIX XM_CALLCONV  operator-(
    FXMMATRIX M
  ) noexcept;
  XMMATRIX XM_CALLCONV  operator*(
    FXMMATRIX M
  ) noexcept;
  XMMATRIX              operator*(
    float S
  ) noexcept;
  XMMATRIX              operator/(
    float S
  ) noexcept;
};

Members

r[4]

Array of four vectors, representing the rows of the matrix.

_11

_12

_13

_14

_21

_22

_23

_24

_31

_32

_33

_34

_41

_42

_43

_44

m[4]

void XMMATRIX()

Default constructor for XMMATRIX.

Default constructor for XMMATRIX.

Note  This constructor is only available when developing with C++.
 

void XMMATRIX( const XMMATRIX & unnamedParam1)

A constructor for XMMATRIX.

A constructor for XMMATRIX.

Note  This constructor is only available when developing with C++.

XMMATRIX & operator=( const XMMATRIX & M) noexcept

Assigns the matrix data of one instance of XMMATRIX to the current instance of XMMATRIX and returns a reference to the current instance.

This operator assigns the matrix data of one instance of XMMATRIX to the current instance of XMMATRIX and returns a reference to the current instance.

Note  This operator is only available when developing with C++.
 

XMMATRIX & operator=( const XMMATRIX & unnamedParam1)

void XMMATRIX( XMMATRIX && unnamedParam1)

XMMATRIX & operator=( XMMATRIX && unnamedParam1)

void XMMATRIX( FXMVECTOR R0, FXMVECTOR R1, FXMVECTOR R2, CXMVECTOR R3) noexcept

Initializes a new instance of the XMMATRIX structure from four instances of XMVECTOR.

Initializes a new instance of the XMMATRIX structure from four instances of XMVECTOR Data Type.

Note  This constructor is only available when developing with C++.

void XMMATRIX( float m00, float m01, float m02, float m03, float m10, float m11, float m12, float m13, float m20, float m21, float m22, float m23, float m30, float m31, float m32, float m33) noexcept

Initializes a new instance of the XMMATRIX structure from sixteen scalar float values.

Initializes a new instance of the XMMATRIX structure from sixteen scalar float values.

Note  This constructor is only available when developing with C++.
 

void XMMATRIX( const float *pArray) noexcept

Initializes a new instance of the XMMATRIX structure from a sixteen element float array.

Initializes a new instance of the XMMATRIX structure from a sixteen element float array.

Note  This constructor is only available when developing with C++.
 

float operator()( size_t Row, size_t Column) noexcept

float & operator()( size_t Row, size_t Column) noexcept

Returns a reference to a matrix element of an instance XMMATRIX as specified by row and column arguments.

This operator returns a reference to a matrix element of an instance XMMATRIX as specified by row and column arguments.

Note  This operator is only available when developing with C++.
 

XMMATRIX operator+() noexcept

XMMATRIX operator-() noexcept

XMMATRIX &XM_CALLCONV operator+=( FXMMATRIX M) noexcept

XMMATRIX &XM_CALLCONV operator-=( FXMMATRIX M) noexcept

XMMATRIX &XM_CALLCONV operator*=( FXMMATRIX M) noexcept

Performs a matrix multiplication of the current instance of XMMATRIX by another instance of XMMATRIX and returns a reference to the current instance, which has been updated.

This operator performs a matrix multiplication of the current instance of XMMATRIX by another instance of XMMATRIX and returns a reference to the current instance, which has been updated.

Note  This operator is only available when developing with C++.
 

XMMATRIX & operator*=( float S) noexcept

XMMATRIX & operator/=( float S) noexcept

XMMATRIX XM_CALLCONV operator+( FXMMATRIX M) noexcept

XMMATRIX XM_CALLCONV operator-( FXMMATRIX M) noexcept

XMMATRIX XM_CALLCONV operator*( FXMMATRIX M) noexcept

Performs a matrix multiplication of the current instance of XMMATRIX by another instance of XMMATRIX.

This operator performs a matrix multiplication of the current instance of XMMATRIX by another instance of XMMATRIX.

Note  This operator is only available when developing with C++.
 

XMMATRIX operator*( float S) noexcept

XMMATRIX operator/( float S) noexcept

Remarks

In the DirectXMath.h header file, the system uses an alias to the XMMATRIX object, specifically CXMMATRIX. The header uses the alias to comply with the optimal in-line calling conventions of different compilers. For most projects using DirectXMath it is sufficient to simply treat this as an exact alias to XMMATRIX.

Effectively:


typedef const XMMATRIX CXMMATRIX;

For projects that need detailed information about how different platform's calling conventions are handled, see Library Internals.

XMMATRIX is row-major and all DirectXMath functions that accept an XMMATRIX as a parameter expect data to be organized as row-major.

Data in an XMMATRIX has the following layout.


_11 _12 _13 _14
_21 _22 _23 _24
_31 _32 _33 _34
_41 _42 _43 _44

DirectXMath defines XMMATRIX as a fully opaque type. To access individual elements of XMMATRIX, use equivalent types such as XMFLOAT4 for a given row or XMFLOAT4X4 for the whole matrix.

Note  XNAMath 2.x defines XMMATRIX as a union with _11 to _44 members and an m array member. When you use these members of the union, poor performance results. DirectXMath.h still defines these XMMATRIX union members for when you build an app with _XM_NO_INTRINSICS_. XNAMath version 2.05 provides an opt-in XM_STRICT_XMMATRIX to enforce the DirectXMath behavior.
 
Namespace: Use DirectX

Platform Requirements

Microsoft Visual Studio 2010 or Microsoft Visual Studio 2012 with the Windows SDK for Windows 8. Supported for Win32 desktop apps, Windows Store apps, and Windows Phone 8 apps.

Requirements

Requirement Value
Header directxmath.h

See also

DirectXMath Library Structures

XMFLOAT4X4

XMMATRIX Extensions