Commits

Karsten Schmidt committed c44acc3

updating ILine protocol and line2d implementation, adding new tests

  • Participants
  • Parent commits 065f059

Comments (0)

Files changed (3)

src/toxi/geom/core.clj

 
 (defprotocol ILine
   (normal [l])
+  (scale-length [l s])
   (offset-and-grow-by [line offset] [line offset scale] [line offset scale refp])
 )
 

src/toxi/geom/line2d.clj

       :vertex-count (fn[l] 2)
     }
     geom/ILine {
-      :line-normal (fn[l] (-> (:b l) (geom/sub (:a l)) geom/perpendicular geom/normalize))
+      :normal (fn[l] (-> (geom/sub (:b l) (:a l)) geom/perpendicular geom/normalize))
       :offset-and-grow-by offset-and-grow-by
       :scale-length common/scale-length
     }

test/toxi/test/geom.clj

     (is (has-endpoint? (first ce) (:a (second ce))))
     (is (not (has-endpoint? (first ce) (:b (second ce)))))
     (is (delta= (* 10 (length c)) (length cs) 0.0001))
+    (is (delta= 10 (length (scale-length a 0.1)) 0.0001))
     (is (deltav= (vec2d 500 0) (centroid cs) 0.001))
+    (is (deltav= (vec2d 0 1) (normal a) 0.001))
     ))
 
 (deftest test-polygon2d