cpvslerp   xtlang


Defined in:  https://github.com/digego/extempore/tree/v0.8.9/libs/contrib/libchipmunk/cpVect.xtm

Implementation

(bind-func cpvslerp
  (lambda (v1:cpVect v2:cpVect t:cpFloat)
    (let (
        (dot (cpvdot (cpvnormalize v1) (cpvnormalize v2)))
        (omega (acos (clamp dot -1. 1.))))
      (if (< omega 0.001)
        (cpvlerp v1 v2 t)
        (let ((denom (/ 1.0 (sin omega))))
          (cpvadd
            (cpvmult v1 (* (sin (* (- 1.0 t) omega)) denom))
            (cpvmult v2 (* (sin (* t omega)) denom))))))))


Back to Index

Similar Entries

  • cpvslerpconst    xtlang