Commit 1c5a33cf authored by Anakin's avatar Anakin

different quat2eul function from the internet

parent 40783470
......@@ -574,21 +574,20 @@ void Object::readUV(Segment* dataDestination, std::streampos position)
void Object::quat2eul(float &quat0, float &quat1, float & quat2, float &quat3)
{
float eulX = atan2(
2 * (quat0 * quat1 + quat2 * quat3),
1 - 2 * (pow(quat1, 2) + pow(quat2, 2))
);
float eulY = asin(2 * (quat0 * quat2 - quat3 * quat1));
float eulZ = atan2(
2 * (quat0 * quat3 + quat1 * quat2),
1 - 2 * (pow(quat2, 2) + pow(quat3, 2))
) - PI;
quat0 = eulX;
quat1 = eulY;
quat2 = eulZ;
float ysqr = quat1 * quat1;
float t0 = -2.0f * (ysqr + quat2 * quat2) + 1.0f;
float t1 = +2.0f * (quat0 * quat1 - quat3 * quat2);
float t2 = -2.0f * (quat0 * quat2 + quat3 * quat1);
float t3 = +2.0f * (quat1 * quat2 - quat3 * quat0);
float t4 = -2.0f * (quat0 * quat0 + ysqr) + 1.0f;
t2 = t2 > 1.0f ? 1.0f : t2;
t2 = t2 < -1.0f ? -1.0f : t2;
quat1 = std::asin(t2);
quat0 = std::atan2(t3, t4);
quat2 = std::atan2(t1, t0);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment