Implement Matrix3x3::Equals() RandomRotation() RandomGeneral() Unary + Operator
This commit is contained in:
@@ -575,7 +575,7 @@ namespace J3ML::LinearAlgebra {
|
||||
{
|
||||
float d = Determinant();
|
||||
bool isSingular = EqualAbs(d, 0.f, epsilon);
|
||||
//assert(Inverse(epsilon) == isSingular);
|
||||
//assert(Inverted(epsilon) == isSingular);
|
||||
return !isSingular;
|
||||
}
|
||||
|
||||
@@ -1050,6 +1050,36 @@ namespace J3ML::LinearAlgebra {
|
||||
return *this * rhs;
|
||||
}
|
||||
|
||||
Matrix3x3 Matrix3x3::operator*(const Quaternion &rhs) const {
|
||||
return *this * Matrix3x3(rhs);
|
||||
}
|
||||
|
||||
bool Matrix3x3::Equals(const Matrix3x3 &other, float epsilon) const {
|
||||
for(int y = 0; y < Rows; ++y)
|
||||
for(int x = 0; x < Cols; ++x)
|
||||
if (!Math::EqualAbs(At(y, x), other[y][x], epsilon))
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
Matrix3x3 Matrix3x3::RandomRotation(RNG &rng) {
|
||||
// The easiest way to generate a random orientation is through quaternions
|
||||
// So we convert a random quaternion to a rotation matrix.
|
||||
return FromQuat(Quaternion::RandomRotation(rng));
|
||||
}
|
||||
|
||||
Matrix3x3 Matrix3x3::RandomGeneral(RNG &rng, float minElem, float maxElem) {
|
||||
Matrix3x3 m;
|
||||
for (int y = 0; y < 3; ++y)
|
||||
{
|
||||
for (int x = 0; x < 3; ++x)
|
||||
{
|
||||
m[y][x] = rng.Float(minElem, maxElem);
|
||||
}
|
||||
}
|
||||
return m;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user