8 double quat_norm2 = (q.
w * q.
w) + (q.
x * q.
x) + (q.
y * q.
y) + (q.
z * q.
z);
9 if (std::abs(quat_norm2 - 1.0) > std::numeric_limits<double>::epsilon())
11 double mult = 1.0 / std::sqrt(quat_norm2);
19 double sinr_cosp = 2 * (q.
w * q.
x + q.
y * q.
z);
20 double cosr_cosp = 1 - 2 * (q.
x * q.
x + q.
y * q.
y);
21 rpy.
roll = std::atan2(sinr_cosp, cosr_cosp);
24 double sinp = 2 * (q.
w * q.
y - q.
z * q.
x);
25 if (std::abs(sinp) >= 1)
31 rpy.
pitch = std::asin(sinp);
35 double siny_cosp = 2 * (q.
w * q.
z + q.
x * q.
y);
36 double cosy_cosp = 1 - 2 * (q.
y * q.
y + q.
z * q.
z);
37 rpy.
yaw = std::atan2(siny_cosp, cosy_cosp);