mirror of
https://github.com/g-truc/glm.git
synced 2025-04-06 05:55:03 +00:00
Added adjugate functions to GTX_matrix_operation #151
This commit is contained in:
parent
76683aa287
commit
1362d51967
3 changed files with 75 additions and 0 deletions
|
@ -82,6 +82,21 @@ namespace glm
|
|||
GLM_FUNC_DECL mat<4, 4, T, Q> diagonal4x4(
|
||||
vec<4, T, Q> const& v);
|
||||
|
||||
/// Build an adjugate matrix.
|
||||
/// From GLM_GTX_matrix_operation extension.
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL mat<2, 2, T, Q> adjugate(mat<2, 2, T, Q> const& m);
|
||||
|
||||
/// Build an adjugate matrix.
|
||||
/// From GLM_GTX_matrix_operation extension.
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL mat<3, 3, T, Q> adjugate(mat<3, 3, T, Q> const& m);
|
||||
|
||||
/// Build an adjugate matrix.
|
||||
/// From GLM_GTX_matrix_operation extension.
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_DECL mat<4, 4, T, Q> adjugate(mat<4, 4, T, Q> const& m);
|
||||
|
||||
/// @}
|
||||
}//namespace glm
|
||||
|
||||
|
|
|
@ -114,4 +114,63 @@ namespace glm
|
|||
Result[1][1] = v[1];
|
||||
return Result;
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<2, 2, T, Q> adjugate(mat<2, 2, T, Q> const& m)
|
||||
{
|
||||
return mat<2, 2, T, Q>(
|
||||
+m[1][1], -m[1][0],
|
||||
-m[0][1], +m[0][0]);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<3, 3, T, Q> adjugate(mat<3, 3, T, Q> const& m)
|
||||
{
|
||||
T const m00 = determinant(mat<2, 2, T, Q>(m[1][1], m[2][1], m[1][2], m[2][2]));
|
||||
T const m01 = determinant(mat<2, 2, T, Q>(m[0][1], m[2][1], m[0][2], m[2][2]));
|
||||
T const m02 = determinant(mat<2, 2, T, Q>(m[0][1], m[1][1], m[0][2], m[1][2]));
|
||||
|
||||
T const m10 = determinant(mat<2, 2, T, Q>(m[1][0], m[2][0], m[1][2], m[2][2]));
|
||||
T const m11 = determinant(mat<2, 2, T, Q>(m[0][0], m[2][0], m[0][2], m[2][2]));
|
||||
T const m12 = determinant(mat<2, 2, T, Q>(m[0][0], m[1][0], m[0][2], m[1][2]));
|
||||
|
||||
T const m20 = determinant(mat<2, 2, T, Q>(m[1][0], m[2][0], m[1][1], m[2][1]));
|
||||
T const m21 = determinant(mat<2, 2, T, Q>(m[0][0], m[2][0], m[0][1], m[2][1]));
|
||||
T const m22 = determinant(mat<2, 2, T, Q>(m[0][0], m[1][0], m[0][1], m[1][1]));
|
||||
|
||||
return mat<3, 3, T, Q>(
|
||||
+m00, -m01, +m02,
|
||||
-m10, +m11, -m12,
|
||||
+m20, -m21, +m22);
|
||||
}
|
||||
|
||||
template<typename T, qualifier Q>
|
||||
GLM_FUNC_QUALIFIER mat<4, 4, T, Q> adjugate(mat<4, 4, T, Q> const& m)
|
||||
{
|
||||
T const m00 = determinant(mat<3, 3, T, Q>(m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]));
|
||||
T const m01 = determinant(mat<3, 3, T, Q>(m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]));
|
||||
T const m02 = determinant(mat<3, 3, T, Q>(m[1][0], m[1][1], m[1][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][1], m[3][3]));
|
||||
T const m03 = determinant(mat<3, 3, T, Q>(m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]));
|
||||
|
||||
T const m10 = determinant(mat<3, 3, T, Q>(m[0][1], m[0][2], m[0][3], m[2][1], m[2][2], m[2][3], m[3][1], m[3][2], m[3][3]));
|
||||
T const m11 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][2], m[0][3], m[2][0], m[2][2], m[2][3], m[3][0], m[3][2], m[3][3]));
|
||||
T const m12 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][1], m[0][3], m[2][0], m[2][1], m[2][3], m[3][0], m[3][1], m[3][3]));
|
||||
T const m13 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][1], m[0][2], m[2][0], m[2][1], m[2][2], m[3][0], m[3][1], m[3][2]));
|
||||
|
||||
T const m20 = determinant(mat<3, 3, T, Q>(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[3][1], m[3][2], m[3][3]));
|
||||
T const m21 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[3][0], m[3][2], m[3][3]));
|
||||
T const m22 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[3][0], m[3][1], m[3][3]));
|
||||
T const m23 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[3][0], m[3][1], m[3][2]));
|
||||
|
||||
T const m30 = determinant(mat<3, 3, T, Q>(m[0][1], m[0][2], m[0][3], m[1][1], m[1][2], m[1][3], m[2][1], m[2][2], m[2][3]));
|
||||
T const m31 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][2], m[0][3], m[1][0], m[1][2], m[1][3], m[2][0], m[2][2], m[2][3]));
|
||||
T const m32 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][1], m[0][3], m[1][0], m[1][1], m[1][3], m[2][0], m[2][1], m[2][3]));
|
||||
T const m33 = determinant(mat<3, 3, T, Q>(m[0][0], m[0][1], m[0][2], m[1][0], m[1][1], m[1][2], m[2][0], m[2][1], m[2][2]));
|
||||
|
||||
return mat<4, 4, T, Q>(
|
||||
+m00, -m01, +m02, -m03,
|
||||
-m10, +m11, -m12, +m13,
|
||||
+m20, -m21, +m22, -m23,
|
||||
-m30, +m31, -m32, +m33);
|
||||
}
|
||||
}//namespace glm
|
||||
|
|
|
@ -56,6 +56,7 @@ glm::mat4 camera(float Translate, glm::vec2 const& Rotate)
|
|||
#### Features:
|
||||
- Added equal and notEqual overload with max ULPs parameters for scalar numbers #121
|
||||
- Added GLM_FORCE_SILENT_WARNINGS to silent GLM warnings when using language extensions but using W4 or Wpedantic warnings #814 #775
|
||||
- Added adjugate functions to GTX_matrix_operation #151
|
||||
|
||||
#### Improvements:
|
||||
- Added constant time ULP distance between float #121
|
||||
|
|
Loading…
Add table
Reference in a new issue