]> gitweb.factorcode.org Git - factor.git/commitdiff
math.affine-transforms: some docs for the vocab
authorBjörn Lindqvist <bjourne@gmail.com>
Sun, 25 Feb 2018 14:11:59 +0000 (15:11 +0100)
committerBjörn Lindqvist <bjourne@gmail.com>
Tue, 27 Feb 2018 12:20:57 +0000 (13:20 +0100)
extra/math/affine-transforms/affine-transforms-docs.factor [new file with mode: 0644]
extra/math/affine-transforms/affine-transforms.factor
extra/math/affine-transforms/tags.txt

diff --git a/extra/math/affine-transforms/affine-transforms-docs.factor b/extra/math/affine-transforms/affine-transforms-docs.factor
new file mode 100644 (file)
index 0000000..f03cdd7
--- /dev/null
@@ -0,0 +1,21 @@
+! Copyright (C) 2018 Björn Lindqvist
+! See http://factorcode.org/license.txt for BSD license
+USING: help.markup help.syntax ;
+IN: math.affine-transforms
+
+ARTICLE: "math.affine-transforms" "Affine Transformations of 2d Vectors"
+"This vocab provides words for affine transformations of 2d vectors. It can sometimes be more suitable to use the words in this vocab, than setting up the affine transformation matrices manually."
+{ $examples
+  "Creates a 45 degree counter clock-wise rotation matrix and applies it to a vector:"
+  { $example
+    "USING: math.affine-transforms math.trig prettyprint ;\n45 deg>rad <rotation> { 0 4 } a.v ."
+    "{ -2.82842712474619 2.82842712474619 }"
+  }
+  "Applies a combined scaling and translation transform to a vector:"
+  { $example
+    "USING: math.affine-transforms math.trig prettyprint ;\n{ 0 -5 } <translation> 1 2  <scale>  a. { 4 3 } a.v ."
+    "{ 4.0 1.0 }"
+  }
+} ;
+
+ABOUT: "math.affine-transforms"
index 65906e0dc0446e3dcc33ff2de33c9514a9111421..96c37390637b9ff0de8c9872ad74cb51f52d8cd0 100644 (file)
@@ -1,12 +1,16 @@
 ! (c)2009 Joe Groff, see BSD license
-USING: accessors arrays combinators combinators.short-circuit kernel math math.vectors
-math.functions sequences ;
+USING: accessors arrays combinators combinators.short-circuit kernel
+math math.functions math.vectors sequences ;
 IN: math.affine-transforms
 
-TUPLE: affine-transform { x read-only } { y read-only } { origin read-only } ;
+TUPLE: affine-transform
+    { x read-only }
+    { y read-only }
+    { origin read-only } ;
 C: <affine-transform> affine-transform
 
-CONSTANT: identity-transform T{ affine-transform f { 1.0 0.0 } { 0.0 1.0 } { 0.0 0.0 } }
+CONSTANT: identity-transform T{ affine-transform f
+                                { 1.0 0.0 } { 0.0 1.0 } { 0.0 0.0 } }
 
 : axes ( a -- a' )
      [ x>> ] [ y>> ] bi { 0.0 0.0 } <affine-transform> ;
@@ -28,7 +32,8 @@ CONSTANT: identity-transform T{ affine-transform f { 1.0 0.0 } { 0.0 1.0 } { 0.0
     [ 0.0 2array ] [ 0.0 swap 2array ] bi* { 0.0 0.0 } <affine-transform> ;
 
 : center-rotation ( transform center -- transform )
-    [ [ x>> ] [ y>> ] [ ] tri ] dip [ vneg a.v ] [ v+ ] bi <affine-transform> ;
+    [ [ x>> ] [ y>> ] [ ] tri ] dip [ vneg a.v ] [ v+ ] bi
+    <affine-transform> ;
 
 : flatten-transform ( transform -- array )
     [ x>> ] [ y>> ] [ origin>> ] tri 3append ;
index ede10ab61b276dbb377d546a34593c7eee6b06f5..1df00ad995ec93d1e54400d67f579e85c02627c3 100644 (file)
@@ -1 +1,2 @@
+graphics
 math