Permalink
Browse files

add transform function and now define ship based on flast 3pyramid ro…

…tated and transformed
  • Loading branch information...
1 parent e3fcf26 commit 086ef7f6009253d3f480e3f944ed133f856ae2ea @dballard committed Jun 18, 2012
Showing with 12 additions and 2 deletions.
  1. +8 −0 math.lisp
  2. +4 −2 model.lisp
View
@@ -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)
View
@@ -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))

0 comments on commit 086ef7f

Please sign in to comment.