4. (defn project-point-to-line-fraction
"Projection of point on line (returns a real number; 0 = point is closest to v;
1 = point is closest to w; 1>f>0 - on the [v;w] segment; otherwise not on
the [v;w] segment). Returns 0 if v and w is the same point"
[point [v w]]
(let [length2 (dist2 v w)]
(if (< length2 0.00001) ; a point
0
(/ (+ (* (- (:x point) (:x v)) (- (:x w) (:x v)))
(* (- (:y point) (:y v)) (- (:y w) (:y v))))
length2))))