Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Much simpler 'compute-incident-edge'

  • Loading branch information...
commit bf870ef8da12bbefec13d3b6810f7246fb42c905 1 parent b163918
dharmatech authored January 17, 2010
54  collide.sls
@@ -113,25 +113,19 @@
113 113
 			(set!            normal (v*n rot-b.col-2
114 114
 						     (if (> db.y 0.0) 1 -1)))))
115 115
 
116  
-		  (let ((front-normal #f)
117  
-			(side-normal  #f)
118  
-
119  
-			(incident-edge (vector (create-clip-vertex)
120  
-                                               (create-clip-vertex)))
121  
-
122  
-			(front #f)
123  
-			(neg-side #f)
124  
-			(pos-side #f)
125  
-			(neg-edge #f)
126  
-			(pos-edge #f)
127  
-			(side #f))
  116
+		  (let ((front-normal  #f)
  117
+			(side-normal   #f)
  118
+			(incident-edge #f)
  119
+			(front         #f)
  120
+			(neg-side      #f)
  121
+			(pos-side      #f)
  122
+			(neg-edge      #f)
  123
+			(pos-edge      #f)
  124
+			(side          #f))
128 125
 
129 126
 		    (case axis
130 127
 
131 128
 		      ((FACE-A-X)
132  
-
133  
-		       ;; (display "case FACE-A-X  ")
134  
-		       
135 129
 		       (set! front-normal normal)
136 130
 		       (set! front        (+ (vec-dot pos-a front-normal) ha.x))
137 131
 		       (set! side-normal  rot-a.col-2)
@@ -140,16 +134,10 @@
140 134
 		       (set! pos-side     (+ side ha.y))
141 135
 		       (set! neg-edge     EDGE3)
142 136
 		       (set! pos-edge     EDGE1)
143  
-
144  
-		       (compute-incident-edge
145  
-			incident-edge hb pos-b rot-b front-normal)
146  
-		       
147  
-		       )
  137
+                       (set! incident-edge
  138
+                             (compute-incident-edge hb pos-b rot-b front-normal)))
148 139
 
149 140
 		      ((FACE-A-Y)
150  
-
151  
-		       ;; (display  "case FACE-A-Y  ")
152  
-		       
153 141
 		       (set! front-normal normal)
154 142
 		       (set! front        (+ (vec-dot pos-a front-normal) ha.y))
155 143
 		       (set! side-normal  rot-a.col-1)
@@ -158,14 +146,10 @@
158 146
 		       (set! pos-side     (+ side ha.x))
159 147
 		       (set! neg-edge     EDGE2)
160 148
 		       (set! pos-edge     EDGE4)
161  
-
162  
-		       (compute-incident-edge
163  
-			incident-edge hb pos-b rot-b front-normal))
  149
+                       (set! incident-edge
  150
+                             (compute-incident-edge hb pos-b rot-b front-normal)))
164 151
 
165 152
 		      ((FACE-B-X)
166  
-
167  
-		       ;; (display "case FACE-B-X  ")
168  
-
169 153
 		       (set! front-normal (vec::neg normal))
170 154
 		       (set! front        (+ (vec-dot pos-b front-normal) hb.x))
171 155
 		       (set! side-normal  rot-b.col-2)
@@ -174,13 +158,10 @@
174 158
 		       (set! pos-side     (+    side  hb.y))
175 159
 		       (set! neg-edge     EDGE3)
176 160
 		       (set! pos-edge     EDGE1)
177  
-		       (compute-incident-edge
178  
-			incident-edge ha pos-a rot-a front-normal))
  161
+                       (set! incident-edge
  162
+                             (compute-incident-edge ha pos-a rot-a front-normal)))
179 163
 
180 164
 		      ((FACE-B-Y)
181  
-
182  
-		       ;; (display "case FACE-B-Y  ")
183  
-
184 165
 		       (set! front-normal (vec::neg normal))
185 166
 		       (set! front        (+ (vec-dot pos-b front-normal) hb.y))
186 167
 		       (set! side-normal  rot-b.col-1)
@@ -189,9 +170,8 @@
189 170
 		       (set! pos-side     (+    side  hb.x))
190 171
 		       (set! neg-edge     EDGE2)
191 172
 		       (set! pos-edge     EDGE4)
192  
-		       (compute-incident-edge
193  
-			incident-edge ha pos-a rot-a front-normal))
194  
-		      )
  173
+		       (set! incident-edge
  174
+                             (compute-incident-edge ha pos-a rot-a front-normal))))
195 175
 		    
196 176
 		    (let ((clip-points-1 (vector (create-clip-vertex)
197 177
 						 (create-clip-vertex)))
104  compute-incident-edge.sls
@@ -16,102 +16,38 @@
16 16
 
17 17
   ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
18 18
 
19  
-  (define (compute-incident-edge c h pos rot normal)
20  
-
21  
-    (define i 0)
22  
-
23  
-    (is-vector      c i)
24  
-    (is-clip-vertex c.i)
25  
-    (is-vec         c.i.v)
26  
-    (is-edges       c.i.e)
  19
+  (define (compute-incident-edge h pos rot normal)
27 20
 
28 21
     (is-vec h)
29 22
 
30  
-    (is-mat rot)
31  
-
32  
-    (let ((rot-t (rot.transpose)))
33  
-
34  
-      (let ((n (vec::neg (m*v rot-t normal))))
35  
-
36  
-	(let ((n-abs (vec::abs n)))
37  
-	  
38  
-	  (is-vec n)
39  
-	  (is-vec n-abs)
40  
-
41  
-	  (if (> n-abs.x n-abs.y)
42  
-
43  
-	      (if (> (sign n.x) 0.0)
44  
-
45  
-		  (begin
46  
-
47  
-		    ;; (say "********** BRANCH A B **********")
48  
-
49  
-		    (set! i 0)
50  
-
51  
-		    (c.i.v.set h.x (- h.y))
52  
-		    (c.i.e.in-edge-2!  EDGE3)
53  
-		    (c.i.e.out-edge-2! EDGE4)
54  
-
55  
-		    (set! i 1)
56  
-		    
57  
-		    (c.i.v.set h.x h.y)
58  
-		    (c.i.e.in-edge-2!  EDGE4)
59  
-		    (c.i.e.out-edge-2! EDGE1))
60  
-
61  
-		  (begin
62  
-
63  
-		    ;; (say "********** BRANCH A C **********")
64  
-
65  
-		    (set! i 0)
66  
-
67  
-		    (c.i.v.set (- h.x) h.y)
68  
-		    (c.i.e.in-edge-2!  EDGE1)
69  
-		    (c.i.e.out-edge-2! EDGE2)
70  
-
71  
-		    (set! i 1)
72  
-		    
73  
-		    (c.i.v.set (- h.x) (- h.y))
74  
-		    (c.i.e.in-edge-2!  EDGE2)
75  
-		    (c.i.e.out-edge-2! EDGE3)
76  
-
77  
-		    ))
78  
-
79  
-	      (if (> (sign n.y) 0.0)
80  
-
81  
-		  (begin
82  
-
83  
-		    ;; (say "********** BRANCH D E **********")
  23
+    (let ((n (vec::neg (m*v (mat::transpose rot) normal))))
84 24
 
85  
-		    (set! i 0)
  25
+      (let ((n-abs (vec::abs n)))
  26
+        
  27
+        (is-vec n)
  28
+        (is-vec n-abs)
86 29
 
87  
-		    (c.i.v.set h.x h.y)
88  
-		    (c.i.e.in-edge-2!  EDGE4)
89  
-		    (c.i.e.out-edge-2! EDGE1)
  30
+        (define (make-incident-vertex x y in-edge-2 out-edge-2)
  31
+          (make-clip-vertex (v+ pos (m*v rot (make-vec x y)))
  32
+                            (make-edges NO-EDGE NO-EDGE in-edge-2 out-edge-2)))
90 33
 
91  
-		    (set! i 1)
92  
-		    
93  
-		    (c.i.v.set (- h.x) h.y)
94  
-		    (c.i.e.in-edge-2!  EDGE1)
95  
-		    (c.i.e.out-edge-2! EDGE2))
  34
+        (if (> n-abs.x n-abs.y)
96 35
 
97  
-		  (begin
  36
+            (if (> (sign n.x) 0.0)
98 37
 
99  
-		    ;; (say "********** BRANCH D F **********")
  38
+                (vector (make-incident-vertex    h.x  (- h.y) EDGE3 EDGE4)
  39
+                        (make-incident-vertex    h.x     h.y  EDGE4 EDGE1))
100 40
 
101  
-		    (set! i 0)
  41
+                (vector (make-incident-vertex (- h.x)    h.y  EDGE1 EDGE2)
  42
+                        (make-incident-vertex (- h.x) (- h.y) EDGE2 EDGE3)))
102 43
 
103  
-		    (c.i.v.set (- h.x) (- h.y))
104  
-		    (c.i.e.in-edge-2!  EDGE2)
105  
-		    (c.i.e.out-edge-2! EDGE3)
  44
+            (if (> (sign n.y) 0.0)
106 45
 
107  
-		    (set! i 1)
108  
-		    
109  
-		    (c.i.v.set h.x (- h.y))
110  
-		    (c.i.e.in-edge-2!  EDGE3)
111  
-		    (c.i.e.out-edge-2! EDGE4)))))))
  46
+                (vector (make-incident-vertex    h.x     h.y  EDGE4 EDGE1)
  47
+                        (make-incident-vertex (- h.x)    h.y  EDGE1 EDGE2))
112 48
 
113  
-    (set! i 0) (c.i.v! (v+ pos (m*v rot c.i.v)))
114  
-    (set! i 1) (c.i.v! (v+ pos (m*v rot c.i.v))))
  49
+                (vector (make-incident-vertex (- h.x) (- h.y) EDGE2 EDGE3)
  50
+                        (make-incident-vertex    h.x  (- h.y) EDGE3 EDGE4)))))))
115 51
 
116 52
   ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
117 53
 

0 notes on commit bf870ef

Please sign in to comment.
Something went wrong with that request. Please try again.