mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-03-03 12:14:10 -04:00
AP_Math: allow null pointers in Quaternion::to_euler()
this matches the Matrix3f method
This commit is contained in:
parent
16c95236c0
commit
5c6368bad3
@ -76,10 +76,16 @@ void Quaternion::from_euler(float roll, float pitch, float yaw)
|
|||||||
// create eulers from a quaternion
|
// create eulers from a quaternion
|
||||||
void Quaternion::to_euler(float *roll, float *pitch, float *yaw)
|
void Quaternion::to_euler(float *roll, float *pitch, float *yaw)
|
||||||
{
|
{
|
||||||
*roll = -(atan2(2.0*(q1*q2 + q3*q4),
|
if (roll) {
|
||||||
1 - 2.0*(q2*q2 + q3*q3)));
|
*roll = -(atan2(2.0*(q1*q2 + q3*q4),
|
||||||
// we let safe_asin() handle the singularities near 90/-90 in pitch
|
1 - 2.0*(q2*q2 + q3*q3)));
|
||||||
*pitch = -safe_asin(2.0*(q1*q3 - q4*q2));
|
}
|
||||||
*yaw = atan2(2.0*(q1*q4 + q2*q3),
|
if (pitch) {
|
||||||
1 - 2.0*(q3*q3 + q4*q4));
|
// 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…
Reference in New Issue
Block a user