cpClosestPointOnSegment   xtlang


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

Implementation

(bind-lib libchipmunk cpMomentForCircle [cpFloat,cpFloat,cpFloat,cpFloat,cpVect])
(bind-lib libchipmunk cpAreaForCircle [cpFloat,cpFloat,cpFloat])
(bind-lib libchipmunk cpMomentForSegment [cpFloat,cpFloat,cpVect,cpVect,cpFloat])
(bind-lib libchipmunk cpAreaForSegment [cpFloat,cpVect,cpVect,cpFloat])
(bind-lib libchipmunk cpMomentForPoly [cpFloat,cpFloat,i32,cpVect*,cpVect,cpFloat])
(bind-lib libchipmunk cpAreaForPoly [cpFloat,i32,cpVect*,cpFloat])
(bind-lib libchipmunk cpCentroidForPoly [cpFloat,i32,cpVect*,cpFloat])
(bind-lib libchipmunk cpMomentForBox [cpFloat,cpFloat,cpFloat,cpFloat])
(bind-lib libchipmunk cpMomentForBox2 [cpFloat,cpFloat,cpBB])
(bind-lib libchipmunk cpConvexHull [i32,i32,cpVect*,cpVect*,i32*,cpFloat])
(bind-func cpClosestPointOnSegment
  (lambda (p:cpVect a:cpVect b:cpVect)
    (let ((delta (cpvsub a b)) (t (clamp (/ (cpvdot delta (cpvsub p b)) (cpvlengthsq delta)) 0. 1.)))
      (cpvadd b (cpvmult delta t)))))


Back to Index