diff --git a/math.lisp b/math.lisp index 0475ddb..6f77bfe 100644 --- a/math.lisp +++ b/math.lisp @@ -59,9 +59,17 @@ (defun scale-vector (v a) (make-array (length v) :initial-contents (loop for i across v collecting (* i a)))) +; scale points by a (defun scale-points (points a) (make-array (length points) :initial-contents (loop for v across points collecting (scale-vector v a)))) +; scale poitns by v (x y z) +(defun transform-points (points x y z) + (make-array (length points) :initial-contents + (loop for v across points collecting + (make-array 3 :initial-contents + (list (* (aref v 0) x) (* (aref v 1) y) (* (aref v 2) z)))))) + ; returns a vector with all elemts scaled to biggest 1 which is scaled to 1 ; e.x. (scale-vector (8 4 2)) -> (1 .5 .25) (defun scale-vector-1 (v) diff --git a/model.lisp b/model.lisp index 2f25832..555699a 100644 --- a/model.lisp +++ b/model.lisp @@ -107,8 +107,10 @@ (defparameter *ship-model* (make-model-3pyramid ;*3pyramid-flat-points* - (rotate-triangle (make-2d-array 4 3 *3pyramid-flat-points*) (make-rotation-matrix 0 0 0)) - :face-colors '((196 196 196) (196 196 196) (196 196 196) (32 32 32)))) + (transform-points + (rotate-triangle (make-2d-array 4 3 *3pyramid-flat-points*) (make-rotation-matrix 0 0 0)) + 4 1 3) + :face-colors '((196 196 196) (196 196 196) (196 196 196) (32 32 32)))) ;(defparameter *ship-model* ; (make-model-3pyramid '((0.0 -0.5 -1.5) (0.0 0.5 1.5) (-2.0 -0.5 1.5) (2.0 -0.5 1.5))