summaryrefslogtreecommitdiff
path: root/core/math/matrix3.h
diff options
context:
space:
mode:
Diffstat (limited to 'core/math/matrix3.h')
-rw-r--r--core/math/matrix3.h82
1 files changed, 41 insertions, 41 deletions
diff --git a/core/math/matrix3.h b/core/math/matrix3.h
index 0b61e3a56c..abce1ee45d 100644
--- a/core/math/matrix3.h
+++ b/core/math/matrix3.h
@@ -37,7 +37,7 @@
/**
@author Juan Linietsky <reduzio@gmail.com>
*/
-class Matrix3 {
+class Basis {
public:
Vector3 elements[3];
@@ -54,8 +54,8 @@ public:
void invert();
void transpose();
- Matrix3 inverse() const;
- Matrix3 transposed() const;
+ Basis inverse() const;
+ Basis transposed() const;
_FORCE_INLINE_ real_t determinant() const;
@@ -73,14 +73,14 @@ public:
}
void rotate(const Vector3& p_axis, real_t p_phi);
- Matrix3 rotated(const Vector3& p_axis, real_t p_phi) const;
+ Basis rotated(const Vector3& p_axis, real_t p_phi) const;
void rotate(const Vector3& p_euler);
- Matrix3 rotated(const Vector3& p_euler) const;
+ Basis rotated(const Vector3& p_euler) const;
Vector3 get_rotation() const;
void scale( const Vector3& p_scale );
- Matrix3 scaled( const Vector3& p_scale ) const;
+ Basis scaled( const Vector3& p_scale ) const;
Vector3 get_scale() const;
Vector3 get_euler() const;
@@ -97,21 +97,21 @@ public:
return elements[0][2] * v[0] + elements[1][2] * v[1] + elements[2][2] * v[2];
}
- bool isequal_approx(const Matrix3& a, const Matrix3& b) const;
+ bool isequal_approx(const Basis& a, const Basis& b) const;
- bool operator==(const Matrix3& p_matrix) const;
- bool operator!=(const Matrix3& p_matrix) const;
+ bool operator==(const Basis& p_matrix) const;
+ bool operator!=(const Basis& p_matrix) const;
_FORCE_INLINE_ Vector3 xform(const Vector3& p_vector) const;
_FORCE_INLINE_ Vector3 xform_inv(const Vector3& p_vector) const;
- _FORCE_INLINE_ void operator*=(const Matrix3& p_matrix);
- _FORCE_INLINE_ Matrix3 operator*(const Matrix3& p_matrix) const;
- _FORCE_INLINE_ void operator+=(const Matrix3& p_matrix);
- _FORCE_INLINE_ Matrix3 operator+(const Matrix3& p_matrix) const;
- _FORCE_INLINE_ void operator-=(const Matrix3& p_matrix);
- _FORCE_INLINE_ Matrix3 operator-(const Matrix3& p_matrix) const;
+ _FORCE_INLINE_ void operator*=(const Basis& p_matrix);
+ _FORCE_INLINE_ Basis operator*(const Basis& p_matrix) const;
+ _FORCE_INLINE_ void operator+=(const Basis& p_matrix);
+ _FORCE_INLINE_ Basis operator+(const Basis& p_matrix) const;
+ _FORCE_INLINE_ void operator-=(const Basis& p_matrix);
+ _FORCE_INLINE_ Basis operator-(const Basis& p_matrix) const;
_FORCE_INLINE_ void operator*=(real_t p_val);
- _FORCE_INLINE_ Matrix3 operator*(real_t p_val) const;
+ _FORCE_INLINE_ Basis operator*(real_t p_val) const;
int get_orthogonal_index() const;
void set_orthogonal_index(int p_index);
@@ -163,9 +163,9 @@ public:
elements[2].zero();
}
- _FORCE_INLINE_ Matrix3 transpose_xform(const Matrix3& m) const
+ _FORCE_INLINE_ Basis transpose_xform(const Basis& m) const
{
- return Matrix3(
+ return Basis(
elements[0].x * m[0].x + elements[1].x * m[1].x + elements[2].x * m[2].x,
elements[0].x * m[0].y + elements[1].x * m[1].y + elements[2].x * m[2].y,
elements[0].x * m[0].z + elements[1].x * m[1].z + elements[2].x * m[2].z,
@@ -176,31 +176,31 @@ public:
elements[0].z * m[0].y + elements[1].z * m[1].y + elements[2].z * m[2].y,
elements[0].z * m[0].z + elements[1].z * m[1].z + elements[2].z * m[2].z);
}
- Matrix3(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
+ Basis(real_t xx, real_t xy, real_t xz, real_t yx, real_t yy, real_t yz, real_t zx, real_t zy, real_t zz) {
set(xx, xy, xz, yx, yy, yz, zx, zy, zz);
}
void orthonormalize();
- Matrix3 orthonormalized() const;
+ Basis orthonormalized() const;
bool is_symmetric() const;
- Matrix3 diagonalize();
+ Basis diagonalize();
operator Quat() const;
- Matrix3(const Quat& p_quat); // euler
- Matrix3(const Vector3& p_euler); // euler
- Matrix3(const Vector3& p_axis, real_t p_phi);
+ Basis(const Quat& p_quat); // euler
+ Basis(const Vector3& p_euler); // euler
+ Basis(const Vector3& p_axis, real_t p_phi);
- _FORCE_INLINE_ Matrix3(const Vector3& row0, const Vector3& row1, const Vector3& row2)
+ _FORCE_INLINE_ Basis(const Vector3& row0, const Vector3& row1, const Vector3& row2)
{
elements[0]=row0;
elements[1]=row1;
elements[2]=row2;
}
- _FORCE_INLINE_ Matrix3() {
+ _FORCE_INLINE_ Basis() {
elements[0][0]=1;
elements[0][1]=0;
@@ -216,7 +216,7 @@ public:
};
-_FORCE_INLINE_ void Matrix3::operator*=(const Matrix3& p_matrix) {
+_FORCE_INLINE_ void Basis::operator*=(const Basis& p_matrix) {
set(
p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]),
@@ -225,9 +225,9 @@ _FORCE_INLINE_ void Matrix3::operator*=(const Matrix3& p_matrix) {
}
-_FORCE_INLINE_ Matrix3 Matrix3::operator*(const Matrix3& p_matrix) const {
+_FORCE_INLINE_ Basis Basis::operator*(const Basis& p_matrix) const {
- return Matrix3(
+ return Basis(
p_matrix.tdotx(elements[0]), p_matrix.tdoty(elements[0]), p_matrix.tdotz(elements[0]),
p_matrix.tdotx(elements[1]), p_matrix.tdoty(elements[1]), p_matrix.tdotz(elements[1]),
p_matrix.tdotx(elements[2]), p_matrix.tdoty(elements[2]), p_matrix.tdotz(elements[2]) );
@@ -235,49 +235,49 @@ _FORCE_INLINE_ Matrix3 Matrix3::operator*(const Matrix3& p_matrix) const {
}
-_FORCE_INLINE_ void Matrix3::operator+=(const Matrix3& p_matrix) {
+_FORCE_INLINE_ void Basis::operator+=(const Basis& p_matrix) {
elements[0] += p_matrix.elements[0];
elements[1] += p_matrix.elements[1];
elements[2] += p_matrix.elements[2];
}
-_FORCE_INLINE_ Matrix3 Matrix3::operator+(const Matrix3& p_matrix) const {
+_FORCE_INLINE_ Basis Basis::operator+(const Basis& p_matrix) const {
- Matrix3 ret(*this);
+ Basis ret(*this);
ret += p_matrix;
return ret;
}
-_FORCE_INLINE_ void Matrix3::operator-=(const Matrix3& p_matrix) {
+_FORCE_INLINE_ void Basis::operator-=(const Basis& p_matrix) {
elements[0] -= p_matrix.elements[0];
elements[1] -= p_matrix.elements[1];
elements[2] -= p_matrix.elements[2];
}
-_FORCE_INLINE_ Matrix3 Matrix3::operator-(const Matrix3& p_matrix) const {
+_FORCE_INLINE_ Basis Basis::operator-(const Basis& p_matrix) const {
- Matrix3 ret(*this);
+ Basis ret(*this);
ret -= p_matrix;
return ret;
}
-_FORCE_INLINE_ void Matrix3::operator*=(real_t p_val) {
+_FORCE_INLINE_ void Basis::operator*=(real_t p_val) {
elements[0]*=p_val;
elements[1]*=p_val;
elements[2]*=p_val;
}
-_FORCE_INLINE_ Matrix3 Matrix3::operator*(real_t p_val) const {
+_FORCE_INLINE_ Basis Basis::operator*(real_t p_val) const {
- Matrix3 ret(*this);
+ Basis ret(*this);
ret *= p_val;
return ret;
}
-Vector3 Matrix3::xform(const Vector3& p_vector) const {
+Vector3 Basis::xform(const Vector3& p_vector) const {
return Vector3(
elements[0].dot(p_vector),
@@ -286,7 +286,7 @@ Vector3 Matrix3::xform(const Vector3& p_vector) const {
);
}
-Vector3 Matrix3::xform_inv(const Vector3& p_vector) const {
+Vector3 Basis::xform_inv(const Vector3& p_vector) const {
return Vector3(
(elements[0][0]*p_vector.x ) + ( elements[1][0]*p_vector.y ) + ( elements[2][0]*p_vector.z ),
@@ -295,7 +295,7 @@ Vector3 Matrix3::xform_inv(const Vector3& p_vector) const {
);
}
-real_t Matrix3::determinant() const {
+real_t Basis::determinant() const {
return elements[0][0]*(elements[1][1]*elements[2][2] - elements[2][1]*elements[1][2]) -
elements[1][0]*(elements[0][1]*elements[2][2] - elements[2][1]*elements[0][2]) +