     (let [m (double (/ (magnitude xyz) scale))]
       (if (and (not= m 0) (not= m 1))
         (divide xyz m)
-        xyz))))+        xyz))))
+      
+(defn perpendicular [[x y z]]
+  (if (and (zero? z) (= (- x) y))
+    (point (- (- y z)) x x)
+    (point z z (- (- x y)))))
+    
+(defn perpendicular-vectors [v]
+  (let [n (normalize v)
+        a (perpendicular n)
+        b (cross-product n a)]
+    [a b]))


(defn dot-product [^doubles as ^doubles bs]
  (reduce + (mapv * as bs)))

(defn transform-point [matrix]
  (fn [[ax ay az aw]]

  [(double (/ (+ ax bx cx) 3))
   (double (/ (+ ay by cy) 3))
   (double (/ (+ az bz cz) 3))])

(defn mid-point
  "Calculate the midpoint of a line"
