Skyscraper 2.0
XrMath.h File Reference
#include <openxr/openxr.h>
#include <DirectXMath.h>
#include <stdexcept>
#include <cmath>
Include dependency graph for XrMath.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  xr::math::NearFar
 
struct  xr::math::ViewProjection
 

Namespaces

namespace  xr
 The xr::DispatchTable struct contains all available PFN pointers to xr functions including those in all extensions. The application should call dispatchTable.Initialize() once creating a new XrInstance to initialize all function pointers. The application should reset the dispatch table by = {} when destroying the instance handle.
 
namespace  xr::math
 
namespace  xr::math::Pose
 
namespace  xr::math::Quaternion
 
namespace  xr::math::detail
 

Macros

#define DEFINE_CAST(X, Y)
 
#define DEFINE_CAST(X, Y)
 
#define VECTOR2F_OPERATOR(op)
 
#define VECTOR2F_OPERATOR(op)
 
#define VECTOR2F_OPERATOR(op)
 
#define VECTOR3F_OPERATOR(op)
 
#define VECTOR3F_OPERATOR(op)
 
#define VECTOR3F_OPERATOR(op)
 

Functions

constexpr XrPosef xr::math::Pose::Identity ()
 
constexpr XrPosef xr::math::Pose::Translation (const XrVector3f &translation)
 
XrPosef xr::math::Pose::LookAt (const XrVector3f &origin, const XrVector3f &forward, const XrVector3f &up)
 
XrPosef xr::math::Pose::Multiply (const XrPosef &a, const XrPosef &b)
 
XrPosef xr::math::Pose::Slerp (const XrPosef &a, const XrPosef &b, float alpha)
 
XrPosef xr::math::Pose::Invert (const XrPosef &pose)
 
constexpr bool xr::math::Pose::IsPoseValid (const XrSpaceLocation &location)
 
constexpr bool xr::math::Pose::IsPoseTracked (const XrSpaceLocation &location)
 
constexpr bool xr::math::Pose::IsPoseValid (const XrHandJointLocationEXT &jointLocation)
 
constexpr bool xr::math::Pose::IsPoseTracked (const XrHandJointLocationEXT &jointLocation)
 
constexpr bool xr::math::Pose::IsPoseValid (const XrViewState &viewState)
 
constexpr bool xr::math::Pose::IsPoseTracked (const XrViewState &viewState)
 
template<typename Quaternion , typename Vector3 >
XrPosef xr::math::Pose::MakePose (const Quaternion &orientation, const Vector3 &position)
 
constexpr XrQuaternionf xr::math::Quaternion::Identity ()
 
bool xr::math::Quaternion::IsNormalized (const XrQuaternionf &quaternion)
 
XrQuaternionf xr::math::Quaternion::RotationAxisAngle (const XrVector3f &axis, float angleInRadians)
 
XrQuaternionf xr::math::Quaternion::RotationRollPitchYaw (const XrVector3f &eulerAnglesInRadians)
 
XrQuaternionf xr::math::Quaternion::Slerp (const XrQuaternionf &a, const XrQuaternionf &b, float alpha)
 
template<typename X , typename Y >
constexpr const X & xr::math::cast (const Y &value)=delete
 
DirectX::XMVECTOR XM_CALLCONV xr::math::LoadXrVector2 (const XrVector2f &vector)
 
DirectX::XMVECTOR XM_CALLCONV xr::math::LoadXrVector3 (const XrVector3f &vector)
 
DirectX::XMVECTOR XM_CALLCONV xr::math::LoadXrVector4 (const XrVector4f &vector)
 
DirectX::XMVECTOR XM_CALLCONV xr::math::LoadXrQuaternion (const XrQuaternionf &quaternion)
 
DirectX::XMMATRIX XM_CALLCONV xr::math::LoadXrPose (const XrPosef &rigidTransform)
 
DirectX::XMMATRIX XM_CALLCONV xr::math::LoadInvertedXrPose (const XrPosef &rigidTransform)
 
DirectX::XMVECTOR XM_CALLCONV xr::math::LoadXrExtent (const XrExtent2Df &extend)
 
void XM_CALLCONV xr::math::StoreXrVector2 (XrVector2f *outVec, DirectX::FXMVECTOR inVec)
 
void XM_CALLCONV xr::math::StoreXrVector3 (XrVector3f *outVec, DirectX::FXMVECTOR inVec)
 
void XM_CALLCONV xr::math::StoreXrVector4 (XrVector4f *outVec, DirectX::FXMVECTOR inVec)
 
void XM_CALLCONV xr::math::StoreXrQuaternion (XrQuaternionf *outQuat, DirectX::FXMVECTOR inQuat)
 
bool XM_CALLCONV xr::math::StoreXrPose (XrPosef *out, DirectX::FXMMATRIX matrix)
 
void XM_CALLCONV xr::math::StoreXrExtent (XrExtent2Df *extend, DirectX::FXMVECTOR inVec)
 
DirectX::XMMATRIX xr::math::ComposeProjectionMatrix (const XrFovf &fov, const NearFar &nearFar)
 
NearFar xr::math::GetProjectionNearFar (const DirectX::XMFLOAT4X4 &projectionMatrix)
 
XrFovf xr::math::DecomposeProjectionMatrix (const DirectX::XMFLOAT4X4 &projectionMatrix)
 
template<typename X , typename Y >
constexpr const X & xr::math::detail::implement_math_cast (const Y &value)
 
