mirror of
https://github.com/recp/cglm.git
synced 2025-12-26 10:35:10 +00:00
got the euler to quat xyz working and got the tests to pass
This commit is contained in:
@@ -142,7 +142,7 @@ glm_quat_init(versor q, float x, float y, float z, float w) {
|
||||
//TODO: telephone001's eulertoquat
|
||||
|
||||
/*!
|
||||
* @brief creates a quaternion using rotation angles and does does rotations in x y z order
|
||||
* @brief creates NEW quaternion using rotation angles and does does rotations in x y z order
|
||||
*
|
||||
* @param[out] q quaternion
|
||||
* @param[in] angle angles x y z (radians)
|
||||
@@ -150,20 +150,21 @@ glm_quat_init(versor q, float x, float y, float z, float w) {
|
||||
CGLM_INLINE
|
||||
void
|
||||
glm_euler_xyz_quat(versor q, vec3 angles) {
|
||||
float xs = sinf(angles[0] / 2.0);
|
||||
float xc = cosf(angles[0] / 2.0);
|
||||
float xs = sinf(angles[0] / 2.0f);
|
||||
float xc = cosf(angles[0] / 2.0f);
|
||||
|
||||
float ys = sinf(angles[1] / 2.0);
|
||||
float yc = cosf(angles[1] / 2.0);
|
||||
float ys = sinf(angles[1] / 2.0f);
|
||||
float yc = cosf(angles[1] / 2.0f);
|
||||
|
||||
float zs = sinf(angles[2] / 2.0);
|
||||
float zc = cosf(angles[2] / 2.0);
|
||||
float zs = sinf(angles[2] / 2.0f);
|
||||
float zc = cosf(angles[2] / 2.0f);
|
||||
|
||||
glm_quat_init(q,
|
||||
zc * yc * xs - zs * ys * xs,
|
||||
zc * ys * xc - zs * yc * xs,
|
||||
zs * yc * xc - zs * yc * xs,
|
||||
zc * yc * xs - zs * ys * xc,
|
||||
zc * ys * xc + zs * yc * xs,
|
||||
-zc * ys * xs + zs * yc * xc,
|
||||
zc * yc * xc + zs * ys * xs);
|
||||
|
||||
}
|
||||
|
||||
/*!
|
||||
|
||||
Reference in New Issue
Block a user