mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-01-23 17:18:28 -04:00
AP_Math: add Internal_Error for quaternion of 0 length
This commit is contained in:
parent
69997626d3
commit
9b74452270
@ -639,6 +639,9 @@ void QuaternionT<T>::normalize(void)
|
||||
q2 *= quatMagInv;
|
||||
q3 *= quatMagInv;
|
||||
q4 *= quatMagInv;
|
||||
} else {
|
||||
// The code goes here if the quaternion is [0,0,0,0]. This shouldn't happen.
|
||||
INTERNAL_ERROR(AP_InternalError::error_t::flow_of_control);
|
||||
}
|
||||
}
|
||||
|
||||
@ -722,6 +725,12 @@ QuaternionT<T> QuaternionT<T>::operator/(const QuaternionT<T> &v) const
|
||||
const T &quat2 = q3;
|
||||
const T &quat3 = q4;
|
||||
|
||||
const T quatMag = length();
|
||||
if (is_zero(quatMag)) {
|
||||
// The code goes here if the quaternion is [0,0,0,0]. This shouldn't happen.
|
||||
INTERNAL_ERROR(AP_InternalError::error_t::flow_of_control);
|
||||
}
|
||||
|
||||
const T rquat0 = v.q1;
|
||||
const T rquat1 = v.q2;
|
||||
const T rquat2 = v.q3;
|
||||
|
Loading…
Reference in New Issue
Block a user