Skip to content

armgit / flix

Public Imported from GitHub
0

Making an ESP32-based quadcopter from scratch

Return zero rotation vector when converting neutral quaternion Previously it would return nans

Oleg Kalachev48c7135efb8b
diff --git a/flix/quaternion.h b/flix/quaternion.h
index 252212e..ab56945 100644
--- a/flix/quaternion.h
+++ b/flix/quaternion.h
@@ -84,6 +84,7 @@ public:
}
Vector toRotationVector() const {
+ if (w == 1 && x == 0 && y == 0 && z == 0) return Vector(0, 0, 0); // neutral quaternion
float angle;
Vector axis;
toAxisAngle(axis, angle);