Added creating a derived matrix from the rotation matrix.

Creating a derived matrix from the rotation matrix about the x-, y-, and z-axis.
This commit is contained in:
Vitali Parkhomenko 2018-03-19 18:25:45 +03:00
parent be53cebcd3
commit 5fe5f32edd
2 changed files with 69 additions and 0 deletions

View File

@ -46,6 +46,24 @@ namespace glm
GLM_FUNC_DECL mat<4, 4, T, defaultp> eulerAngleZ(
T const& angleZ);
/// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about X-axis.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleX(
T const & angleX, T const & angularVelocityX);
/// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about Y-axis.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleY(
T const & angleY, T const & angularVelocityY);
/// Creates a 3D 4 * 4 homogeneous derived matrix from the rotation matrix about Z-axis.
/// @see gtx_euler_angles
template <typename T>
GLM_FUNC_DECL mat<4, 4, T, defaultp> derivedEulerAngleZ(
T const & angleZ, T const & angularVelocityZ);
/// Creates a 3D 4 * 4 homogeneous rotation matrix from euler angles (X * Y).
/// @see gtx_euler_angles
template<typename T>

View File

@ -53,6 +53,57 @@ namespace glm
T(0), T(0), T(0), T(1));
}
template <typename T>
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> derivedEulerAngleX
(
T const & angleX,
T const & angularVelocityX
)
{
T cosX = glm::cos(angleX) * angularVelocityX;
T sinX = glm::sin(angleX) * angularVelocityX;
return mat<4, 4, T, defaultp>(
T(0), T(0), T(0), T(0),
T(0),-sinX, cosX, T(0),
T(0),-cosX,-sinX, T(0),
T(0), T(0), T(0), T(0));
}
template <typename T>
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> derivedEulerAngleY
(
T const & angleY,
T const & angularVelocityY
)
{
T cosY = glm::cos(angleY) * angularVelocityY;
T sinY = glm::sin(angleY) * angularVelocityY;
return mat<4, 4, T, defaultp>(
-sinY, T(0), -cosY, T(0),
T(0), T(0), T(0), T(0),
cosY, T(0), -sinY, T(0),
T(0), T(0), T(0), T(0));
}
template <typename T>
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> derivedEulerAngleZ
(
T const & angleZ,
T const & angularVelocityZ
)
{
T cosZ = glm::cos(angleZ) * angularVelocityZ;
T sinZ = glm::sin(angleZ) * angularVelocityZ;
return mat<4, 4, T, defaultp>(
-sinZ, cosZ, T(0), T(0),
-cosZ, -sinZ, T(0), T(0),
T(0), T(0), T(0), T(0),
T(0), T(0), T(0), T(0));
}
template<typename T>
GLM_FUNC_QUALIFIER mat<4, 4, T, defaultp> eulerAngleXY
(