(bind-func cpBBSegmentQuery
(lambda (bb:cpBB a:cpVect b:cpVect)
(let ((delta (cpvsub b a)) (tmin (- 0. CPFLOAT_MAX)) (tmax CPFLOAT_MAX))
(if (<> (tref delta 0) 0.)
(let (
(t1 (/ (- (tref bb 0) (tref a 0)) (tref delta 0)))
(t2 (/ (- (tref bb 2) (tref a 0)) (tref delta 0))))
(set! tmin (max tmin (min t1 t2)))
(set! tmax (min tmax (max t1 t2)))))
(if (<> (tref delta 1) 0.)
(let (
(t1 (/ (- (tref bb 1) (tref a 1)) (tref delta 1)))
(t2 (/ (- (tref bb 3) (tref a 1)) (tref delta 1))))
(set! tmin (max tmin (min t1 t2)))
(set! tmax (min tmax (max t1 t2)))))
(if (and (<= tmin tmax) (<= 0. tmax) (<= tmin 1.))
(max tmin 0.)
(CPFLOAT_MAX)))))