]> gitweb.factorcode.org Git - factor.git/blobdiff - extra/math/matrices/simd/simd.factor
factor: trim using lists
[factor.git] / extra / math / matrices / simd / simd.factor
index 26ad8bb4d7549fb7eadf946bbe23284d5a48e63f..4ee38a3d003caf8b8fba343d460e55658fe8f2a2 100644 (file)
@@ -1,7 +1,9 @@
-! (c)Joe Groff bsd license
-USING: accessors classes.struct fry generalizations kernel locals
-math math.combinatorics math.functions math.matrices.simd math.vectors
-math.vectors.simd math.quaternions sequences sequences.private specialized-arrays
+! Copyright (C) 2009, 2011 Joe Groff.
+! See http://factorcode.org/license.txt for BSD license.
+USING: accessors classes.struct generalizations kernel
+math math.functions math.matrices.simd math.vectors
+math.vectors.simd math.quaternions sequences
+sequences.generalizations sequences.private specialized-arrays
 typed ;
 FROM: sequences.private => nth-unsafe ;
 FROM: math.quaternions.private => (q*sign) ;
@@ -44,7 +46,7 @@ M: matrix4 new-sequence 2drop matrix4 (struct) ; inline
 
 : map-columns ( ... a quot: ( ... col -- ... newcol ) -- ... c )
     '[ columns _ 4 napply ] make-matrix4 ; inline
-    
+
 PRIVATE>
 
 TYPED: m4+ ( a: matrix4 b: matrix4 -- c: matrix4 ) [ v+ ] 2map-columns ;
@@ -67,12 +69,12 @@ TYPED:: m4. ( a: matrix4 b: matrix4 -- c: matrix4 )
         b3 first  a1 n*v :> c3a
         b4 first  a1 n*v :> c4a
 
-        b1 second a2 n*v c1a v+ :> c1b 
+        b1 second a2 n*v c1a v+ :> c1b
         b2 second a2 n*v c2a v+ :> c2b
         b3 second a2 n*v c3a v+ :> c3b
         b4 second a2 n*v c4a v+ :> c4b
 
-        b1 third  a3 n*v c1b v+ :> c1c 
+        b1 third  a3 n*v c1b v+ :> c1c
         b2 third  a3 n*v c2b v+ :> c2c
         b3 third  a3 n*v c3b v+ :> c3c
         b4 third  a3 n*v c4b v+ :> c4c
@@ -85,14 +87,14 @@ TYPED:: m4. ( a: matrix4 b: matrix4 -- c: matrix4 )
 
 TYPED:: m4.v ( m: matrix4 v: float-4 -- v': float-4 )
     m columns :> ( m1 m2 m3 m4 )
-    
+
     v first  m1 n*v
     v second m2 n*v v+
     v third  m3 n*v v+
     v fourth m4 n*v v+ ;
 
 TYPED:: v.m4 ( v: float-4 m: matrix4 -- c: float-4 )
-    m columns [ v v. ] 4 napply float-4-boa ;
+    m columns [ v vdot ] 4 napply float-4-boa ;
 
 CONSTANT: identity-matrix4
     S{ matrix4 f
@@ -143,7 +145,7 @@ TYPED: transpose-matrix4 ( matrix: matrix4 -- matrix: matrix4 )
 TYPED: translation-matrix4 ( offset: float-4 -- matrix: matrix4 )
     [
         linear>homogeneous
-        [ 
+        [
             float-4{ 1.0 0.0 0.0 0.0 }
             float-4{ 0.0 1.0 0.0 0.0 }
             float-4{ 0.0 0.0 1.0 0.0 }
@@ -188,13 +190,13 @@ TYPED:: rotation-matrix4 ( axis: float-4 theta: float -- matrix: matrix4 )
     triangle-a triangle-b v- :> triangle-hi
 
     diagonal triangle-hi triangle-lo (rotation-matrix4) ;
-    
+
 TYPED:: frustum-matrix4 ( xy: float-4 near: float far: float -- matrix: matrix4 )
     [
         near near near far + 2 near far * * float-4-boa ! num
         float-4{ t t f f } xy near far - float-4-with v? ! denom
         v/ :> fov
-        
+
         float-4{ 0.0 -1.0 0.0 0.0 } :> negone
 
         fov vmerge-diagonal