Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

irteus/test/geo.l: add test code for geometry functions #100

Merged
merged 2 commits into from
Jun 24, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
66 changes: 66 additions & 0 deletions irteus/test/geo.l
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
(require :unittest "lib/llib/unittest.l")

(init-unit-test)

(in-package "GEO")
(defun face-normal-vector (vertices)
(let* ((v1 (first vertices)) (v2) (vlist (rest vertices))
(v (float-vector 0 0 0))
(normal (float-vector 0 0 0)))
(while vlist
(setq v2 (pop vlist))
(v+ (v* v1 v2 v) normal normal)
(setq v1 v2))
(setq v2 (car vertices))
(v+ (v* v1 v2 v) normal normal)
(normalize-vector normal normal)) )

(defmethod polygon
(:reset-normal ()
(setq normal (face-normal-vector (rest vertices))
distance (- (v. normal (car vertices))))))
(in-package "USER")

(deftest test-body+
(let (bottom-frame
b
c1 c2 c3 c4
d1 d2 d3 d4
)
;; tekitou
;; (setq bottom-frame (make-cube 600 480 250))
(setq c1 (make-cube 650 20.4 20)
c2 (make-cube 150 20.5 20)
c3 (make-cube 600 20.4 20)
c4 (make-cube 320 20.2 20)
b (make-cube 300 480 250)
)

(send c1 :rotate (deg2rad -39) :y)
(send c2 :rotate (deg2rad 36) :y)
(send c3 :rotate (deg2rad -54) :y)
(send c4 :rotate (deg2rad 31) :y)
(send b :rotate (deg2rad -45) :y)


(send c1 :translate #f(-49.0 0 86) :world)
(send c2 :translate #f(250.0 0 248) :world)
(send c3 :translate #f(129.0 0 -35.0) :world)
(send c4 :translate #f(-175.0 0 -200.0) :world)
(send b :translate #f(-50.0 0 -50.0) :world)
(setq d1 (copy-object c1)
d2 (copy-object c2)
d3 (copy-object c3)
d4 (copy-object c4))

(send-all (list c1 c2 c3 c4) :translate #f(0 225 0) :world)
(send-all (list d1 d2 d3 d4) :translate #f(0 -225 0) :world)
(setq bottom-frame (body+ c1 b d1 c2 d2 c3 d3 c4 d4)) ;; <= here, body+ fails
(setf (get bottom-frame :face-color) :dimgray)
(setf (get bottom-frame :weight) 100)
bottom-frame
))

(run-all-tests)
(exit)