qanglebetween
authorJames Preiss <japreiss@usc.edu>
Sun, 10 Jun 2018 05:00:25 +0000 (22:00 -0700)
committerJames Preiss <japreiss@usc.edu>
Sun, 10 Jun 2018 05:00:25 +0000 (22:00 -0700)
math3d.h

index 6540b63..af937a9 100644 (file)
--- a/math3d.h
+++ b/math3d.h
@@ -422,6 +422,7 @@ static inline bool misnan(struct mat33 m) {
        }
        return false;
 }
+
 // set a 3x3 block within a big row-major matrix.
 // block: pointer to the upper-left element of the block in the big matrix.
 // stride: the number of columns in the big matrix.
@@ -598,6 +599,9 @@ static inline struct quat qneg(struct quat q) {
 static inline float qdot(struct quat a, struct quat b) {
        return a.x * b.x + a.y * b.y + a.z * b.z + a.w * b.w;
 }
+static inline float qanglebetween(struct quat a, struct quat b) {
+       return acosf(qdot(a, b));
+}
 // normalize a quaternion.
 // typically used to mitigate precision errors.
 static inline struct quat qnormalize(struct quat q) {