Permalink
Browse files

Much simpler 'compute-incident-edge'

  • Loading branch information...
dharmatech committed Jan 17, 2010
1 parent b163918 commit bf870ef8da12bbefec13d3b6810f7246fb42c905
Showing with 37 additions and 121 deletions.
  1. +17 −37 collide.sls
  2. +20 −84 compute-incident-edge.sls
View
@@ -113,25 +113,19 @@
(set! normal (v*n rot-b.col-2
(if (> db.y 0.0) 1 -1)))))
- (let ((front-normal #f)
- (side-normal #f)
-
- (incident-edge (vector (create-clip-vertex)
- (create-clip-vertex)))
-
- (front #f)
- (neg-side #f)
- (pos-side #f)
- (neg-edge #f)
- (pos-edge #f)
- (side #f))
+ (let ((front-normal #f)
+ (side-normal #f)
+ (incident-edge #f)
+ (front #f)
+ (neg-side #f)
+ (pos-side #f)
+ (neg-edge #f)
+ (pos-edge #f)
+ (side #f))
(case axis
((FACE-A-X)
-
- ;; (display "case FACE-A-X ")
-
(set! front-normal normal)
(set! front (+ (vec-dot pos-a front-normal) ha.x))
(set! side-normal rot-a.col-2)
@@ -140,16 +134,10 @@
(set! pos-side (+ side ha.y))
(set! neg-edge EDGE3)
(set! pos-edge EDGE1)
-
- (compute-incident-edge
- incident-edge hb pos-b rot-b front-normal)
-
- )
+ (set! incident-edge
+ (compute-incident-edge hb pos-b rot-b front-normal)))
((FACE-A-Y)
-
- ;; (display "case FACE-A-Y ")
-
(set! front-normal normal)
(set! front (+ (vec-dot pos-a front-normal) ha.y))
(set! side-normal rot-a.col-1)
@@ -158,14 +146,10 @@
(set! pos-side (+ side ha.x))
(set! neg-edge EDGE2)
(set! pos-edge EDGE4)
-
- (compute-incident-edge
- incident-edge hb pos-b rot-b front-normal))
+ (set! incident-edge
+ (compute-incident-edge hb pos-b rot-b front-normal)))
((FACE-B-X)
-
- ;; (display "case FACE-B-X ")
-
(set! front-normal (vec::neg normal))
(set! front (+ (vec-dot pos-b front-normal) hb.x))
(set! side-normal rot-b.col-2)
@@ -174,13 +158,10 @@
(set! pos-side (+ side hb.y))
(set! neg-edge EDGE3)
(set! pos-edge EDGE1)
- (compute-incident-edge
- incident-edge ha pos-a rot-a front-normal))
+ (set! incident-edge
+ (compute-incident-edge ha pos-a rot-a front-normal)))
((FACE-B-Y)
-
- ;; (display "case FACE-B-Y ")
-
(set! front-normal (vec::neg normal))
(set! front (+ (vec-dot pos-b front-normal) hb.y))
(set! side-normal rot-b.col-1)
@@ -189,9 +170,8 @@
(set! pos-side (+ side hb.x))
(set! neg-edge EDGE2)
(set! pos-edge EDGE4)
- (compute-incident-edge
- incident-edge ha pos-a rot-a front-normal))
- )
+ (set! incident-edge
+ (compute-incident-edge ha pos-a rot-a front-normal))))
(let ((clip-points-1 (vector (create-clip-vertex)
(create-clip-vertex)))
View
@@ -16,102 +16,38 @@
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
- (define (compute-incident-edge c h pos rot normal)
-
- (define i 0)
-
- (is-vector c i)
- (is-clip-vertex c.i)
- (is-vec c.i.v)
- (is-edges c.i.e)
+ (define (compute-incident-edge h pos rot normal)
(is-vec h)
- (is-mat rot)
-
- (let ((rot-t (rot.transpose)))
-
- (let ((n (vec::neg (m*v rot-t normal))))
-
- (let ((n-abs (vec::abs n)))
-
- (is-vec n)
- (is-vec n-abs)
-
- (if (> n-abs.x n-abs.y)
-
- (if (> (sign n.x) 0.0)
-
- (begin
-
- ;; (say "********** BRANCH A B **********")
-
- (set! i 0)
-
- (c.i.v.set h.x (- h.y))
- (c.i.e.in-edge-2! EDGE3)
- (c.i.e.out-edge-2! EDGE4)
-
- (set! i 1)
-
- (c.i.v.set h.x h.y)
- (c.i.e.in-edge-2! EDGE4)
- (c.i.e.out-edge-2! EDGE1))
-
- (begin
-
- ;; (say "********** BRANCH A C **********")
-
- (set! i 0)
-
- (c.i.v.set (- h.x) h.y)
- (c.i.e.in-edge-2! EDGE1)
- (c.i.e.out-edge-2! EDGE2)
-
- (set! i 1)
-
- (c.i.v.set (- h.x) (- h.y))
- (c.i.e.in-edge-2! EDGE2)
- (c.i.e.out-edge-2! EDGE3)
-
- ))
-
- (if (> (sign n.y) 0.0)
-
- (begin
-
- ;; (say "********** BRANCH D E **********")
+ (let ((n (vec::neg (m*v (mat::transpose rot) normal))))
- (set! i 0)
+ (let ((n-abs (vec::abs n)))
+
+ (is-vec n)
+ (is-vec n-abs)
- (c.i.v.set h.x h.y)
- (c.i.e.in-edge-2! EDGE4)
- (c.i.e.out-edge-2! EDGE1)
+ (define (make-incident-vertex x y in-edge-2 out-edge-2)
+ (make-clip-vertex (v+ pos (m*v rot (make-vec x y)))
+ (make-edges NO-EDGE NO-EDGE in-edge-2 out-edge-2)))
- (set! i 1)
-
- (c.i.v.set (- h.x) h.y)
- (c.i.e.in-edge-2! EDGE1)
- (c.i.e.out-edge-2! EDGE2))
+ (if (> n-abs.x n-abs.y)
- (begin
+ (if (> (sign n.x) 0.0)
- ;; (say "********** BRANCH D F **********")
+ (vector (make-incident-vertex h.x (- h.y) EDGE3 EDGE4)
+ (make-incident-vertex h.x h.y EDGE4 EDGE1))
- (set! i 0)
+ (vector (make-incident-vertex (- h.x) h.y EDGE1 EDGE2)
+ (make-incident-vertex (- h.x) (- h.y) EDGE2 EDGE3)))
- (c.i.v.set (- h.x) (- h.y))
- (c.i.e.in-edge-2! EDGE2)
- (c.i.e.out-edge-2! EDGE3)
+ (if (> (sign n.y) 0.0)
- (set! i 1)
-
- (c.i.v.set h.x (- h.y))
- (c.i.e.in-edge-2! EDGE3)
- (c.i.e.out-edge-2! EDGE4)))))))
+ (vector (make-incident-vertex h.x h.y EDGE4 EDGE1)
+ (make-incident-vertex (- h.x) h.y EDGE1 EDGE2))
- (set! i 0) (c.i.v! (v+ pos (m*v rot c.i.v)))
- (set! i 1) (c.i.v! (v+ pos (m*v rot c.i.v))))
+ (vector (make-incident-vertex (- h.x) (- h.y) EDGE2 EDGE3)
+ (make-incident-vertex h.x (- h.y) EDGE3 EDGE4)))))))
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

0 comments on commit bf870ef

Please sign in to comment.