Fill out Matrix3x3 Documentation, implement several missing functions.
Some checks failed
Build Docs With Doxygen / Explore-Gitea-Actions (push) Has been cancelled
Some checks failed
Build Docs With Doxygen / Explore-Gitea-Actions (push) Has been cancelled
This commit is contained in:
@@ -87,18 +87,22 @@ namespace J3ML::LinearAlgebra {
|
||||
|
||||
}
|
||||
|
||||
Matrix3x3::Matrix3x3(const Vector3 &r1, const Vector3 &r2, const Vector3 &r3) {
|
||||
this->elems[0][0] = r1.x;
|
||||
this->elems[0][1] = r1.y;
|
||||
this->elems[0][2] = r1.z;
|
||||
Matrix3x3::Matrix3x3(const Vector3 &col0, const Vector3 &col1, const Vector3 &col2) {
|
||||
SetColumn(0, col0);
|
||||
SetColumn(1, col1);
|
||||
SetColumn(2, col2);
|
||||
|
||||
this->elems[1][0] = r2.x;
|
||||
this->elems[1][1] = r2.y;
|
||||
this->elems[1][2] = r2.z;
|
||||
//this->elems[0][0] = r1.x;
|
||||
//this->elems[0][1] = r1.y;
|
||||
//this->elems[0][2] = r1.z;
|
||||
|
||||
this->elems[2][0] = r3.x;
|
||||
this->elems[2][1] = r3.y;
|
||||
this->elems[2][2] = r3.z;
|
||||
//this->elems[1][0] = r2.x;
|
||||
//this->elems[1][1] = r2.y;
|
||||
//this->elems[1][2] = r2.z;
|
||||
|
||||
//this->elems[2][0] = r3.x;
|
||||
//this->elems[2][1] = r3.y;
|
||||
//this->elems[2][2] = r3.z;
|
||||
}
|
||||
|
||||
Matrix3x3::Matrix3x3(const Quaternion &orientation) {
|
||||
@@ -456,5 +460,74 @@ namespace J3ML::LinearAlgebra {
|
||||
return Transform(rhs);
|
||||
}
|
||||
|
||||
Matrix3x3 Matrix3x3::RotateX(float radians) {
|
||||
Matrix3x3 r;
|
||||
r.SetRotatePartX(radians);
|
||||
return r;
|
||||
}
|
||||
|
||||
Matrix3x3 Matrix3x3::RotateY(float radians) {
|
||||
Matrix3x3 r;
|
||||
r.SetRotatePartY(radians);
|
||||
return r;
|
||||
}
|
||||
|
||||
Matrix3x3 Matrix3x3::RotateZ(float radians) {
|
||||
Matrix3x3 r;
|
||||
r.SetRotatePartZ(radians);
|
||||
return r;
|
||||
}
|
||||
|
||||
void Matrix3x3::SetRotatePartX(float angle) {
|
||||
Set3x3PartRotateX(*this, angle);
|
||||
}
|
||||
|
||||
void Matrix3x3::SetRotatePartY(float angle) {
|
||||
Set3x3PartRotateY(*this, angle);
|
||||
}
|
||||
|
||||
void Matrix3x3::SetRotatePartZ(float angle) {
|
||||
Set3x3RotatePartZ(*this, angle);
|
||||
}
|
||||
|
||||
Vector3 Matrix3x3::ExtractScale() const {
|
||||
return {GetColumn(0).Length(), GetColumn(1).Length(), GetColumn(2).Length()};
|
||||
}
|
||||
|
||||
// TODO: Finish implementation
|
||||
Matrix3x3 Matrix3x3::RotateFromTo(const Vector3 &source, const Vector3 &direction) {
|
||||
assert(source.IsNormalized());
|
||||
assert(source.IsNormalized());
|
||||
|
||||
// http://cs.brown.edu/research/pubs/pdfs/1999/Moller-1999-EBA.pdf
|
||||
Matrix3x3 r;
|
||||
float dot = source.Dot(direction);
|
||||
if (std::abs(dot) > 0.999f)
|
||||
{
|
||||
Vector3 s = source.Abs();
|
||||
Vector3 unit = s.x < s.y && s.x < s.z ? Vector3::UnitX : (s.y < s.z ? Vector3::UnitY : Vector3::UnitZ);
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 &Matrix3x3::Row(int row) {
|
||||
assert(row >= 0);
|
||||
assert(row < Rows);
|
||||
return reinterpret_cast<Vector3 &> (elems[row]);
|
||||
}
|
||||
|
||||
Vector3 Matrix3x3::Column(int index) const { return GetColumn(index);}
|
||||
|
||||
Vector3 Matrix3x3::Col(int index) const { return Column(index);}
|
||||
|
||||
Vector3 &Matrix3x3::Row3(int index) {
|
||||
return reinterpret_cast<Vector3 &>(elems[index]);
|
||||
}
|
||||
|
||||
Vector3 Matrix3x3::Row3(int index) const { return GetRow3(index);}
|
||||
|
||||
void Matrix3x3::Set(const Matrix3x3 &x3) {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user