        (if (zero? mag)
          nullv
          (map #(* (/ % mag) m) v)))))
+
+(defn project
+  "Calculates the vector projection of a in the direction of b."
+  [a b]
+  (let [scalar (apply + (map * a (direction b)))]
+    (direction b scalar)))
 
 (defn direction-from
   "Given two vectors, returns a unit vector representing the direction from the

  [v]
  (Math/sqrt (apply + (map #(* % %) v))))

(defn direction
  "Given a vector, returns a unit vector in the same direction, optionally
scaled."

  [p v all]
  (let [a (calc-accel p all)
        v (map + v a)
        p (map + p v)]
    [p v a]))

