Browse Source

AP_Math: allow null pointers in Quaternion::to_euler()

this matches the Matrix3f method
mission-4.1.18
Andrew Tridgell 13 years ago
parent
commit
5c6368bad3
  1. 6
      libraries/AP_Math/quaternion.cpp

6
libraries/AP_Math/quaternion.cpp

@ -76,10 +76,16 @@ void Quaternion::from_euler(float roll, float pitch, float yaw) @@ -76,10 +76,16 @@ void Quaternion::from_euler(float roll, float pitch, float yaw)
// create eulers from a quaternion
void Quaternion::to_euler(float *roll, float *pitch, float *yaw)
{
if (roll) {
*roll = -(atan2(2.0*(q1*q2 + q3*q4),
1 - 2.0*(q2*q2 + q3*q3)));
}
if (pitch) {
// we let safe_asin() handle the singularities near 90/-90 in pitch
*pitch = -safe_asin(2.0*(q1*q3 - q4*q2));
}
if (yaw) {
*yaw = atan2(2.0*(q1*q4 + q2*q3),
1 - 2.0*(q3*q3 + q4*q4));
}
}

Loading…
Cancel
Save