#include "Foundation/Math/MathOperations.h"\r
\r
//----------------------------------------------------------------------------------------\r
-struct Vector2\r
+struct Vec2\r
{\r
float x;\r
float y;\r
\r
- slInline explicit Vector2() {}\r
- slInline explicit Vector2(const float xy) {x = xy; y = xy;}\r
- slInline explicit Vector2(const float ix, const float iy) {x = ix; y = iy;}\r
+ slInline explicit Vec2() {}\r
+ slInline explicit Vec2(const float xy) {x = xy; y = xy;}\r
+ slInline explicit Vec2(const float ix, const float iy) {x = ix; y = iy;}\r
\r
- slInline Vector2(const Vector2& v) {x = v.x; y = v.y;} // copy constructor\r
+ slInline Vec2(const Vec2& v) {x = v.x; y = v.y;} // copy constructor\r
\r
slInline float* AsFloatArray() {return &x;}\r
slInline const float* AsFloatArray() const {return &x;}\r
\r
\r
//----------------------------------------------------------------------------------------\r
-struct Vector3\r
+struct Vec3\r
{\r
float x;\r
float y;\r
float z;\r
\r
- slInline explicit Vector3() {}\r
- slInline explicit Vector3(const float xyz) {x = xyz; y = xyz; z = xyz;}\r
- slInline explicit Vector3(const float ix, const float iy, const float iz) {x = ix; y = iy; z = iz;}\r
+ slInline explicit Vec3() {}\r
+ slInline explicit Vec3(const float xyz) {x = xyz; y = xyz; z = xyz;}\r
+ slInline explicit Vec3(const float ix, const float iy, const float iz) {x = ix; y = iy; z = iz;}\r
\r
- slInline explicit Vector3(const Vector2& v, const float iz) {x = v.x; y = v.y; z = iz;}\r
+ slInline explicit Vec3(const Vec2& v, const float iz) {x = v.x; y = v.y; z = iz;}\r
\r
- slInline Vector3(const Vector3& v) {x = v.x; y = v.y; z = v.z;} // copy constructor\r
+ slInline Vec3(const Vec3& v) {x = v.x; y = v.y; z = v.z;} // copy constructor\r
\r
- slInline Vector2 AsVector2() const {return Vector2(x, y);}\r
+ slInline Vec2 AsVec2() const {return Vec2(x, y);}\r
\r
slInline float* AsFloatArray() {return &x;}\r
slInline const float* AsFloatArray() const {return &x;}\r
\r
\r
//----------------------------------------------------------------------------------------\r
-struct Vector4\r
+struct Vec4\r
{\r
float x;\r
float y;\r
float z;\r
float w;\r
\r
- slInline explicit Vector4() {}\r
- slInline explicit Vector4(const float xyzw) {x = xyzw; y = xyzw; z = xyzw; w = xyzw;}\r
- slInline explicit Vector4(const float xyz, const float iw) {x = xyz; y = xyz; z = xyz; w = iw;}\r
- slInline explicit Vector4(const float ix, const float iy, const float iz, const float iw) {x = ix; y = iy; z = iz; w = iw;}\r
+ slInline explicit Vec4() {}\r
+ slInline explicit Vec4(const float xyzw) {x = xyzw; y = xyzw; z = xyzw; w = xyzw;}\r
+ slInline explicit Vec4(const float xyz, const float iw) {x = xyz; y = xyz; z = xyz; w = iw;}\r
+ slInline explicit Vec4(const float ix, const float iy, const float iz, const float iw) {x = ix; y = iy; z = iz; w = iw;}\r
\r
- slInline explicit Vector4(const Vector2& u, const Vector2& v) {x = u.x; y = u.y; z = v.x; w = v.y;}\r
- slInline explicit Vector4(const Vector2& v, const float iz, const float iw) {x = v.x; y = v.y; z = iz; w = iw;}\r
+ slInline explicit Vec4(const Vec2& u, const Vec2& v) {x = u.x; y = u.y; z = v.x; w = v.y;}\r
+ slInline explicit Vec4(const Vec2& v, const float iz, const float iw) {x = v.x; y = v.y; z = iz; w = iw;}\r
\r
- slInline explicit Vector4(const Vector3& v, const float iw) {x = v.x; y = v.y; z = v.z; w = iw;}\r
+ slInline explicit Vec4(const Vec3& v, const float iw) {x = v.x; y = v.y; z = v.z; w = iw;}\r
\r
- slInline Vector4(const Vector4& v) {x = v.x; y = v.y; z = v.z; w = v.w;} // copy constructor\r
+ slInline Vec4(const Vec4& v) {x = v.x; y = v.y; z = v.z; w = v.w;} // copy constructor\r
\r
- slInline Vector2 AsVector2() const {return Vector2(x, y);}\r
- slInline Vector3 AsVector3() const {return Vector3(x, y, z);}\r
+ slInline Vec2 AsVec2() const {return Vec2(x, y);}\r
+ slInline Vec3 AsVec3() const {return Vec3(x, y, z);}\r
\r
slInline float* AsFloatArray() {return &x;}\r
slInline const float* AsFloatArray() const {return &x;}\r
float s;\r
\r
slInline explicit Quaternion() {}\r
- explicit Quaternion(const float angle, const Vector3& normalized_axis);\r
+ explicit Quaternion(const float angle, const Vec3& normalized_axis);\r
explicit Quaternion(const float angle, const float x, const float y, const float z);\r
\r
slInline Quaternion(const Quaternion& q) {i = q.i; j = q.j; k = q.k; s = q.s;}\r
\r
- Vector4 AsVector4();\r
+ Vec4 AsVec4();\r
slInline float* AsFloatArray() {return &i;}\r
\r
- Vector3 GetImaginary();\r
+ Vec3 GetImaginary();\r
slInline float GetReal() {return s;}\r
};\r
\r
-slInline Quaternion::Quaternion(const float angle, const Vector3& normalized_axis)\r
+slInline Quaternion::Quaternion(const float angle, const Vec3& normalized_axis)\r
{\r
- Assert( EpsilonEquals(LengthVector3(normalized_axis), 1.0f, kEpsilon) );\r
+ Assert( EpsilonEquals(normalized_axis.x * normalized_axis.x + normalized_axis.y * normalized_axis.y + normalized_axis.z * normalized_axis.z, 1.0f, kSqrtEpsilon) );\r
float half_angle = angle * 0.5f;\r
- float sin_half_angle = Sinf(half_angle);\r
+ float sin_half_angle = (float)Sinf(half_angle);\r
i = normalized_axis.x * sin_half_angle;\r
j = normalized_axis.y * sin_half_angle;\r
k = normalized_axis.z * sin_half_angle;\r
- s = Cosf(half_angle);\r
+ s = (float)Cosf(half_angle);\r
}\r
\r
slInline Quaternion::Quaternion(const float angle, const float x, const float y, const float z)\r
{\r
Assert( EpsilonEquals(x * x + y * y + z * z, 1.0f, kSqrtEpsilon) );\r
float half_angle = angle * 0.5f;\r
- float sin_half_angle = Sinf(half_angle);\r
+ float sin_half_angle = (float)Sinf(half_angle);\r
i = x * sin_half_angle;\r
j = y * sin_half_angle;\r
k = z * sin_half_angle;\r
- s = Cosf(half_angle);\r
+ s = (float)Cosf(half_angle);\r
}\r
\r
-Vector4 Quaternion::AsVector4()\r
+Vec4 Quaternion::AsVec4()\r
{\r
- Vector4 r;\r
+ Vec4 r;\r
r.x = i;\r
r.y = j;\r
r.z = k;\r
return r;\r
}\r
\r
-Vector3 Quaternion::GetImaginary()\r
+Vec3 Quaternion::GetImaginary()\r
{\r
- Vector3 r;\r
+ Vec3 r;\r
r.x = i;\r
r.y = j;\r
r.z = k;\r
\r
\r
//----------------------------------------------------------------------------------------\r
-struct Matrix3\r
+struct Mat3\r
{\r
- Vector3 v[3];\r
+ Vec3 v[3];\r
\r
- slInline explicit Matrix3() {}\r
- explicit Matrix3(const Vector3& v0, const Vector3& v1, const Vector3& v2);\r
- explicit Matrix3(const float v00, const float v01, const float v02,\r
- const float v10, const float v11, const float v12,\r
- const float v20, const float v21, const float v22);\r
- Matrix3(Matrix3& m); // copy constructor\r
+ slInline explicit Mat3() {}\r
+ explicit Mat3(const Vec3& v0, const Vec3& v1, const Vec3& v2);\r
+ explicit Mat3(const float v00, const float v01, const float v02,\r
+ const float v10, const float v11, const float v12,\r
+ const float v20, const float v21, const float v22);\r
+ Mat3(const Mat3& m); // copy constructor\r
\r
float* AsFloatArray() {return &v[0].x;}\r
};\r
\r
-slInline Matrix3::Matrix3(const Vector3& v0, const Vector3& v1, const Vector3& v2)\r
+slInline Mat3::Mat3(const Vec3& v0, const Vec3& v1, const Vec3& v2)\r
{\r
v[0] = v0;\r
v[1] = v1;\r
v[2] = v2;\r
}\r
\r
-slInline Matrix3::Matrix3(const float v00, const float v01, const float v02, const float v10, const float v11, const float v12, const float v20, const float v21, const float v22)\r
+slInline Mat3::Mat3(const float v00, const float v01, const float v02, const float v10, const float v11, const float v12, const float v20, const float v21, const float v22)\r
{\r
v[0].x = v00; v[0].y = v01; v[0].z = v02;\r
v[1].x = v10; v[1].y = v11; v[1].z = v12;\r
v[2].x = v20; v[2].y = v21; v[2].z = v22;\r
}\r
\r
-slInline Matrix3::Matrix3(Matrix3& m)\r
+slInline Mat3::Mat3(const Mat3& m)\r
{\r
v[0] = m.v[0];\r
v[1] = m.v[1];\r
\r
\r
//----------------------------------------------------------------------------------------\r
-struct Matrix4\r
+struct Mat4\r
{\r
- Vector4 v[4];\r
+ Vec4 v[4];\r
\r
- slInline explicit Matrix4() {}\r
- explicit Matrix4(const Vector4& v0, const Vector4& v1, const Vector4& v2, const Vector4& v3);\r
- explicit Matrix4(const float v00, const float v01, const float v02, const float v03,\r
- const float v10, const float v11, const float v12, const float v13,\r
- const float v20, const float v21, const float v22, const float v23,\r
- const float v30, const float v31, const float v32, const float v33);\r
- explicit Matrix4(const Matrix3& m);\r
- Matrix4(const Matrix4& m); // copy constructor\r
+ slInline explicit Mat4() {}\r
+ explicit Mat4(const Vec4& v0, const Vec4& v1, const Vec4& v2, const Vec4& v3);\r
+ explicit Mat4(const float v00, const float v01, const float v02, const float v03,\r
+ const float v10, const float v11, const float v12, const float v13,\r
+ const float v20, const float v21, const float v22, const float v23,\r
+ const float v30, const float v31, const float v32, const float v33);\r
+ explicit Mat4(const Mat3& m);\r
+ Mat4(const Mat4& m); // copy constructor\r
\r
float* AsFloatArray() {return &v[0].x;}\r
};\r
\r
-slInline Matrix4::Matrix4(const Vector4& v0, const Vector4& v1, const Vector4& v2, const Vector4& v3)\r
+slInline Mat4::Mat4(const Vec4& v0, const Vec4& v1, const Vec4& v2, const Vec4& v3)\r
{\r
v[0] = v0;\r
v[1] = v1;\r
v[3] = v3;\r
}\r
\r
-slInline Matrix4::Matrix4(const float v00, const float v01, const float v02, const float v03, const float v10, const float v11, const float v12, const float v13, const float v20, const float v21, const float v22, const float v23, const float v30, const float v31, const float v32, const float v33)\r
+slInline Mat4::Mat4(const float v00, const float v01, const float v02, const float v03, const float v10, const float v11, const float v12, const float v13, const float v20, const float v21, const float v22, const float v23, const float v30, const float v31, const float v32, const float v33)\r
{\r
v[0].x = v00; v[0].y = v01; v[0].z = v02; v[0].w = v03;\r
v[1].x = v10; v[1].y = v11; v[1].z = v12; v[1].w = v13;\r
v[3].x = v30; v[3].y = v31; v[3].z = v32; v[3].w = v33;\r
}\r
\r
-slInline Matrix4::Matrix4(const Matrix3& m)\r
+slInline Mat4::Mat4(const Mat3& m)\r
{\r
v[0].x = m.v[0].x; v[0].y = m.v[0].y; v[0].z = m.v[0].z; v[0].w = 0.0f;\r
v[1].x = m.v[1].x; v[1].y = m.v[1].y; v[1].z = m.v[1].z; v[1].w = 0.0f;\r
v[3].x = 0.0f; v[3].y = 0.0f; v[3].z = 0.0f; v[3].w = 1.0f;\r
}\r
\r
-slInline Matrix4::Matrix4(const Matrix4& m)\r
+slInline Mat4::Mat4(const Mat4& m)\r
{\r
v[0] = m.v[0];\r
v[1] = m.v[1];\r
\r
\r
//----------------------------------------------------------------------------------------\r
-typedef ALIGN(8) Vector2 AlignedVector2;\r
-typedef ALIGN(16) Vector3 AlignedVector3;\r
-typedef ALIGN(16) Vector4 AlignedVector4;\r
+typedef MEM_ALIGN(8) Vec2 AlignedVec2;\r
+typedef MEM_ALIGN(16) Vec3 AlignedVec3;\r
+typedef MEM_ALIGN(16) Vec4 AlignedVec4;\r
\r
-typedef ALIGN(64) Matrix3 AlignedMatrix3;\r
-typedef ALIGN(64) Matrix4 AlignedMatrix4;\r
+typedef MEM_ALIGN(64) Mat3 AlignedMat3;\r
+typedef MEM_ALIGN(64) Mat4 AlignedMat4;\r
\r
\r
//----------------------------------------------------------------------------------------\r
// SIMD Structures\r
//----------------------------------------------------------------------------------------\r
-struct Vector2SOA\r
+struct Vec2SOA\r
{\r
uint32_t m_Count;\r
uint32_t m_MaxCount;\r
float* m_X;\r
float* m_Y;\r
\r
- slInline explicit Vector2SOA() {m_Count = 0; m_MaxCount = 0; m_X = NULL; m_Y = NULL;}\r
- bool InitVector2SOA(float* buffer, uint32_t buffer_size);\r
+ slInline explicit Vec2SOA() {m_Count = 0; m_MaxCount = 0; m_X = NULL; m_Y = NULL;}\r
+ bool InitVec2SOA(float* buffer, uint32_t buffer_size);\r
\r
- void GetVector2AtIndex(Vector2& v, uint32_t index) {Assert(index < m_Count); v.x = m_X[index]; v.y = m_Y[index];}\r
+ void GetVec2AtIndex(Vec2& v, uint32_t index) {Assert(index < m_Count); v.x = m_X[index]; v.y = m_Y[index];}\r
};\r
\r
-slInline bool Vector2SOA::InitVector2SOA(float* buffer, uint32_t max_count)\r
+slInline bool Vec2SOA::InitVec2SOA(float* buffer, uint32_t max_count)\r
{\r
m_Count = 0;\r
\r
\r
\r
//----------------------------------------------------------------------------------------\r
-struct Vector3SOA : public Vector2SOA\r
+struct Vec3SOA : public Vec2SOA\r
{\r
float* m_Z;\r
\r
- slInline explicit Vector3SOA() {m_Count = 0; m_MaxCount = 0; m_X = NULL; m_Y = NULL; m_Z = NULL;}\r
- bool InitVector3SOA(float* buffer, uint32_t buffer_size);\r
+ slInline explicit Vec3SOA() {m_Count = 0; m_MaxCount = 0; m_X = NULL; m_Y = NULL; m_Z = NULL;}\r
+ bool InitVec3SOA(float* buffer, uint32_t buffer_size);\r
\r
- void GetVector3AtIndex(Vector3& v, uint32_t index) {Assert(index < m_Count); v.x = m_X[index]; v.y = m_Y[index]; v.z = m_Z[index];}\r
+ void GetVec3AtIndex(Vec3& v, uint32_t index) {Assert(index < m_Count); v.x = m_X[index]; v.y = m_Y[index]; v.z = m_Z[index];}\r
};\r
\r
-slInline bool Vector3SOA::InitVector3SOA(float* buffer, uint32_t max_count)\r
+slInline bool Vec3SOA::InitVec3SOA(float* buffer, uint32_t max_count)\r
{\r
m_Count = 0;\r
\r
\r
\r
//----------------------------------------------------------------------------------------\r
-struct Vector4SOA : public Vector3SOA\r
+struct Vec4SOA : public Vec3SOA\r
{\r
float* m_W;\r
\r
- slInline explicit Vector4SOA() {m_Count = 0; m_MaxCount = 0; m_X = NULL; m_Y = NULL; m_Z = NULL; m_W = NULL;}\r
- bool InitVector4SOA(float* buffer, uint32_t buffer_size);\r
+ slInline explicit Vec4SOA() {m_Count = 0; m_MaxCount = 0; m_X = NULL; m_Y = NULL; m_Z = NULL; m_W = NULL;}\r
+ bool InitVec4SOA(float* buffer, uint32_t buffer_size);\r
\r
- void GetVector4AtIndex(Vector4& v, uint32_t index) {Assert(index < m_Count); v.x = m_X[index]; v.y = m_Y[index]; v.z = m_Z[index]; v.w = m_W[index];}\r
+ void GetVec4AtIndex(Vec4& v, uint32_t index) {Assert(index < m_Count); v.x = m_X[index]; v.y = m_Y[index]; v.z = m_Z[index]; v.w = m_W[index];}\r
};\r
\r
-slInline bool Vector4SOA::InitVector4SOA(float* buffer, uint32_t max_count)\r
+slInline bool Vec4SOA::InitVec4SOA(float* buffer, uint32_t max_count)\r
{\r
m_Count = 0;\r
\r
//----------------------------------------------------------------------------------------\r
\r
//----------------------------------------------------------------------------------------\r
-// Matrix3\r
+// Mat3\r
//----------------------------------------------------------------------------------------\r
-void SetMatrix3(Matrix3& r, const Matrix3& a);\r
-void SetMatrix3(Matrix3& r, const Vector3& v0, const Vector3& v1, const Vector3& v2);\r
+void SetMat3(Mat3& r, const Mat3& a);\r
+void SetMat3(Mat3& r, const Vec3& v0, const Vec3& v1, const Vec3& v2);\r
\r
-void ScaleMatrix3(Matrix3& r, const float s, const Matrix3& a);\r
-Matrix3 ScaleMatrix3(const float s, const Matrix3& a);\r
+void ScaleMat3(Mat3& r, const float s, const Mat3& a);\r
+Mat3 ScaleMat3(const float s, const Mat3& a);\r
\r
-float DeterminantOfMatrix3(const Matrix3& a);\r
+float DeterminantOfMat3(const Mat3& a);\r
\r
-void TransposeMatrix3(Matrix3& r, const Matrix3& a);\r
-Matrix3 TransposeMatrix3(const Matrix3& a);\r
+void TransposeMat3(Mat3& r, const Mat3& a);\r
+Mat3 TransposeMat3(const Mat3& a);\r
\r
-void InvertAffineMatrix3(Matrix3& r, const Matrix3& a);\r
-Matrix3 InvertAffineMatrix3(const Matrix3& a);\r
+void InvertAffineMat3(Mat3& r, const Mat3& a);\r
+Mat3 InvertAffineMat3(const Mat3& a);\r
\r
-void InvertGeneralMatrix3(Matrix3& r, const Matrix3& a);\r
-Matrix3 InvertGeneralMatrix3(const Matrix3& a);\r
+void InvertGeneralMat3(Mat3& r, const Mat3& a);\r
+Mat3 InvertGeneralMat3(const Mat3& a);\r
\r
-void MulMatrix3(Matrix3& r, const Matrix3& a, const Matrix3& b);\r
-Matrix3 MulMatrix3(const Matrix3& a, const Matrix3& b);\r
+void MulMat3(Mat3& r, const Mat3& a, const Mat3& b);\r
+Mat3 MulMat3(const Mat3& a, const Mat3& b);\r
\r
-void MulMatrix3ByTransposedMatrix3(Matrix3& r, const Matrix3& a, const Matrix3& b);\r
-Matrix3 MulMatrix3ByTransposedMatrix3(const Matrix3& a, const Matrix3& b);\r
+void MulMat3ByTransposedMat3(Mat3& r, const Mat3& a, const Mat3& b);\r
+Mat3 MulMat3ByTransposedMat3(const Mat3& a, const Mat3& b);\r
\r
-void MulVector3ByMatrix3(Vector3& r, const Vector3& v, const Matrix3& a);\r
-Vector3 MulVector3ByMatrix3(const Vector3& v, const Matrix3& a);\r
+void MulVec3ByMat3(Vec3& r, const Vec3& v, const Mat3& a);\r
+Vec3 MulVec3ByMat3(const Vec3& v, const Mat3& a);\r
\r
//----------------------------------------------------------------------------------------\r
-slInline void SetMatrix3(Matrix3& r, const Matrix3& a)\r
+slInline void SetMat3(Mat3& r, const Mat3& a)\r
{\r
r.v[0] = a.v[0];\r
r.v[1] = a.v[1];\r
}\r
\r
//----------------------------------------------------------------------------------------\r
-slInline void SetMatrix3(Matrix3& r, const Vector3& v0, const Vector3& v1, const Vector3& v2)\r
+slInline void SetMat3(Mat3& r, const Vec3& v0, const Vec3& v1, const Vec3& v2)\r
{\r
r.v[0] = v0;\r
r.v[1] = v1;\r