Skip to content

Quaternion

Chuck Walbourn edited this page Nov 3, 2015 · 25 revisions

A rotation represented as a four component vector modeled after the XNA Game Studio math library.

Header

#include <SimpleMath.h>

Initialization

using namespace DirectX::SimpleMath;

Quaternion q;                     // Creates the identity quaternion [0, 0, 0, 1]
Quaternion q(0, 0, 0, 1);         // Creates a quaternion [0, 0, 0, 1]
Quaternion q( Vector3(0,0,0), 1); // Creates a quaternion [0, 0, 0, 1]
Quaternion q( Vector4(0,0,0,1) ); // Creates a quaternion [0, 0, 0, 1]

float arr[4] = { 0, 0, 0, 1 };
Quaternion q(arr);                // Creates a quaternion [0, 0, 0, 1]

Fields

  • x component of the quaternion
  • y component of the quaternion
  • z component of the quaternion
  • w component of the quaternion

Methods

  • Comparison operators: == and !=
  • Assignment operators: =, +=, -=, *=, /=
  • Unary operators: +, -
  • Binary operators: +, -, *, /
  • Length
  • LengthSquared
  • Normalize
  • Conjugate*
  • Inverse
  • Dot

Statics

  • CreateFromAxisAngle
  • CreateFromYawPitchRoll
  • CreateFromRotationMatrix
  • Lerp
  • Slerp: Spherical linear interpolation
  • Concatenate

Constants

  • Identity: The identity quaternion [0, 0, 0, 1]

Remark

Quaternion can freely convert to and from a XMFLOAT4 and XMVECTOR

Further Reading

Quaternions and spatial rotation

For Use

  • Universal Windows Platform apps
  • Windows desktop apps
  • Windows 11
  • Windows 10
  • Windows 8.1
  • Xbox One

Architecture

  • x86
  • x64
  • ARM64

For Development

  • Visual Studio 2022
  • Visual Studio 2019 (16.11)
  • clang/LLVM v12 - v18
  • MinGW 12.2, 13.2
  • CMake 3.20

Related Projects

DirectX Tool Kit for DirectX 12

DirectXMesh

DirectXTex

DirectXMath

Win2D

Tools

Test Suite

Model Viewer

Content Exporter

DxCapsViewer

Clone this wiki locally