vaquat   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/core/math.xtm

Implementation

(bind-func vaquat
  "@param v - axis vector (3d)
@param angle - angle in radians
@param result - quaternion (4d vector xyzw) in which to store the result"
  (lambda (v:double* angle:double result:double*)
    (let ((m (vmag v 3))
          (s (/ (sin (* 0.5 angle)) m)))
      (pfill! result
              (* (pref v 0) s) (* (pref v 1) s) (* (pref v 2) s)
              (cos (* 0.5 angle)))
      void)))


Back to Index

Similar Entries