]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/jamshred/oint/oint.factor
factor: trim using lists
[factor.git] / extra / jamshred / oint / oint.factor
index b50d9ac2fbbe1b5765413c2263b96d3afb75df56..2e772c2f22cc73289590700184357dcfd15cf95d 100644 (file)
@@ -1,6 +1,7 @@
 ! Copyright (C) 2007, 2008 Alex Chapman
 ! See http://factorcode.org/license.txt for BSD license.
-USING: accessors arrays kernel locals math math.constants math.functions math.matrices math.vectors random sequences ;
+USING: accessors arrays kernel math math.functions math.vectors
+random sequences ;
 IN: jamshred.oint
 
 ! An oint is a point with three linearly independent unit vectors
@@ -62,7 +63,7 @@ PRIVATE>
     over forward>> rotate-oint ;
 
 : random-float+- ( n -- m )
-    #! find a random float between -n/2 and n/2
+    ! find a random float between -n/2 and n/2
     dup 10000 * >integer random 10000 / swap 2 / - ;
 
 : random-turn ( oint theta -- )
@@ -81,8 +82,8 @@ PRIVATE>
     distance-vector norm ;
 
 : scalar-projection ( v1 v2 -- n )
-    #! the scalar projection of v1 onto v2
-    [ v. ] [ norm ] bi / ;
+    ! the scalar projection of v1 onto v2
+    [ vdot ] [ norm ] bi / ;
 
 : proj-perp ( u v -- w )
     dupd proj v- ;
@@ -92,8 +93,8 @@ PRIVATE>
     -rot up>> scalar-projection abs + ;
 
 :: reflect ( v n -- v' )
-    #! bounce v on a surface with normal n
-    v v n v. n n v. / 2 * n n*v v- ;
+    ! bounce v on a surface with normal n
+    v v n vdot n n vdot / 2 * n n*v v- ;
 
 : half-way ( p1 p2 -- p3 )
     over v- 2 v/n v+ ;