cpBBWrapVect   xtlang


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

Implementation

(bind-func cpBBWrapVect
  (lambda (bb:cpBB v:cpVect)
    (let (
        (dx (fabs (- (tref bb 2) (tref bb 0))))
        (modx (fmod (- (tref v 0) (tref bb 0)) dx))
        (x modx)
        (dy (fabs (- (tref bb 3) (tref bb 1))))
        (mody (fmod (- (tref v 1) (tref bb 1)) dx))
        (y mody))
      (if (< modx 0.)
        (set! x (+ x dx)))
      (if (< mody 0.)
        (set! y (+ y dy)))
      (cpVect_val (+ x (tref bb 0)) (+ y (tref bb 1))))))


Back to Index