Implement Matrix3x3::IsRowOrthogonal IsColOrthogonal
This commit is contained in:
@@ -26,6 +26,7 @@ namespace J3ML::LinearAlgebra {
|
||||
* vectors in the form M * v. This means that "Matrix3x3 M, M1, M2; M = M1 * M2;" gives a transformation M
|
||||
* that applies M2 first, followed by M1 second
|
||||
*/
|
||||
|
||||
class Matrix3x3 {
|
||||
public:
|
||||
enum { Rows = 3 };
|
||||
@@ -137,7 +138,10 @@ namespace J3ML::LinearAlgebra {
|
||||
Vector4 Mul(const Vector4& rhs) const;
|
||||
Quaternion Mul(const Quaternion& rhs) const;
|
||||
|
||||
void IsColOrthogonal();
|
||||
// Returns true if the column vectors of this matrix are all perpendicular to each other.
|
||||
bool IsColOrthogonal(float epsilon = 1e-3f) const;
|
||||
// Returns true if the row vectors of this matrix are all perpendicular to each other.
|
||||
bool IsRowOrthogonal(float epsilon = 1e-3f) const;
|
||||
|
||||
protected:
|
||||
float elems[3][3];
|
||||
|
@@ -397,8 +397,18 @@ namespace J3ML::LinearAlgebra {
|
||||
return *this * rhs;
|
||||
}
|
||||
|
||||
void Matrix3x3::IsColOrthogonal() {
|
||||
bool Matrix3x3::IsRowOrthogonal(float epsilon) const
|
||||
{
|
||||
return GetRow(0).IsPerpendicular(GetRow(1), epsilon)
|
||||
&& GetRow(0).IsPerpendicular(GetRow(2), epsilon)
|
||||
&& GetRow(1).IsPerpendicular(GetRow(2), epsilon);
|
||||
}
|
||||
|
||||
bool Matrix3x3::IsColOrthogonal(float epsilon) const
|
||||
{
|
||||
return GetColumn(0).IsPerpendicular(GetColumn(1), epsilon)
|
||||
&& GetColumn(0).IsPerpendicular(GetColumn(2), epsilon)
|
||||
&& GetColumn(1).IsPerpendicular(GetColumn(2), epsilon);
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user