Skip to content

Instantly share code, notes, and snippets.

@nyuichi
Created December 9, 2012 14:22
Show Gist options
  • Select an option

  • Save nyuichi/4245166 to your computer and use it in GitHub Desktop.

Select an option

Save nyuichi/4245166 to your computer and use it in GitHub Desktop.
(let* ((p1 b)
(v1 (v- a b))
(p2 d)
(v2 (v- c d)))
(with-vector (x1 y1 z1) v1
(with-vector (x2 y2 z2) v2
(with-vector (x3 y3 z3) (v- p1 p2)
(when (<= (abs (- (+ (* x1 y2 z3) (* x2 y3 z1) (* x3 y1 z2))
(+ (* x3 y2 z1) (* y3 z2 x1) (* z3 x2 y1))))
*vector3-acceptable-error-range*)
(let ((d (- (* x1 y2) (* x2 y1))))
(break)
(if (not (zerop d))
(let ((l1 (- (/ (- (* x3 y2) (* y3 x2)) d)))
(l2 (/ (- (* x1 y3) (* y1 x3)) d)))
(break)
(if (and (<= 0 l1 1)
(<= 0 l2 1))
(v+ p1 (v* v1 l1))))))))))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment