 (defn bezier3-pw-calc [beziers t]
   (let [i (int t)]
     (bezier3-calc (nth beziers i) (- t i))))
-
-; having duplicate adjacent points screws up the distance
-; calculations, so we need to remove them before doing the fitting
-(defn dedup-points [coords]
-  (reduce (fn [result c]
-            (if (= 0 (v2-dist (last result) c))
-              result
-              (conj result c)))
-          [] coords))
 
 (defn interpolate-points [coords desired-seg-len]
   (let [path-len (path-length coords)]

        (if (< max-error fit-error)
          [(adjust-bezier bezier coords params tan1 tan2
                          adjust-error max-adjust-iter)]
          (let [center-tan (v2-center-tangent
                             (nth coords (dec split-point))
                             (nth coords split-point)
                             (nth coords (inc split-point)))]
            (vec (concat
                   (fit-cubic
                     (subvec coords 0 (inc split-point)) tan1
                     (v2-reverse center-tan))
                   (fit-cubic
                      (subvec coords split-point) center-tan tan2)))))))))

(defn path-length [coords]
  (first (reduce

  (+ (* (:x a) (:x b))
     (* (:y a) (:y b))))

; computes the tangent of the center point b
; returns both the "leftward-pointing" and "rightward-pointing" tangents
(defn v2-center-tangents [a b c]
  (let [left-tan (v2-tangent b a)
        right-tan (v2-tangent c b)
        avg-tan (v2-add left-tan right-tan)]
    (if (zero-vector? avg-tan)
      ; if left and right tangents are exactly opposite
      ; normalization of the average would cause divide-by-zero
      ; in this case, just give the normalized left and right tangents
      [(v2-reverse left-tan) right-tan]
      (let [normed-tan (v2-normalize avg-tan)]
        [(v2-reverse normed-tan) normed-tan]))))

(defn parameter-normalize [params]
  (let [last-t (last params)]
