20 { 1 -1 -5 } cut-solid
\r
21 { -1 -1 -21 } cut-solid
\r
22 { -1 0 -12 } cut-solid
\r
23 { 1 2 16 } cut-solid
\r
25 : solid1 ( -- solid )
\r
29 { 1 -1 -5 } cut-solid
\r
30 { -1 -1 -21 } cut-solid
\r
31 { -1 0 -12 } cut-solid
\r
32 { 1 2 16 } cut-solid
\r
36 : solid2 ( -- solid )
\r
40 { -1 1 -10 } cut-solid
\r
41 { -1 -1 -28 } cut-solid
\r
42 { 1 0 13 } cut-solid
\r
43 ! { 1 2 16 } cut-solid
\r
48 : solid3 ( -- solid )
\r
53 { 1 0 16 } cut-solid
\r
54 { -1 0 -36 } cut-solid
\r
55 { 0 1 1 } cut-solid
\r
56 { 0 -1 -17 } cut-solid
\r
57 ! { 1 2 16 } cut-solid
\r
63 : solid4 ( -- solid )
\r
68 { 1 0 21 } cut-solid
\r
69 { -1 0 -36 } cut-solid
\r
70 { 0 1 1 } cut-solid
\r
71 { 0 -1 -17 } cut-solid
\r
76 : solid5 ( -- solid )
\r
81 { 1 0 6 } cut-solid
\r
82 { -1 0 -17 } cut-solid
\r
83 { 0 1 17 } cut-solid
\r
84 { 0 -1 -19 } cut-solid
\r
89 : solid7 ( -- solid )
\r
94 { 1 0 38 } cut-solid
\r
95 { 1 -5 -66 } cut-solid
\r
96 { -2 1 -75 } cut-solid
\r
101 : solid6s ( -- seq )
\r
102 solid3 clone solid2 clone subtract
\r
105 : space1 ( -- space )
\r
108 ! solid3 suffix-solids
\r
109 solid1 suffix-solids
\r
110 solid2 suffix-solids
\r
111 ! solid6s [ suffix-solids ] each
\r
112 solid4 suffix-solids
\r
113 ! solid5 suffix-solids
\r
114 solid7 suffix-solids
\r
115 { 1 1 1 } >>ambient-color
\r
117 { -100 -100 } >>position
\r
118 { 0.2 0.7 0.1 } >>color
\r
122 : space2 ( -- space )
\r
125 ! 4cube suffix-solids
\r
126 { 1 1 1 } >>ambient-color
\r
128 { -100 -100 } >>position
\r
129 { 0.2 0.7 0.1 } >>color
\r
139 ! { 0 0 0.984807753012208 -0.1736481776669303 }
\r
140 ! { 0 0 0.1736481776669303 0.984807753012208 }
\r
143 ! ------------------------------------------------------------
\r
145 [ { 1 2 5 } ] [ { 1 2 3 } 2 constant+ ] unit-test
\r
147 ! ------------------------------------------------------------
\r
149 [ { 1 -1 0 } ] [ { 1 -1 -5 } { 3 -2 } translate ] unit-test
\r
151 ! ------------------------------------------------------------
\r
153 [ { -1 -1 -5 21.0 } ] [ { -1 -1 -5 21 }
\r
160 ! ------------------------------------------------------------
\r
161 ! compare-nleft-to-identity-matrix
\r
167 3 compare-nleft-to-identity-matrix
\r
171 { { 1 0 0 } { 0 1 0 } { 0 0 0 } }
\r
172 3 compare-nleft-to-identity-matrix
\r
176 { { 2 0 0 } { 0 1 0 } { 0 0 1 } }
\r
177 3 compare-nleft-to-identity-matrix
\r
179 ! ------------------------------------------------------------
\r
183 { 0 0 1 } } 3 valid-solution?
\r
189 { 0 0 1 0 } } 3 valid-solution?
\r
194 { 0 0 0 1 } } 3 valid-solution?
\r
200 { 0 0 1 0 } } 2 valid-solution?
\r
203 ! ------------------------------------------------------------
\r
204 [ 3 ] [ { 1 2 3 } last ] unit-test
\r
206 [ { 1 2 5 } ] [ { 1 2 3 } dup [ 2 + ] change-last ] unit-test
\r
208 ! ------------------------------------------------------------
\r
211 { 1 -1 -5 } { 2 7 } position-point
\r
214 ! ------------------------------------------------------------
\r
217 ! TODO construire un exemple
\r
220 ! ------------------------------------------------------------
\r
223 ! ------------------------------------------------------------
\r
225 ! deux cas de tests, avec solution et sans solution
\r
228 [ { { 1 -1 -5 } { 1 2 16 } } intersect-hyperplanes ]
\r
232 [ { { 1 -1 -5 } { 1 2 16 } { -1 -1 -21 } } intersect-hyperplanes ]
\r
236 [ { { 1 0 -5 } { 1 0 16 } } intersect-hyperplanes ]
\r
239 ! ------------------------------------------------------------
\r
240 ! point-inside-halfspace
\r
241 [ t ] [ { 1 -1 -5 } { 0 0 } point-inside-halfspace? ]
\r
243 [ f ] [ { 1 -1 -5 } { 8 13 } point-inside-halfspace? ]
\r
245 [ t ] [ { 1 -1 -5 } { 8 13 } point-inside-or-on-halfspace? ]
\r
249 ! ------------------------------
\r
252 [ 1 ] [ 0 >pv solid1 solid2 order-solid ] unit-test
\r
253 [ -1 ] [ 0 >pv solid2 solid1 order-solid ] unit-test
\r
254 [ f ] [ 1 >pv solid1 solid2 order-solid ] unit-test
\r
255 [ f ] [ 1 >pv solid2 solid1 order-solid ] unit-test
\r
259 [ { { 13 15 } { 15 13 } { 13 13 } } ]
\r
260 [ 0 >pv solid2 solid1 clip-solid first corners>> ] unit-test
\r
262 solid1 corners>> '[ _ ]
\r
263 [ 0 >pv solid1 solid1 clip-solid first corners>> ] unit-test
\r
265 solid1 corners>> '[ _ ]
\r
266 [ 0 >pv solid1 solid2 clip-solid first corners>> ] unit-test
\r
268 solid1 corners>> '[ _ ]
\r
269 [ 1 >pv solid1 solid2 clip-solid first corners>> ] unit-test
\r
270 solid2 corners>> '[ _ ]
\r
271 [ 1 >pv solid2 solid1 clip-solid first corners>> ] unit-test
\r
276 { { 13 15 } { 15 13 } { 13 13 } }
\r
277 { { 16 17 } { 16 13 } { 36 17 } { 36 13 } }
\r
278 { { 16 1 } { 16 2 } { 36 1 } { 36 2 } }
\r
280 ] [ 0 >pv solid2 solid3 2array
\r
281 solid1 (solids-silhouette-subtract)
\r
288 { { 8 13 } { 2 7 } { 12 9 } { 12 2 } }
\r
289 { { 13 15 } { 15 13 } { 13 13 } }
\r
290 { { 16 17 } { 16 15 } { 36 17 } { 36 15 } }
\r
291 { { 16 1 } { 16 2 } { 36 1 } { 36 2 } }
\r
294 0 >pv <space> solid1 suffix-solids
\r
295 solid2 suffix-solids
\r
296 solid3 suffix-solids
\r
297 remove-hidden-solids
\r
298 solids>> [ corners>> ] map
\r
303 ! <light> { 0.2 0.3 0.4 } >>color { 1 -1 1 } >>direction suffix
\r
304 ! <light> { 0.4 0.3 0.1 } >>color { -1 -1 -1 } >>direction suffix
\r
306 ! { 0.1 0.1 0.1 } suffix ! ambient color
\r
307 ! { 0.23 0.32 0.17 } suffix ! solid color
\r
308 ! solid3 faces>> first
\r
310 ! enlight-projection
\r