71 inline Matrix4x4(
float r0c0,
float r1c0,
float r2c0,
float r3c0,
float r0c1,
float r1c1,
float r2c1,
float r3c1,
float r0c2,
float r1c2,
float r2c2,
float r3c2,
float r0c3,
float r1c3,
float r2c3,
float r3c3) {
72 set(r0c0, r1c0, r2c0, r3c0, r0c1, r1c1, r2c1, r3c1, r0c2, r1c2, r2c2, r3c2, r0c3, r1c3, r2c3, r3c3);
95 inline Matrix4x4&
set(
float r0c0,
float r1c0,
float r2c0,
float r3c0,
float r0c1,
float r1c1,
float r2c1,
float r3c1,
float r0c2,
float r1c2,
float r2c2,
float r3c2,
float r0c3,
float r1c3,
float r2c3,
float r3c3) {
217 return this->
equals(m) ==
false;
392 array<float, 16> _data;
482 float r0 = vXYZ[0] * vXYZ[0] * c1 + c;
483 float r1 = vXYZ[0] * vXYZ[1] * c1 + vXYZ[2] * s;
484 float r2 = vXYZ[0] * vXYZ[2] * c1 - vXYZ[1] * s;
485 float r4 = vXYZ[0] * vXYZ[1] * c1 - vXYZ[2] * s;
486 float r5 = vXYZ[1] * vXYZ[1] * c1 + c;
487 float r6 = vXYZ[1] * vXYZ[2] * c1 + vXYZ[0] * s;
488 float r8 = vXYZ[0] * vXYZ[2] * c1 + vXYZ[1] * s;
489 float r9 = vXYZ[1] * vXYZ[2] * c1 - vXYZ[0] * s;
490 float r10= vXYZ[2] * vXYZ[2] * c1 + c;
491 data[0] = r0 * m0 + r4 * m1 + r8 * m2;
492 data[1] = r1 * m0 + r5 * m1 + r9 * m2;
493 data[2] = r2 * m0 + r6 * m1 + r10* m2;
494 data[4] = r0 * m4 + r4 * m5 + r8 * m6;
495 data[5] = r1 * m4 + r5 * m5 + r9 * m6;
496 data[6] = r2 * m4 + r6 * m5 + r10* m6;
497 data[8] = r0 * m8 + r4 * m9 + r8 * m10;
498 data[9] = r1 * m8 + r5 * m9 + r9 * m10;
499 data[10]= r2 * m8 + r6 * m9 + r10* m10;
500 data[12]= r0 * m12+ r4 * m13+ r8 * m14;
501 data[13]= r1 * m12+ r5 * m13+ r9 * m14;
502 data[14]= r2 * m12+ r6 * m13+ r10* m14;
511 array <float, 16> _data;
522 _data[10] =
data[10];
523 _data[11] =
data[14];
526 _data[14] =
data[11];
527 _data[15] =
data[15];
555 array <float, 16> _data;
572 auto determinant =
data[0] * _data[0] +
data[1] * _data[4] +
data[2] * _data[8] +
data[3] * _data[12];
573 if (determinant == 0.0f) {
577 determinant = 1.0f / determinant;
578 for (
auto i = 0; i < _data.size(); i++)
579 _data[i] = _data[i] * determinant;
617 return (array<float, 16>&)
data;
638 (m2.
data[0] * t) + ((1.0f - t) * m1.
data[0]),
639 (m2.
data[1] * t) + ((1.0f - t) * m1.
data[1]),
640 (m2.
data[2] * t) + ((1.0f - t) * m1.
data[2]),
641 (m2.
data[3] * t) + ((1.0f - t) * m1.
data[3]),
642 (m2.
data[4] * t) + ((1.0f - t) * m1.
data[4]),
643 (m2.
data[5] * t) + ((1.0f - t) * m1.
data[5]),
644 (m2.
data[6] * t) + ((1.0f - t) * m1.
data[6]),
645 (m2.
data[7] * t) + ((1.0f - t) * m1.
data[7]),
646 (m2.
data[8] * t) + ((1.0f - t) * m1.
data[8]),
647 (m2.
data[9] * t) + ((1.0f - t) * m1.
data[9]),
648 (m2.
data[10] * t) + ((1.0f - t) * m1.
data[10]),
649 (m2.
data[11] * t) + ((1.0f - t) * m1.
data[11]),
650 (m2.
data[12] * t) + ((1.0f - t) * m1.
data[12]),
651 (m2.
data[13] * t) + ((1.0f - t) * m1.
data[13]),
652 (m2.
data[14] * t) + ((1.0f - t) * m1.
data[14]),
653 (m2.
data[15] * t) + ((1.0f - t) * m1.
data[15])
679 auto cy =
static_cast<float>(
Math::sqrt(
data[axis0 + 4 * axis0] *
data[axis0 + 4 * axis0] +
data[axis1 + 4 * axis0] *
data[axis1 + 4 * axis0]));
681 euler[0] =
static_cast<float>((
Math::atan2(
data[axis2 + 4 * axis1],
data[axis2 + 4 * axis2])));
682 euler[1] =
static_cast<float>((
Math::atan2(-
data[axis2 + 4 * axis0], cy)));
683 euler[2] =
static_cast<float>((
Math::atan2(
data[axis1 + 4 * axis0],
data[axis0 + 4 * axis0])));
685 euler[0] =
static_cast<float>((
Math::atan2(-
data[axis1 + 4 * axis2],
data[axis1 + 4 * axis1])));
686 euler[1] =
static_cast<float>((
Math::atan2(-
data[axis2 + 4 * axis0], cy)));
static float sqrt(float value)
Returns the square of given value.
static float cos(float value)
Returns the cosine of an angle.
static constexpr float EPSILON
static int32_t abs(int32_t value)
Returns absolute value.
static float atan2(float y, float x)
Returns the angle from the conversion of rectangular coordinates to polar coordinates.
static constexpr float PI
static constexpr float DEG2RAD
static float sin(float value)
Returns the sine of an angle.
Matrix4x4(const Matrix4x4 &matrix)
Public constructor.
Vector4 multiply(const Vector4 &v) const
Multiplies a vector4 with this matrix into destination vector.
Matrix4x4(const array< float, 16 > &m)
Public constructor.
Matrix4x4 clone() const
Clones this matrix.
Matrix4x4 & set(const array< float, 16 > &m)
Sets up this matrix by matrix m.
void getAxes(Vector3 &xAxis, Vector3 &yAxis, Vector3 &zAxis) const
Get coordinate system axes.
static Matrix4x4 interpolateLinear(const Matrix4x4 &m1, const Matrix4x4 &m2, float t)
Interpolates between matrix 1 and matrix 2 by 0f<=t<=1f linearly.
Matrix4x4 & multiply(const Matrix4x4 &m)
Multiplies this matrix with another matrix.
Vector3 computeEulerAngles() const
Compute Euler angles (rotation around x, y, z axes)
Matrix4x4()
Public constructor.
Matrix4x4 & identity()
Setup identity matrix.
Matrix4x4 & rotate(const Vector3 &axis, float angle)
Creates a rotation matrix.
Matrix4x4 & set(float r0c0, float r1c0, float r2c0, float r3c0, float r0c1, float r1c1, float r2c1, float r3c1, float r0c2, float r1c2, float r2c2, float r3c2, float r0c3, float r1c3, float r2c3, float r3c3)
Set up matrix by values.
Matrix4x4 & scale(const Vector3 &v)
Scales this matrix by given vector.
Matrix4x4 & transpose()
Transposes this matrix.
Matrix4x4 & setTranslation(const Vector3 &translation)
Set translation.
bool operator==(const Matrix4x4 &m) const
Equality comparison operator.
Matrix4x4 & setScale(const Vector3 &scale)
Get scale.
Matrix4x4(float r0c0, float r1c0, float r2c0, float r3c0, float r0c1, float r1c1, float r2c1, float r3c1, float r0c2, float r1c2, float r2c2, float r3c2, float r0c3, float r1c3, float r2c3, float r3c3)
Public constructor.
const float & operator[](int i) const
Const array access operator.
Matrix4x4 & operator*=(const Matrix4x4 m)
Vector3 multiplyNoTranslation(const Vector3 &v) const
Multiplies a vector3 with this matrix ignoring translation.
float & operator[](int i)
Array access operator.
void getScale(Vector3 &scale) const
Get scale.
Matrix4x4 & translate(const Vector3 &v)
Sets up a translation matrix.
Matrix4x4 operator*(const float f) const
Operator * (float)
Matrix4x4 clone()
Clones this matrix.
Matrix4x4 & invert()
Inverts the matrix.
Matrix4x4 & setAxes(const Vector3 &xAxis, const Vector3 &yAxis, const Vector3 &zAxis)
Set coordinate system axes.
void getTranslation(Vector3 &translation) const
Get translation.
Matrix4x4 & scale(float s)
Scales this matrix.
Matrix4x4 & set(const Matrix4x4 &m)
Sets up this matrix by matrix m.
Vector3 multiply(const Vector3 &v) const
Multiplies a vector3 with this matrix into destination vector.
array< float, 16 > & getArray() const
Returns array data.
bool equals(const Matrix4x4 &m) const
Returns if this matrix equals m.
bool operator!=(const Matrix4x4 &m) const
Non equality comparison operator.
float computeLength() const
Vector3 & normalize()
Normalize the vector.
Vector3 & set(float x, float y, float z)
Set up vector.
Vector3 & scale(float scale)
Scale this vector.
array< float, 3 > & getArray() const