template<typename X , typename Y >
constexpr X & xr::math::detail::implement_math_cast (Y &value)
 
 xr::math::DEFINE_CAST (XrVector2f, DirectX::XMFLOAT2)
 
 xr::math::DEFINE_CAST (DirectX::XMFLOAT2, XrVector2f)
 
 xr::math::DEFINE_CAST (XrVector3f, DirectX::XMFLOAT3)
 
 xr::math::DEFINE_CAST (DirectX::XMFLOAT3, XrVector3f)
 
 xr::math::DEFINE_CAST (XrVector4f, DirectX::XMFLOAT4)
 
 xr::math::DEFINE_CAST (DirectX::XMFLOAT4, XrVector4f)
 
 xr::math::DEFINE_CAST (XrQuaternionf, DirectX::XMFLOAT4)
 
 xr::math::DEFINE_CAST (DirectX::XMFLOAT4, XrQuaternionf)
 
 xr::math::DEFINE_CAST (XrExtent2Di, DirectX::XMINT2)
 
 xr::math::DEFINE_CAST (DirectX::XMINT2, XrExtent2Di)
 
 xr::math::DEFINE_CAST (XrExtent2Df, DirectX::XMFLOAT2)
 
 xr::math::DEFINE_CAST (DirectX::XMFLOAT2, XrExtent2Df)
 
 xr::math::DEFINE_CAST (XrColor4f, DirectX::XMFLOAT4)
 
 xr::math::DEFINE_CAST (DirectX::XMFLOAT4, XrColor4f)
 
 xr::math::VECTOR2F_OPERATOR (+)
 
 xr::math::VECTOR2F_OPERATOR (-)
 
VECTOR2F_OPERATOR * xr::math::VECTOR2F_OPERATOR (/);#define VECTOR2F_OPERATOR(op) \ \ \ VECTOR2F_OPERATOR(+
 
 xr::math::VECTOR3F_OPERATOR (-)
 
VECTOR3F_OPERATOR * xr::math::VECTOR3F_OPERATOR (/);#define VECTOR3F_OPERATOR(op) \ \ \ VECTOR3F_OPERATOR(+
 
constexpr bool xr::math::Pose::IsPoseValid (XrSpaceLocationFlags locationFlags)
 
constexpr bool xr::math::Pose::IsPoseTracked (XrSpaceLocationFlags locationFlags)
 
float xr::math::Quaternion::Length (const XrQuaternionf &quaternion)
 
XrPosef xr::math::operator* (const XrPosef &a, const XrPosef &b)
 
float xr::math::Dot (const XrVector3f &a, const XrVector3f &b)
 
float xr::math::Length (const XrVector3f &v)
 
XrVector3f xr::math::Normalize (const XrVector3f &a)
 
bool xr::math::IsInfiniteNearPlaneProjectionMatrix (const DirectX::XMFLOAT4X4 &p)
 
bool xr::math::IsInfiniteFarPlaneProjectionMatrix (const DirectX::XMFLOAT4X4 &p)
 
void xr::math::ValidateProjectionMatrix (const DirectX::XMFLOAT4X4 &p)
 
template<uint32_t alignment>
constexpr uint32_t xr::math::AlignTo (uint32_t n)
 
constexpr uint32_t xr::math::DivideRoundingUp (uint32_t x, uint32_t y)
 

Variables

constexpr float xr::math::QuaternionEpsilon = 0.01f
 
constexpr float xr::math::OneOverFloatEpsilon = 1.0f / std::numeric_limits<float>::epsilon()
 

Macro Definition Documentation

◆ DEFINE_CAST [1/2]

#define DEFINE_CAST ( X,
Y )
Value:
template <> \
constexpr const X& cast<X, Y>(const Y& value) { \
return detail::implement_math_cast<X>(value); \
}

Definition at line 109 of file XrMath.h.

◆ DEFINE_CAST [2/2]

#define DEFINE_CAST ( X,
Y )
Value:
constexpr const X& cast(const Y& value) { \
return detail::implement_math_cast<X>(value); \
} \
constexpr X& cast(Y& value) { \
return detail::implement_math_cast<X>(value); \
}

Definition at line 109 of file XrMath.h.

◆ VECTOR2F_OPERATOR [1/3]

#define VECTOR2F_OPERATOR ( op)
Value:
constexpr XrVector2f operator op(const XrVector2f& a, const XrVector2f& b) { \
return XrVector2f{a.x op b.x, a.y op b.y}; \
}

Definition at line 175 of file XrMath.h.

◆ VECTOR2F_OPERATOR [2/3]

#define VECTOR2F_OPERATOR ( op)
Value:
constexpr XrVector2f operator op(const XrVector2f& a, float s) { \
return XrVector2f{a.x op s, a.y op s}; \
}

Definition at line 175 of file XrMath.h.

◆ VECTOR2F_OPERATOR [3/3]

#define VECTOR2F_OPERATOR ( op)
Value:
constexpr XrVector2f operator op(float s, const XrVector2f& a) { \
return XrVector2f{s op a.x, s op a.y}; \
}

Definition at line 175 of file XrMath.h.

◆ VECTOR3F_OPERATOR [1/3]

#define VECTOR3F_OPERATOR ( op)
Value:
constexpr XrVector3f operator op(const XrVector3f& a, const XrVector3f& b) { \
return XrVector3f{a.x op b.x, a.y op b.y, a.z op b.z}; \
}

◆ VECTOR3F_OPERATOR [2/3]

#define VECTOR3F_OPERATOR ( op)
Value:
constexpr XrVector3f operator op(const XrVector3f& a, float s) { \
return XrVector3f{a.x op s, a.y op s, a.z op s}; \
}

◆ VECTOR3F_OPERATOR [3/3]

#define VECTOR3F_OPERATOR ( op)
Value:
constexpr XrVector3f operator op(float s, const XrVector3f& a) { \
return XrVector3f{s op a.x, s op a.y, s op a.z}; \
}