// Copyright (c) Wojciech Figat. All rights reserved. #pragma once #include "Vector4.h" /// /// Represents a 4x4 mathematical matrix using double-precision floating-point values. /// struct FLAXENGINE_API Double4x4 { public: union { struct { /// Value at row 1 column 1 of the matrix. double M11; /// Value at row 1 column 2 of the matrix. double M12; /// Value at row 1 column 3 of the matrix. double M13; /// Value at row 1 column 4 of the matrix. double M14; /// Value at row 2 column 1 of the matrix. double M21; /// Value at row 2 column 2 of the matrix. double M22; /// Value at row 2 column 3 of the matrix. double M23; /// Value at row 2 column 4 of the matrix. double M24; /// Value at row 3 column 1 of the matrix. double M31; /// Value at row 3 column 2 of the matrix. double M32; /// Value at row 3 column 3 of the matrix. double M33; /// Value at row 3 column 4 of the matrix. double M34; /// Value at row 4 column 1 of the matrix. double M41; /// Value at row 4 column 2 of the matrix. double M42; /// Value at row 4 column 3 of the matrix. double M43; /// Value at row 4 column 4 of the matrix. double M44; }; double Values[4][4]; double Raw[16]; }; public: /// /// Empty constructor. /// Double4x4() = default; Double4x4(const Matrix& matrix); public: // Inverts the matrix. void Invert() { Invert(*this, *this); } // Calculates the inverse of the specified matrix. static Double4x4 Invert(const Double4x4& value) { Double4x4 result; Invert(value, result); return result; } // Calculates the inverse of the specified matrix. static void Invert(const Double4x4& value, Double4x4& result); // Creates a left-handed, look-at matrix. static void LookAt(const Double3& eye, const Double3& target, const Double3& up, Double4x4& result); // Calculates the product of two matrices. static void Multiply(const Double4x4& left, const Double4x4& right, Double4x4& result); // Creates a matrix that contains both the X, Y and Z rotation, as well as scaling and translation. static void Transformation(const Float3& scaling, const Quaternion& rotation, const Vector3& translation, Double4x4& result); public: Double4x4 operator*(const Double4x4& other) const { Double4x4 result; Multiply(*this, other, result); return result; } }; template<> struct TIsPODType { enum { Value = true }; };