move the code around
1 files changed, 43 insertions(+), 43 deletions(-)

M tracer.lisp
M tracer.lisp +43 -43
@@ 198,6 198,42 @@ 
         (setf (aref result i j)
               (aref m j i))))))
 
+(defun translation (x y z)
+  (make-array '(4 4) :initial-contents `((1 0 0 ,x)
+                                         (0 1 0 ,y)
+                                         (0 0 1 ,z)
+                                         (0 0 0 1))))
+
+(defun scaling (x y z)
+  (make-array '(4 4) :initial-contents `((,x  0  0 0)
+                                         ( 0 ,y  0 0)
+                                         ( 0  0 ,z 0)
+                                         ( 0  0  0  1))))
+
+(defun rotation-x (r)
+  (make-array '(4 4) :initial-contents `((1     0         0      0)
+                                         (0 ,(cos r) ,(-(sin r)) 0)
+                                         (0 ,(sin r)   ,(cos r)  0)
+                                         (0     0         0      1))))
+
+(defun rotation-y (r)
+  (make-array '(4 4) :initial-contents `((,(cos r)    0 ,(sin r) 0)
+                                         (    0       1     0    0)
+                                         (,(-(sin r)) 0 ,(cos r) 0)
+                                         (    0       0     0    1))))
+
+(defun rotation-z (r)
+  (make-array '(4 4) :initial-contents `((,(cos r) ,(- (sin r)) 0 0)
+                                         (,(sin r) ,(cos r)     0 0)
+                                         (    0        0        1 0)
+                                         (    0        0        0 1))))
+
+(defun shearing (xy xx yx yz zx zy)
+  (make-array '(4 4) :initial-contents `((  1 ,xy ,xx 0)
+                                         (,yx   1 ,yz 0)
+                                         (,zx ,zy   1 0)
+                                         (  0   0   0 1))))
+
 ;;; tests:
 (deftest adding-vectors
   (let ((a (vec3 3 -2 5))

          
@@ 261,8 297,8 @@ 
         (v2 (vec3 1 2 3)))
     (check (equalp (normalize v1) (vec3 1 0 0))
            (equalp (normalize v2) (vec3 (/ 1 (sqrt 14))
-                                          (/ 2 (sqrt 14))
-                                          (/ 3 (sqrt 14)))))))
+                                        (/ 2 (sqrt 14))
+                                        (/ 3 (sqrt 14)))))))
 
 (deftest normalize-magnitude-of-vector
   (let ((v1 (vec3 1 2 3)))

          
@@ 334,7 370,7 @@ 
 
 (deftest output-canvas-to-ppm
   (check (equalp (canvas->ppm (make-canvas :width 3 :height 5))
-"P3
+                 "P3
 3 5
 255
 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

          
@@ 400,9 436,9 @@ 0 0 0 0 0 0 0 0 0 0
                (1 8 5 3)
                (0 0 5 6))))
     (check (equalp (transpose a) #2A((0 9 1 0)
-                                            (9 8 8 0)
-                                            (3 0 5 5)
-                                            (0 8 3 6))))))
+                                     (9 8 8 0)
+                                     (3 0 5 5)
+                                     (0 8 3 6))))))
 
 (deftest transpose-identity-matrix
   (check (equalp (transpose identity-matrix)

          
@@ 539,36 575,6 @@ 0 0 0 0 0 0 0 0 0 0
   (inverse-is-reversible)
   (inverse-undoes-multiplication))
 
-(defun translation (x y z)
-  (make-array '(4 4) :initial-contents `((1 0 0 ,x)
-                                         (0 1 0 ,y)
-                                         (0 0 1 ,z)
-                                         (0 0 0 1))))
-
-(defun scaling (x y z)
-  (make-array '(4 4) :initial-contents `((,x  0  0 0)
-                                         ( 0 ,y  0 0)
-                                         ( 0  0 ,z 0)
-                                         ( 0  0  0  1))))
-
-(defun rotation-x (r)
-  (make-array '(4 4) :initial-contents `((1     0         0      0)
-                                         (0 ,(cos r) ,(-(sin r)) 0)
-                                         (0 ,(sin r)   ,(cos r)  0)
-                                         (0     0         0      1))))
-
-(defun rotation-y (r)
-  (make-array '(4 4) :initial-contents `((,(cos r)    0 ,(sin r) 0)
-                                         (    0       1     0    0)
-                                         (,(-(sin r)) 0 ,(cos r) 0)
-                                         (    0       0     0    1))))
-
-(defun rotation-z (r)
-  (make-array '(4 4) :initial-contents `((,(cos r) ,(- (sin r)) 0 0)
-                                         (,(sin r) ,(cos r)     0 0)
-                                         (    0        0        1 0)
-                                         (    0        0        0 1))))
-
 (deftest multiplying-translation-matrix
   (let ((transform (translation 5 -3 2))
         (p (point -3 4 5)))

          
@@ 673,12 679,6 @@ 0 0 0 0 0 0 0 0 0 0
     (check (not (member nil (mapcar #'float= hq-values hq-actuals)))
            (not (member nil (mapcar #'float= fq-values fq-actuals))))))
 
-(defun shearing (xy xx yx yz zx zy)
-  (make-array '(4 4) :initial-contents `((  1 ,xy ,xx 0)
-                                         (,yx   1 ,yz 0)
-                                         (,zx ,zy   1 0)
-                                         (  0   0   0 1))))
-
 (deftest shearing-transforms-x-proportionally-to-y
   (let ((transform (shearing 1 0 0 0 0 0))
         (p (point 2 3 4)))

          
@@ 757,7 757,7 @@ 0 0 0 0 0 0 0 0 0 0
 (defun tick (env proj)
   (let ((p (VECTOR+ (projectile-position proj) (projectile-velocity proj)))
         (v (VECTOR+ (projectile-velocity proj) (VECTOR+ (environment-gravity env)
-                                                    (environment-wind env)))))
+                                                        (environment-wind env)))))
     (make-projectile :position p :velocity v)))
 
 (defun projectile-tracking ()