Promoted matrix inverse functions
This commit is contained in:
parent
455144b990
commit
cd183edb29
@ -65,7 +65,6 @@ namespace glm
|
|||||||
genIType & msb,
|
genIType & msb,
|
||||||
genIType & lsb);
|
genIType & lsb);
|
||||||
|
|
||||||
|
|
||||||
//! Extracts bits [offset, offset + bits - 1] from value,
|
//! Extracts bits [offset, offset + bits - 1] from value,
|
||||||
//! returning them in the least significant bits of the result.
|
//! returning them in the least significant bits of the result.
|
||||||
//! For unsigned data types, the most significant bits of the
|
//! For unsigned data types, the most significant bits of the
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// Created : 2009-05-01
|
// Created : 2009-05-01
|
||||||
// Updated : 2010-04-30
|
// Updated : 2010-12-13
|
||||||
// Licence : This source is under MIT License
|
// Licence : This source is under MIT License
|
||||||
// File : glm/ext.hpp
|
// File : glm/ext.hpp
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
#include "./gtc/half_float.hpp"
|
#include "./gtc/half_float.hpp"
|
||||||
#include "./gtc/matrix_access.hpp"
|
#include "./gtc/matrix_access.hpp"
|
||||||
|
#include "./gtc/matrix_inverse.hpp"
|
||||||
#include "./gtc/matrix_transform.hpp"
|
#include "./gtc/matrix_transform.hpp"
|
||||||
#include "./gtc/quaternion.hpp"
|
#include "./gtc/quaternion.hpp"
|
||||||
#include "./gtc/swizzle.hpp"
|
#include "./gtc/swizzle.hpp"
|
||||||
@ -27,7 +28,6 @@
|
|||||||
#include "./gtx/comparison.hpp"
|
#include "./gtx/comparison.hpp"
|
||||||
#include "./gtx/compatibility.hpp"
|
#include "./gtx/compatibility.hpp"
|
||||||
#include "./gtx/component_wise.hpp"
|
#include "./gtx/component_wise.hpp"
|
||||||
#include "./gtx/determinant.hpp"
|
|
||||||
#include "./gtx/epsilon.hpp"
|
#include "./gtx/epsilon.hpp"
|
||||||
#include "./gtx/euler_angles.hpp"
|
#include "./gtx/euler_angles.hpp"
|
||||||
#include "./gtx/extend.hpp"
|
#include "./gtx/extend.hpp"
|
||||||
@ -41,14 +41,11 @@
|
|||||||
#include "./gtx/int_10_10_10_2.hpp"
|
#include "./gtx/int_10_10_10_2.hpp"
|
||||||
#include "./gtx/integer.hpp"
|
#include "./gtx/integer.hpp"
|
||||||
#include "./gtx/intersect.hpp"
|
#include "./gtx/intersect.hpp"
|
||||||
#include "./gtx/inverse.hpp"
|
|
||||||
#include "./gtx/inverse_transpose.hpp"
|
|
||||||
#include "./gtx/log_base.hpp"
|
#include "./gtx/log_base.hpp"
|
||||||
#include "./gtx/matrix_cross_product.hpp"
|
#include "./gtx/matrix_cross_product.hpp"
|
||||||
#include "./gtx/matrix_major_storage.hpp"
|
#include "./gtx/matrix_major_storage.hpp"
|
||||||
#include "./gtx/matrix_operation.hpp"
|
#include "./gtx/matrix_operation.hpp"
|
||||||
#include "./gtx/matrix_query.hpp"
|
#include "./gtx/matrix_query.hpp"
|
||||||
#include "./gtx/matrix_selection.hpp"
|
|
||||||
#include "./gtx/mixed_product.hpp"
|
#include "./gtx/mixed_product.hpp"
|
||||||
#include "./gtx/norm.hpp"
|
#include "./gtx/norm.hpp"
|
||||||
#include "./gtx/normal.hpp"
|
#include "./gtx/normal.hpp"
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Created : 2005-12-21
|
||||||
|
// Updated : 2010-12-13
|
||||||
|
// Licence : This source is under MIT License
|
||||||
|
// File : glm/gtc/matrix_inverse.hpp
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Dependency:
|
||||||
|
// - GLM core
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#ifndef glm_gtc_matrix_inverse
|
||||||
|
#define glm_gtc_matrix_inverse
|
||||||
|
|
||||||
|
// Dependency:
|
||||||
|
#include "../glm.hpp"
|
||||||
|
|
||||||
|
namespace glm{
|
||||||
|
namespace gtc{
|
||||||
|
//! GLM_GTC_matrix_inverse extension: Inverse matrix functions
|
||||||
|
namespace matrix_inverse
|
||||||
|
{
|
||||||
|
//! Fast matrix inverse for affine matrix.
|
||||||
|
//! From GLM_GTC_matrix_inverse extension.
|
||||||
|
template <typename genType>
|
||||||
|
genType affineInverse(genType const & m);
|
||||||
|
|
||||||
|
//! Compute the inverse transpose of a matrix.
|
||||||
|
//! From GLM_GTC_matrix_inverse extension.
|
||||||
|
template <typename genType>
|
||||||
|
inline typename genType::value_type inverseTranspose(
|
||||||
|
genType const & m);
|
||||||
|
|
||||||
|
}//namespace matrix_inverse
|
||||||
|
}//namespace gtc
|
||||||
|
}//namespace glm
|
||||||
|
|
||||||
|
#include "matrix_inverse.inl"
|
||||||
|
|
||||||
|
namespace glm{using namespace gtc::matrix_inverse;}
|
||||||
|
|
||||||
|
#endif//glm_gtc_matrix_inverse
|
@ -0,0 +1,139 @@
|
|||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Created : 2005-12-21
|
||||||
|
// Updated : 2010-12-13
|
||||||
|
// Licence : This source is under MIT License
|
||||||
|
// File : glm/gtc/matrix_inverse.inl
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
namespace glm{
|
||||||
|
namespace gtx{
|
||||||
|
namespace matrix_inverse
|
||||||
|
{
|
||||||
|
template <typename T>
|
||||||
|
inline detail::tmat3x3<T> affineInverse
|
||||||
|
(
|
||||||
|
detail::tmat3x3<T> const & m
|
||||||
|
)
|
||||||
|
{
|
||||||
|
detail::tmat3x3<T> Result(m);
|
||||||
|
Result[2] = detail::tvec3<T>(0, 0, 1);
|
||||||
|
Result = transpose(Result);
|
||||||
|
detail::tvec3<T> Translation = Result * detail::tvec3<T>(-detail::tvec2<T>(m[2]), m[2][2]);
|
||||||
|
Result[2] = Translation;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
inline detail::tmat4x4<T> affineInverse
|
||||||
|
(
|
||||||
|
detail::tmat4x4<T> const & m
|
||||||
|
)
|
||||||
|
{
|
||||||
|
detail::tmat4x4<T> Result(m);
|
||||||
|
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
|
||||||
|
Result = transpose(Result);
|
||||||
|
detail::tvec4<T> Translation = Result * detail::tvec4<T>(-detail::tvec3<T>(m[3]), m[3][3]);
|
||||||
|
Result[3] = Translation;
|
||||||
|
return Result;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename valType>
|
||||||
|
inline detail::tmat2x2<valType> inverseTranspose(
|
||||||
|
detail::tmat2x2<valType> const & m)
|
||||||
|
{
|
||||||
|
valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
|
||||||
|
|
||||||
|
detail::tmat2x2<valType> Inverse(
|
||||||
|
+ m[1][1] / Determinant,
|
||||||
|
- m[0][1] / Determinant,
|
||||||
|
- m[1][0] / Determinant,
|
||||||
|
+ m[0][0] / Determinant);
|
||||||
|
|
||||||
|
return Inverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename valType>
|
||||||
|
inline detail::tmat3x3<valType> inverseTranspose(
|
||||||
|
detail::tmat3x3<valType> const & m)
|
||||||
|
{
|
||||||
|
valType Determinant =
|
||||||
|
+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
|
||||||
|
- m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
|
||||||
|
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
||||||
|
|
||||||
|
detail::tmat3x3<valType> Inverse;
|
||||||
|
Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
|
||||||
|
Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
|
||||||
|
Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
|
||||||
|
Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);
|
||||||
|
Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]);
|
||||||
|
Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);
|
||||||
|
Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
|
||||||
|
Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);
|
||||||
|
Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
|
||||||
|
Inverse /= Determinant;
|
||||||
|
|
||||||
|
return Inverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename valType>
|
||||||
|
inline detail::tmat4x4<valType> inverseTranspose(
|
||||||
|
detail::tmat4x4<valType> const & m)
|
||||||
|
{
|
||||||
|
valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
|
||||||
|
valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
|
||||||
|
valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
|
||||||
|
valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
|
||||||
|
valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
|
||||||
|
valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
|
||||||
|
valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
|
||||||
|
valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||||
|
valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
|
||||||
|
valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
|
||||||
|
valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
|
||||||
|
valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
||||||
|
valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
|
||||||
|
valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
|
||||||
|
valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
|
||||||
|
valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
|
||||||
|
valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
|
||||||
|
valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
|
||||||
|
valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
|
||||||
|
|
||||||
|
detail::tmat4x4<valType> Inverse;
|
||||||
|
Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
|
||||||
|
Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
|
||||||
|
Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
|
||||||
|
Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05);
|
||||||
|
|
||||||
|
Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02);
|
||||||
|
Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04);
|
||||||
|
Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05);
|
||||||
|
Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05);
|
||||||
|
|
||||||
|
Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08);
|
||||||
|
Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10);
|
||||||
|
Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12);
|
||||||
|
Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12);
|
||||||
|
|
||||||
|
Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15);
|
||||||
|
Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17);
|
||||||
|
Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18);
|
||||||
|
Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
|
||||||
|
|
||||||
|
valType Determinant =
|
||||||
|
+ m[0][0] * Inverse[0][0]
|
||||||
|
+ m[0][1] * Inverse[0][1]
|
||||||
|
+ m[0][2] * Inverse[0][2]
|
||||||
|
+ m[0][3] * Inverse[0][3];
|
||||||
|
|
||||||
|
Inverse /= Determinant;
|
||||||
|
|
||||||
|
return Inverse;
|
||||||
|
}
|
||||||
|
|
||||||
|
}//namespace matrix_inverse
|
||||||
|
}//namespace gtx
|
||||||
|
}//namespace glm
|
@ -1,40 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2005-12-21
|
|
||||||
// Updated : 2008-09-30
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : glm/gtx/inverse.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Dependency:
|
|
||||||
// - GLM core
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef glm_gtx_inverse
|
|
||||||
#define glm_gtx_inverse
|
|
||||||
|
|
||||||
// Dependency:
|
|
||||||
#include "../glm.hpp"
|
|
||||||
#include "../gtc/matrix_operation.hpp"
|
|
||||||
|
|
||||||
namespace glm{
|
|
||||||
namespace gtx{
|
|
||||||
//! GLM_GTX_inverse extension: Inverse matrix functions
|
|
||||||
namespace inverse
|
|
||||||
{
|
|
||||||
using namespace gtc::matrix_operation;
|
|
||||||
|
|
||||||
//! Fast matrix inverse for affine matrix.
|
|
||||||
//! From GLM_GTX_inverse extension.
|
|
||||||
template <typename genType>
|
|
||||||
genType affineInverse(genType const & m);
|
|
||||||
|
|
||||||
}//namespace inverse
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace glm
|
|
||||||
|
|
||||||
#include "inverse.inl"
|
|
||||||
|
|
||||||
namespace glm{using namespace gtx::inverse;}
|
|
||||||
|
|
||||||
#endif//glm_gtx_inverse
|
|
@ -1,44 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2005-12-21
|
|
||||||
// Updated : 2008-09-30
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : glm/gtx/inverse.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace glm{
|
|
||||||
namespace gtx{
|
|
||||||
namespace inverse
|
|
||||||
{
|
|
||||||
template <typename T>
|
|
||||||
inline detail::tmat3x3<T> affineInverse
|
|
||||||
(
|
|
||||||
detail::tmat3x3<T> const & m
|
|
||||||
)
|
|
||||||
{
|
|
||||||
detail::tmat3x3<T> Result(m);
|
|
||||||
Result[2] = detail::tvec3<T>(0, 0, 1);
|
|
||||||
Result = transpose(Result);
|
|
||||||
detail::tvec3<T> Translation = Result * detail::tvec3<T>(-detail::tvec2<T>(m[2]), m[2][2]);
|
|
||||||
Result[2] = Translation;
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
inline detail::tmat4x4<T> affineInverse
|
|
||||||
(
|
|
||||||
detail::tmat4x4<T> const & m
|
|
||||||
)
|
|
||||||
{
|
|
||||||
detail::tmat4x4<T> Result(m);
|
|
||||||
Result[3] = detail::tvec4<T>(0, 0, 0, 1);
|
|
||||||
Result = transpose(Result);
|
|
||||||
detail::tvec4<T> Translation = Result * detail::tvec4<T>(-detail::tvec3<T>(m[3]), m[3][3]);
|
|
||||||
Result[3] = Translation;
|
|
||||||
return Result;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace inverse
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace glm
|
|
@ -1,39 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2006-01-04
|
|
||||||
// Updated : 2008-10-23
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : glm/gtx/inverse_transpose.hpp
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Dependency:
|
|
||||||
// - GLM core
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
#ifndef glm_gtx_inverse_transpose
|
|
||||||
#define glm_gtx_inverse_transpose
|
|
||||||
|
|
||||||
// Dependency:
|
|
||||||
#include "../glm.hpp"
|
|
||||||
|
|
||||||
namespace glm
|
|
||||||
{
|
|
||||||
namespace gtx{
|
|
||||||
//! GLM_GTX_inverse_transpose extension: Inverse transpose matrix functions
|
|
||||||
namespace inverse_transpose
|
|
||||||
{
|
|
||||||
//! Compute the inverse transpose of a matrix.
|
|
||||||
//! From GLM_GTX_inverse extension.
|
|
||||||
template <typename genType>
|
|
||||||
inline typename genType::value_type inverseTranspose(
|
|
||||||
genType const & m);
|
|
||||||
|
|
||||||
}//namespace inverse_transpose
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace glm
|
|
||||||
|
|
||||||
#include "inverse_transpose.inl"
|
|
||||||
|
|
||||||
namespace glm{using namespace gtx::inverse_transpose;}
|
|
||||||
|
|
||||||
#endif//glm_gtx_inverse_transpose
|
|
@ -1,112 +0,0 @@
|
|||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// OpenGL Mathematics Copyright (c) 2005 - 2010 G-Truc Creation (www.g-truc.net)
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Created : 2006-01-04
|
|
||||||
// Updated : 2008-12-02
|
|
||||||
// Licence : This source is under MIT License
|
|
||||||
// File : glm/gtx/inverse_transpose.inl
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
namespace glm{
|
|
||||||
namespace gtx{
|
|
||||||
//! GLM_GTX_inverse_transpose extension: Inverse transpose matrix functions
|
|
||||||
namespace inverse_transpose{
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
inline detail::tmat2x2<valType> inverseTranspose(
|
|
||||||
detail::tmat2x2<valType> const & m)
|
|
||||||
{
|
|
||||||
valType Determinant = m[0][0] * m[1][1] - m[1][0] * m[0][1];
|
|
||||||
|
|
||||||
detail::tmat2x2<valType> Inverse(
|
|
||||||
+ m[1][1] / Determinant,
|
|
||||||
- m[0][1] / Determinant,
|
|
||||||
- m[1][0] / Determinant,
|
|
||||||
+ m[0][0] / Determinant);
|
|
||||||
|
|
||||||
return Inverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
inline detail::tmat3x3<valType> inverseTranspose(
|
|
||||||
detail::tmat3x3<valType> const & m)
|
|
||||||
{
|
|
||||||
valType Determinant =
|
|
||||||
+ m[0][0] * (m[1][1] * m[2][2] - m[1][2] * m[2][1])
|
|
||||||
- m[0][1] * (m[1][0] * m[2][2] - m[1][2] * m[2][0])
|
|
||||||
+ m[0][2] * (m[1][0] * m[2][1] - m[1][1] * m[2][0]);
|
|
||||||
|
|
||||||
detail::tmat3x3<valType> Inverse;
|
|
||||||
Inverse[0][0] = + (m[1][1] * m[2][2] - m[2][1] * m[1][2]);
|
|
||||||
Inverse[0][1] = - (m[1][0] * m[2][2] - m[2][0] * m[1][2]);
|
|
||||||
Inverse[0][2] = + (m[1][0] * m[2][1] - m[2][0] * m[1][1]);
|
|
||||||
Inverse[1][0] = - (m[0][1] * m[2][2] - m[2][1] * m[0][2]);
|
|
||||||
Inverse[1][1] = + (m[0][0] * m[2][2] - m[2][0] * m[0][2]);
|
|
||||||
Inverse[1][2] = - (m[0][0] * m[2][1] - m[2][0] * m[0][1]);
|
|
||||||
Inverse[2][0] = + (m[0][1] * m[1][2] - m[1][1] * m[0][2]);
|
|
||||||
Inverse[2][1] = - (m[0][0] * m[1][2] - m[1][0] * m[0][2]);
|
|
||||||
Inverse[2][2] = + (m[0][0] * m[1][1] - m[1][0] * m[0][1]);
|
|
||||||
Inverse /= Determinant;
|
|
||||||
|
|
||||||
return Inverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <typename valType>
|
|
||||||
inline detail::tmat4x4<valType> inverseTranspose(
|
|
||||||
detail::tmat4x4<valType> const & m)
|
|
||||||
{
|
|
||||||
valType SubFactor00 = m[2][2] * m[3][3] - m[3][2] * m[2][3];
|
|
||||||
valType SubFactor01 = m[2][1] * m[3][3] - m[3][1] * m[2][3];
|
|
||||||
valType SubFactor02 = m[2][1] * m[3][2] - m[3][1] * m[2][2];
|
|
||||||
valType SubFactor03 = m[2][0] * m[3][3] - m[3][0] * m[2][3];
|
|
||||||
valType SubFactor04 = m[2][0] * m[3][2] - m[3][0] * m[2][2];
|
|
||||||
valType SubFactor05 = m[2][0] * m[3][1] - m[3][0] * m[2][1];
|
|
||||||
valType SubFactor06 = m[1][2] * m[3][3] - m[3][2] * m[1][3];
|
|
||||||
valType SubFactor07 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
|
||||||
valType SubFactor08 = m[1][1] * m[3][2] - m[3][1] * m[1][2];
|
|
||||||
valType SubFactor09 = m[1][0] * m[3][3] - m[3][0] * m[1][3];
|
|
||||||
valType SubFactor10 = m[1][0] * m[3][2] - m[3][0] * m[1][2];
|
|
||||||
valType SubFactor11 = m[1][1] * m[3][3] - m[3][1] * m[1][3];
|
|
||||||
valType SubFactor12 = m[1][0] * m[3][1] - m[3][0] * m[1][1];
|
|
||||||
valType SubFactor13 = m[1][2] * m[2][3] - m[2][2] * m[1][3];
|
|
||||||
valType SubFactor14 = m[1][1] * m[2][3] - m[2][1] * m[1][3];
|
|
||||||
valType SubFactor15 = m[1][1] * m[2][2] - m[2][1] * m[1][2];
|
|
||||||
valType SubFactor16 = m[1][0] * m[2][3] - m[2][0] * m[1][3];
|
|
||||||
valType SubFactor17 = m[1][0] * m[2][2] - m[2][0] * m[1][2];
|
|
||||||
valType SubFactor18 = m[1][0] * m[2][1] - m[2][0] * m[1][1];
|
|
||||||
|
|
||||||
detail::tmat4x4<valType> Inverse;
|
|
||||||
Inverse[0][0] = + (m[1][1] * SubFactor00 - m[1][2] * SubFactor01 + m[1][3] * SubFactor02);
|
|
||||||
Inverse[0][1] = - (m[1][0] * SubFactor00 - m[1][2] * SubFactor03 + m[1][3] * SubFactor04);
|
|
||||||
Inverse[0][2] = + (m[1][0] * SubFactor01 - m[1][1] * SubFactor03 + m[1][3] * SubFactor05);
|
|
||||||
Inverse[0][3] = - (m[1][0] * SubFactor02 - m[1][1] * SubFactor04 + m[1][2] * SubFactor05);
|
|
||||||
|
|
||||||
Inverse[1][0] = - (m[0][1] * SubFactor00 - m[0][2] * SubFactor01 + m[0][3] * SubFactor02);
|
|
||||||
Inverse[1][1] = + (m[0][0] * SubFactor00 - m[0][2] * SubFactor03 + m[0][3] * SubFactor04);
|
|
||||||
Inverse[1][2] = - (m[0][0] * SubFactor01 - m[0][1] * SubFactor03 + m[0][3] * SubFactor05);
|
|
||||||
Inverse[1][3] = + (m[0][0] * SubFactor02 - m[0][1] * SubFactor04 + m[0][2] * SubFactor05);
|
|
||||||
|
|
||||||
Inverse[2][0] = + (m[0][1] * SubFactor06 - m[0][2] * SubFactor07 + m[0][3] * SubFactor08);
|
|
||||||
Inverse[2][1] = - (m[0][0] * SubFactor06 - m[0][2] * SubFactor09 + m[0][3] * SubFactor10);
|
|
||||||
Inverse[2][2] = + (m[0][0] * SubFactor11 - m[0][1] * SubFactor09 + m[0][3] * SubFactor12);
|
|
||||||
Inverse[2][3] = - (m[0][0] * SubFactor08 - m[0][1] * SubFactor10 + m[0][2] * SubFactor12);
|
|
||||||
|
|
||||||
Inverse[3][0] = - (m[0][1] * SubFactor13 - m[0][2] * SubFactor14 + m[0][3] * SubFactor15);
|
|
||||||
Inverse[3][1] = + (m[0][0] * SubFactor13 - m[0][2] * SubFactor16 + m[0][3] * SubFactor17);
|
|
||||||
Inverse[3][2] = - (m[0][0] * SubFactor14 - m[0][1] * SubFactor16 + m[0][3] * SubFactor18);
|
|
||||||
Inverse[3][3] = + (m[0][0] * SubFactor15 - m[0][1] * SubFactor17 + m[0][2] * SubFactor18);
|
|
||||||
|
|
||||||
valType Determinant =
|
|
||||||
+ m[0][0] * Inverse[0][0]
|
|
||||||
+ m[0][1] * Inverse[0][1]
|
|
||||||
+ m[0][2] * Inverse[0][2]
|
|
||||||
+ m[0][3] * Inverse[0][3];
|
|
||||||
|
|
||||||
Inverse /= Determinant;
|
|
||||||
|
|
||||||
return Inverse;
|
|
||||||
}
|
|
||||||
|
|
||||||
}//namespace inverse_transpose
|
|
||||||
}//namespace gtx
|
|
||||||
}//namespace glm
|
|
Loading…
Reference in New Issue
Block a user