4 #include <DirectXMath.h> 7 #include <Utils\DebugUtils.h> 19 static float RandomFloatInInverval(
const float bottomValue,
20 const float topValue) noexcept
22 BRE_ASSERT(bottomValue < topValue);
23 const float randomBetweenZeroAndOne =
static_cast<float>(rand()) / static_cast<float>(RAND_MAX);
24 return bottomValue + randomBetweenZeroAndOne * (topValue - bottomValue);
27 static int RandomIntegerInInterval(
const int32_t a,
28 const int32_t b) noexcept
30 return a + rand() % ((b - a) + 1);
34 static T Min(
const T& a,
41 static T Max(
const T& a,
48 static T Lerp(
const T& a,
50 const float t) noexcept
52 return a + (b - a) * t;
56 static T Clamp(
const T& x,
58 const T& high) noexcept
60 return x < low ? low : (x > high ? high : x);
63 static DirectX::XMMATRIX GetTransposeMatrix(
const DirectX::XMFLOAT4X4& matrix) noexcept
65 const DirectX::XMMATRIX xmMatrix = XMLoadFloat4x4(&matrix);
66 return DirectX::XMMatrixTranspose(xmMatrix);
69 static void StoreTransposeMatrix(
const DirectX::XMFLOAT4X4& sourceMatrix,
70 DirectX::XMFLOAT4X4& destinationMatrix) noexcept
72 const DirectX::XMMATRIX xmMatrix = GetTransposeMatrix(sourceMatrix);
73 DirectX::XMStoreFloat4x4(&destinationMatrix, xmMatrix);
76 static DirectX::XMMATRIX GetInverseMatrix(
const DirectX::XMFLOAT4X4& matrix) noexcept
78 const DirectX::XMMATRIX xmMatrix = XMLoadFloat4x4(&matrix);
79 return DirectX::XMMatrixInverse(
nullptr, xmMatrix);
82 static void StoreInverseMatrix(
const DirectX::XMFLOAT4X4& sourceMatrix,
83 DirectX::XMFLOAT4X4& destinationMatrix) noexcept
85 const DirectX::XMMATRIX xmMatrix = GetInverseMatrix(sourceMatrix);
86 DirectX::XMStoreFloat4x4(&destinationMatrix, xmMatrix);
89 static DirectX::XMMATRIX GetInverseTransposeMatrix(
const DirectX::XMFLOAT4X4& matrix) noexcept
91 const DirectX::XMMATRIX xmInverseMatrix = GetInverseMatrix(matrix);
92 DirectX::XMFLOAT4X4 inverseMatrix;
93 DirectX::XMStoreFloat4x4(&inverseMatrix, xmInverseMatrix);
94 return GetTransposeMatrix(inverseMatrix);
97 static void StoreInverseTransposeMatrix(
const DirectX::XMFLOAT4X4& sourceMatrix,
98 DirectX::XMFLOAT4X4& destinationMatrix) noexcept
100 const DirectX::XMMATRIX xmMatrix = GetInverseTransposeMatrix(sourceMatrix);
101 DirectX::XMStoreFloat4x4(&destinationMatrix, xmMatrix);
104 static void ComputeMatrix(DirectX::XMFLOAT4X4& m,
108 const float sx = 1.0f,
109 const float sy = 1.0f,
110 const float sz = 1.0f,
111 const float rx = 0.0f,
112 const float ry = 0.0f,
113 const float rz = 0.0f) noexcept;
115 static DirectX::XMFLOAT4X4 GetIdentity4x4Matrix() noexcept
117 DirectX::XMFLOAT4X4 identityMatrix(
118 1.0f, 0.0f, 0.0f, 0.0f,
119 0.0f, 1.0f, 0.0f, 0.0f,
120 0.0f, 0.0f, 1.0f, 0.0f,
121 0.0f, 0.0f, 0.0f, 1.0f);
123 return identityMatrix;
126 static const float Infinity;
127 static const float Pi;
Definition: MathUtils.h:10