From 0452029690a07f9fae8ecdec61c06011fb6e2e58 Mon Sep 17 00:00:00 2001 From: Thompson Lee Date: Wed, 17 Aug 2016 16:41:02 -0400 Subject: [PATCH] Added Quat_FromPitchYawRoll() helper function. Quickly converts pitch, yaw, and roll rotations to the Quaternion equivalent orientation. --- include/c3d/maths.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/include/c3d/maths.h b/include/c3d/maths.h index 1587231..4b442b1 100644 --- a/include/c3d/maths.h +++ b/include/c3d/maths.h @@ -668,4 +668,16 @@ static inline C3D_FVec FVec3_CrossQuat(C3D_FVec v, C3D_FQuat q) // v×q = q^-1×v return Quat_CrossFVec3(Quat_Inverse(q), v); } + +/** + * @brief Converting Pitch, Yaw, and Roll to Quaternion equivalent + * @param[in] pitch The pitch angle in radians. + * @param[in] yaw The yaw angle in radians. + * @param[in] roll The roll angle in radians. + * @return C3D_FQuat The Quaternion equivalent with the pitch, yaw, and roll orientations applied. + */ +static inline C3D_FQuat Quat_FromPitchYawRoll(float pitch, float yaw, float roll) +{ + return Quat_RotateZ(Quat_RotateY(Quat_RotateX(Quat_Identity(), pitch, false), yaw, false), roll, false); +} ///@}