Fix Matrix3x3::Matrix3x3(Quaternion)
This commit is contained in:
@@ -297,16 +297,7 @@ namespace J3ML::LinearAlgebra {
|
|||||||
/// Identical to D3DXMatrixPerspectiveRH, except transposed to account for Matrix * vector convention used in J3ML.
|
/// Identical to D3DXMatrixPerspectiveRH, except transposed to account for Matrix * vector convention used in J3ML.
|
||||||
/// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb205355(v=vs.85).aspx
|
/// See http://msdn.microsoft.com/en-us/library/windows/desktop/bb205355(v=vs.85).aspx
|
||||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||||
static Matrix4x4 D3DPerspProjRH(float n, float f, float h, float v)
|
static Matrix4x4 D3DPerspProjRH(float n, float f, float h, float v);
|
||||||
{
|
|
||||||
Matrix4x4 p;
|
|
||||||
p[0][0] = 2.f * n / h; p[0][1] = 0; p[0][2] = 0; p[0][3] = 0.f;
|
|
||||||
p[1][0] = 0; p[1][1] = 2.f * n / v; p[1][2] = 0; p[1][3] = 0.f;
|
|
||||||
p[2][0] = 0; p[2][1] = 0; p[2][2] = f / (f-n); p[2][3] = n * f / (n-f);
|
|
||||||
p[3][0] = 0; p[3][1] = 0; p[3][2] = 1.f; p[3][3] = 0.f;
|
|
||||||
|
|
||||||
return p;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Computes a left-handled orthographic projection matrix for OpenGL.
|
/// Computes a left-handled orthographic projection matrix for OpenGL.
|
||||||
/// @note Use the M*v multiplication order to project points with this matrix.
|
/// @note Use the M*v multiplication order to project points with this matrix.
|
||||||
@@ -519,8 +510,15 @@ namespace J3ML::LinearAlgebra {
|
|||||||
|
|
||||||
Vector3 ExtractScale() const;
|
Vector3 ExtractScale() const;
|
||||||
|
|
||||||
|
/// Returns true if this matrix only contains uniform scaling, compared to the given epsilon.
|
||||||
|
/// @note If the matrix does not really do any scaling, this function returns true (scaling uniformly by a factor of 1).
|
||||||
|
/// @note This function only examines the upper 3-by-3 part of this matrix.
|
||||||
|
/// @note This function assumes that this matrix does not contain projection (the fourth row of this matrix is [0 0 0 1]).
|
||||||
bool HasUniformScale(float epsilon = 1e-3f) const;
|
bool HasUniformScale(float epsilon = 1e-3f) const;
|
||||||
|
|
||||||
|
/// Returns true if the row vectors of 3x3-top-left submatrix are all perpendicular to each other.
|
||||||
bool IsColOrthogonal3(float epsilon = 1e-3f) const;
|
bool IsColOrthogonal3(float epsilon = 1e-3f) const;
|
||||||
|
/// Returns true if the column vector of 3x3-top-left submatrix are all perpendicular to each other.
|
||||||
bool IsRowOrthogonal3(float epsilon = 1e-3f) const;
|
bool IsRowOrthogonal3(float epsilon = 1e-3f) const;
|
||||||
|
|
||||||
bool IsColOrthogonal(float epsilon = 1e-3f) const;
|
bool IsColOrthogonal(float epsilon = 1e-3f) const;
|
||||||
@@ -552,7 +550,7 @@ namespace J3ML::LinearAlgebra {
|
|||||||
/// Computes the Cholesky decomposition of this matrix.
|
/// Computes the Cholesky decomposition of this matrix.
|
||||||
/// The returned matrix L satisfies L * transpose(L) = this;
|
/// The returned matrix L satisfies L * transpose(L) = this;
|
||||||
/// Returns true on success.
|
/// Returns true on success.
|
||||||
bool ColeskyDecompose(Matrix4x4 &outL) const;
|
bool CholeskyDecompose(Matrix4x4 &outL) const;
|
||||||
|
|
||||||
/// Computes the LU decomposition of this matrix.
|
/// Computes the LU decomposition of this matrix.
|
||||||
/// This decomposition has the form 'this = L * U'
|
/// This decomposition has the form 'this = L * U'
|
||||||
@@ -561,10 +559,7 @@ namespace J3ML::LinearAlgebra {
|
|||||||
|
|
||||||
/// Inverts this matrix using the generic Gauss's method.
|
/// Inverts this matrix using the generic Gauss's method.
|
||||||
/// @return Returns true on success, false otherwise.
|
/// @return Returns true on success, false otherwise.
|
||||||
bool Inverse(float epsilon = 1e-6f)
|
bool Inverse(float epsilon = 1e-6f);
|
||||||
{
|
|
||||||
return InverseMatrix(*this, epsilon);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Returns an inverted copy of this matrix.
|
/// Returns an inverted copy of this matrix.
|
||||||
/// If this matrix does not have an inverse, returns the matrix that was the result of running
|
/// If this matrix does not have an inverse, returns the matrix that was the result of running
|
||||||
@@ -614,13 +609,7 @@ namespace J3ML::LinearAlgebra {
|
|||||||
bool InverseTranspose();
|
bool InverseTranspose();
|
||||||
/// Returns the inverse transpose of this matrix.
|
/// Returns the inverse transpose of this matrix.
|
||||||
/// Use that matrix to transform covariant vectors (normal vectors).
|
/// Use that matrix to transform covariant vectors (normal vectors).
|
||||||
Matrix4x4 InverseTransposed() const
|
Matrix4x4 InverseTransposed() const;
|
||||||
{
|
|
||||||
Matrix4x4 copy = *this;
|
|
||||||
copy.Transpose();
|
|
||||||
copy.Inverse();
|
|
||||||
return copy;
|
|
||||||
}
|
|
||||||
/// Returns the sum of the diagonal elements of this matrix.
|
/// Returns the sum of the diagonal elements of this matrix.
|
||||||
float Trace() const;
|
float Trace() const;
|
||||||
|
|
||||||
|
@@ -106,7 +106,7 @@ namespace J3ML::LinearAlgebra {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Matrix3x3::Matrix3x3(const Quaternion &orientation) {
|
Matrix3x3::Matrix3x3(const Quaternion &orientation) {
|
||||||
|
SetRotatePart(orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
float Matrix3x3::Determinant() const {
|
float Matrix3x3::Determinant() const {
|
||||||
|
@@ -816,4 +816,33 @@ namespace J3ML::LinearAlgebra {
|
|||||||
p[3][0] = 0; p[3][1] = 0; p[3][2] = 1.f; p[3][3] = 0.f;
|
p[3][0] = 0; p[3][1] = 0; p[3][2] = 1.f; p[3][3] = 0.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Matrix4x4 Matrix4x4::D3DPerspProjRH(float n, float f, float h, float v) {
|
||||||
|
Matrix4x4 p;
|
||||||
|
p[0][0] = 2.f * n / h; p[0][1] = 0; p[0][2] = 0; p[0][3] = 0.f;
|
||||||
|
p[1][0] = 0; p[1][1] = 2.f * n / v; p[1][2] = 0; p[1][3] = 0.f;
|
||||||
|
p[2][0] = 0; p[2][1] = 0; p[2][2] = f / (f-n); p[2][3] = n * f / (n-f);
|
||||||
|
p[3][0] = 0; p[3][1] = 0; p[3][2] = 1.f; p[3][3] = 0.f;
|
||||||
|
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Matrix4x4::Inverse(float epsilon) {
|
||||||
|
return InverseMatrix(*this, epsilon);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Matrix4x4::LUDecompose(Matrix4x4 &outLower, Matrix4x4 &outUpper) const {
|
||||||
|
return LUDecomposeMatrix(*this, outLower, outUpper);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Matrix4x4::CholeskyDecompose(Matrix4x4 &outL) const {
|
||||||
|
return CholeskyDecomposeMatrix(*this, outL);
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix4x4 Matrix4x4::InverseTransposed() const {
|
||||||
|
Matrix4x4 copy = *this;
|
||||||
|
copy.Transpose();
|
||||||
|
copy.Inverse();
|
||||||
|
return copy;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
Reference in New Issue
Block a user