Coverage for colour/geometry/tests/test_vertices.py: 100%
52 statements
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
« prev ^ index » next coverage.py v7.11.0, created at 2025-11-15 19:01 +1300
1"""Define the unit tests for the :mod:`colour.geometry.vertices` module."""
3from __future__ import annotations
5import numpy as np
6import pytest
8from colour.constants import TOLERANCE_ABSOLUTE_TESTS
9from colour.geometry import (
10 MAPPING_PLANE_TO_AXIS,
11 primitive_vertices_cube_mpl,
12 primitive_vertices_grid_mpl,
13 primitive_vertices_quad_mpl,
14 primitive_vertices_sphere,
15)
17__author__ = "Colour Developers"
18__copyright__ = "Copyright 2013 Colour Developers"
19__license__ = "BSD-3-Clause - https://opensource.org/licenses/BSD-3-Clause"
20__maintainer__ = "Colour Developers"
21__email__ = "colour-developers@colour-science.org"
22__status__ = "Production"
24__all__ = [
25 "TestPrimitiveVerticesQuadMpl",
26 "TestPrimitiveVerticesGridMpl",
27 "TestPrimitiveVerticesCubeMpl",
28 "TestPrimitiveVerticesSphere",
29]
32class TestPrimitiveVerticesQuadMpl:
33 """
34 Define :func:`colour.geometry.vertices.primitive_vertices_quad_mpl`
35 definition unit tests methods.
36 """
38 def test_primitive_vertices_quad_mpl(self) -> None:
39 """
40 Test :func:`colour.geometry.vertices.primitive_vertices_quad_mpl`
41 definition.
42 """
44 np.testing.assert_allclose(
45 primitive_vertices_quad_mpl(),
46 np.array([[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]),
47 atol=TOLERANCE_ABSOLUTE_TESTS,
48 )
50 np.testing.assert_allclose(
51 primitive_vertices_quad_mpl(axis="+y"),
52 np.array([[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]),
53 atol=TOLERANCE_ABSOLUTE_TESTS,
54 )
56 np.testing.assert_allclose(
57 primitive_vertices_quad_mpl(axis="+x"),
58 np.array([[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 0, 1]]),
59 atol=TOLERANCE_ABSOLUTE_TESTS,
60 )
62 np.testing.assert_allclose(
63 primitive_vertices_quad_mpl(
64 width=0.2,
65 height=0.4,
66 depth=0.6,
67 origin=np.array([0.2, 0.4]),
68 axis="+z",
69 ),
70 np.array(
71 [
72 [0.2, 0.4, 0.6],
73 [0.4, 0.4, 0.6],
74 [0.4, 0.8, 0.6],
75 [0.2, 0.8, 0.6],
76 ]
77 ),
78 atol=TOLERANCE_ABSOLUTE_TESTS,
79 )
81 np.testing.assert_allclose(
82 primitive_vertices_quad_mpl(
83 width=-0.2,
84 height=-0.4,
85 depth=-0.6,
86 origin=np.array([-0.2, -0.4]),
87 axis="+z",
88 ),
89 np.array(
90 [
91 [-0.2, -0.4, -0.6],
92 [-0.4, -0.4, -0.6],
93 [-0.4, -0.8, -0.6],
94 [-0.2, -0.8, -0.6],
95 ]
96 ),
97 atol=TOLERANCE_ABSOLUTE_TESTS,
98 )
100 for plane in ("xy", "xz", "yz"):
101 np.testing.assert_allclose(
102 primitive_vertices_quad_mpl(axis=plane),
103 primitive_vertices_quad_mpl(axis=MAPPING_PLANE_TO_AXIS[plane]),
104 atol=TOLERANCE_ABSOLUTE_TESTS,
105 )
107 pytest.raises(ValueError, lambda: primitive_vertices_quad_mpl(axis="Undefined"))
110class TestPrimitiveVerticesGridMpl:
111 """
112 Define :func:`colour.geometry.vertices.primitive_vertices_grid_mpl`
113 definition unit tests methods.
114 """
116 def test_primitive_vertices_grid_mpl(self) -> None:
117 """
118 Test :func:`colour.geometry.vertices.primitive_vertices_grid_mpl`
119 definition.
120 """
122 np.testing.assert_allclose(
123 primitive_vertices_grid_mpl(),
124 np.array([[[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]]),
125 atol=TOLERANCE_ABSOLUTE_TESTS,
126 )
128 np.testing.assert_allclose(
129 primitive_vertices_grid_mpl(axis="+y"),
130 np.array([[[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]]),
131 atol=TOLERANCE_ABSOLUTE_TESTS,
132 )
134 np.testing.assert_allclose(
135 primitive_vertices_grid_mpl(axis="+x"),
136 np.array([[[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 0, 1]]]),
137 atol=TOLERANCE_ABSOLUTE_TESTS,
138 )
140 np.testing.assert_allclose(
141 primitive_vertices_grid_mpl(
142 width=0.2,
143 height=0.4,
144 depth=0.6,
145 width_segments=1,
146 height_segments=2,
147 origin=np.array([0.2, 0.4]),
148 axis="+z",
149 ),
150 np.array(
151 [
152 [
153 [0.20000000, 0.40000000, 0.60000000],
154 [0.40000000, 0.40000000, 0.60000000],
155 [0.40000000, 0.60000000, 0.60000000],
156 [0.20000000, 0.60000000, 0.60000000],
157 ],
158 [
159 [0.20000000, 0.60000000, 0.60000000],
160 [0.40000000, 0.60000000, 0.60000000],
161 [0.40000000, 0.80000000, 0.60000000],
162 [0.20000000, 0.80000000, 0.60000000],
163 ],
164 ]
165 ),
166 atol=TOLERANCE_ABSOLUTE_TESTS,
167 )
169 np.testing.assert_allclose(
170 primitive_vertices_grid_mpl(
171 width=-0.2,
172 height=-0.4,
173 depth=-0.6,
174 width_segments=1,
175 height_segments=2,
176 origin=np.array([-0.2, -0.4]),
177 axis="+z",
178 ),
179 np.array(
180 [
181 [
182 [-0.20000000, -0.40000000, -0.60000000],
183 [-0.40000000, -0.40000000, -0.60000000],
184 [-0.40000000, -0.60000000, -0.60000000],
185 [-0.20000000, -0.60000000, -0.60000000],
186 ],
187 [
188 [-0.20000000, -0.60000000, -0.60000000],
189 [-0.40000000, -0.60000000, -0.60000000],
190 [-0.40000000, -0.80000000, -0.60000000],
191 [-0.20000000, -0.80000000, -0.60000000],
192 ],
193 ]
194 ),
195 atol=TOLERANCE_ABSOLUTE_TESTS,
196 )
199class TestPrimitiveVerticesCubeMpl:
200 """
201 Define :func:`colour.geometry.vertices.primitive_vertices_cube_mpl`
202 definition unit tests methods.
203 """
205 def test_primitive_vertices_cube_mpl(self) -> None:
206 """
207 Test :func:`colour.geometry.vertices.primitive_vertices_cube_mpl`
208 definition.
209 """
211 np.testing.assert_allclose(
212 primitive_vertices_cube_mpl(),
213 np.array(
214 [
215 [
216 [0, 0, 0],
217 [1, 0, 0],
218 [1, 1, 0],
219 [0, 1, 0],
220 ],
221 [
222 [0, 0, 1],
223 [1, 0, 1],
224 [1, 1, 1],
225 [0, 1, 1],
226 ],
227 [
228 [0, 0, 0],
229 [1, 0, 0],
230 [1, 0, 1],
231 [0, 0, 1],
232 ],
233 [
234 [0, 1, 0],
235 [1, 1, 0],
236 [1, 1, 1],
237 [0, 1, 1],
238 ],
239 [
240 [0, 0, 0],
241 [0, 1, 0],
242 [0, 1, 1],
243 [0, 0, 1],
244 ],
245 [
246 [1, 0, 0],
247 [1, 1, 0],
248 [1, 1, 1],
249 [1, 0, 1],
250 ],
251 ]
252 ),
253 atol=TOLERANCE_ABSOLUTE_TESTS,
254 )
256 np.testing.assert_allclose(
257 primitive_vertices_cube_mpl(planes=["+x"]),
258 np.array([[[1, 0, 0], [1, 1, 0], [1, 1, 1], [1, 0, 1]]]),
259 atol=TOLERANCE_ABSOLUTE_TESTS,
260 )
262 np.testing.assert_allclose(
263 primitive_vertices_cube_mpl(planes=["-x"]),
264 np.array([[[0, 0, 0], [0, 1, 0], [0, 1, 1], [0, 0, 1]]]),
265 atol=TOLERANCE_ABSOLUTE_TESTS,
266 )
268 np.testing.assert_allclose(
269 primitive_vertices_cube_mpl(planes=["+y"]),
270 np.array([[[0, 1, 0], [1, 1, 0], [1, 1, 1], [0, 1, 1]]]),
271 atol=TOLERANCE_ABSOLUTE_TESTS,
272 )
274 np.testing.assert_allclose(
275 primitive_vertices_cube_mpl(planes=["-y"]),
276 np.array([[[0, 0, 0], [1, 0, 0], [1, 0, 1], [0, 0, 1]]]),
277 atol=TOLERANCE_ABSOLUTE_TESTS,
278 )
280 np.testing.assert_allclose(
281 primitive_vertices_cube_mpl(planes=["+z"]),
282 np.array([[[0, 0, 1], [1, 0, 1], [1, 1, 1], [0, 1, 1]]]),
283 atol=TOLERANCE_ABSOLUTE_TESTS,
284 )
286 np.testing.assert_allclose(
287 primitive_vertices_cube_mpl(planes=["-z"]),
288 np.array([[[0, 0, 0], [1, 0, 0], [1, 1, 0], [0, 1, 0]]]),
289 atol=TOLERANCE_ABSOLUTE_TESTS,
290 )
292 np.testing.assert_allclose(
293 primitive_vertices_cube_mpl(
294 width=0.2,
295 height=0.4,
296 depth=0.6,
297 width_segments=1,
298 height_segments=2,
299 depth_segments=3,
300 origin=np.array([0.2, 0.4, 0.6]),
301 ),
302 np.array(
303 [
304 [
305 [0.20000000, 0.60000000, 0.40000000],
306 [0.40000000, 0.60000000, 0.40000000],
307 [0.40000000, 0.80000000, 0.40000000],
308 [0.20000000, 0.80000000, 0.40000000],
309 ],
310 [
311 [0.20000000, 0.80000000, 0.40000000],
312 [0.40000000, 0.80000000, 0.40000000],
313 [0.40000000, 1.00000000, 0.40000000],
314 [0.20000000, 1.00000000, 0.40000000],
315 ],
316 [
317 [0.20000000, 1.00000000, 0.40000000],
318 [0.40000000, 1.00000000, 0.40000000],
319 [0.40000000, 1.20000000, 0.40000000],
320 [0.20000000, 1.20000000, 0.40000000],
321 ],
322 [
323 [0.20000000, 0.60000000, 0.80000000],
324 [0.40000000, 0.60000000, 0.80000000],
325 [0.40000000, 0.80000000, 0.80000000],
326 [0.20000000, 0.80000000, 0.80000000],
327 ],
328 [
329 [0.20000000, 0.80000000, 0.80000000],
330 [0.40000000, 0.80000000, 0.80000000],
331 [0.40000000, 1.00000000, 0.80000000],
332 [0.20000000, 1.00000000, 0.80000000],
333 ],
334 [
335 [0.20000000, 1.00000000, 0.80000000],
336 [0.40000000, 1.00000000, 0.80000000],
337 [0.40000000, 1.20000000, 0.80000000],
338 [0.20000000, 1.20000000, 0.80000000],
339 ],
340 [
341 [0.20000000, 0.60000000, 0.40000000],
342 [0.40000000, 0.60000000, 0.40000000],
343 [0.40000000, 0.60000000, 0.60000000],
344 [0.20000000, 0.60000000, 0.60000000],
345 ],
346 [
347 [0.20000000, 0.60000000, 0.60000000],
348 [0.40000000, 0.60000000, 0.60000000],
349 [0.40000000, 0.60000000, 0.80000000],
350 [0.20000000, 0.60000000, 0.80000000],
351 ],
352 [
353 [0.20000000, 1.20000000, 0.40000000],
354 [0.40000000, 1.20000000, 0.40000000],
355 [0.40000000, 1.20000000, 0.60000000],
356 [0.20000000, 1.20000000, 0.60000000],
357 ],
358 [
359 [0.20000000, 1.20000000, 0.60000000],
360 [0.40000000, 1.20000000, 0.60000000],
361 [0.40000000, 1.20000000, 0.80000000],
362 [0.20000000, 1.20000000, 0.80000000],
363 ],
364 [
365 [0.20000000, 0.60000000, 0.40000000],
366 [0.20000000, 0.80000000, 0.40000000],
367 [0.20000000, 0.80000000, 0.60000000],
368 [0.20000000, 0.60000000, 0.60000000],
369 ],
370 [
371 [0.20000000, 0.60000000, 0.60000000],
372 [0.20000000, 0.80000000, 0.60000000],
373 [0.20000000, 0.80000000, 0.80000000],
374 [0.20000000, 0.60000000, 0.80000000],
375 ],
376 [
377 [0.20000000, 0.80000000, 0.40000000],
378 [0.20000000, 1.00000000, 0.40000000],
379 [0.20000000, 1.00000000, 0.60000000],
380 [0.20000000, 0.80000000, 0.60000000],
381 ],
382 [
383 [0.20000000, 0.80000000, 0.60000000],
384 [0.20000000, 1.00000000, 0.60000000],
385 [0.20000000, 1.00000000, 0.80000000],
386 [0.20000000, 0.80000000, 0.80000000],
387 ],
388 [
389 [0.20000000, 1.00000000, 0.40000000],
390 [0.20000000, 1.20000000, 0.40000000],
391 [0.20000000, 1.20000000, 0.60000000],
392 [0.20000000, 1.00000000, 0.60000000],
393 ],
394 [
395 [0.20000000, 1.00000000, 0.60000000],
396 [0.20000000, 1.20000000, 0.60000000],
397 [0.20000000, 1.20000000, 0.80000000],
398 [0.20000000, 1.00000000, 0.80000000],
399 ],
400 [
401 [0.40000000, 0.60000000, 0.40000000],
402 [0.40000000, 0.80000000, 0.40000000],
403 [0.40000000, 0.80000000, 0.60000000],
404 [0.40000000, 0.60000000, 0.60000000],
405 ],
406 [
407 [0.40000000, 0.60000000, 0.60000000],
408 [0.40000000, 0.80000000, 0.60000000],
409 [0.40000000, 0.80000000, 0.80000000],
410 [0.40000000, 0.60000000, 0.80000000],
411 ],
412 [
413 [0.40000000, 0.80000000, 0.40000000],
414 [0.40000000, 1.00000000, 0.40000000],
415 [0.40000000, 1.00000000, 0.60000000],
416 [0.40000000, 0.80000000, 0.60000000],
417 ],
418 [
419 [0.40000000, 0.80000000, 0.60000000],
420 [0.40000000, 1.00000000, 0.60000000],
421 [0.40000000, 1.00000000, 0.80000000],
422 [0.40000000, 0.80000000, 0.80000000],
423 ],
424 [
425 [0.40000000, 1.00000000, 0.40000000],
426 [0.40000000, 1.20000000, 0.40000000],
427 [0.40000000, 1.20000000, 0.60000000],
428 [0.40000000, 1.00000000, 0.60000000],
429 ],
430 [
431 [0.40000000, 1.00000000, 0.60000000],
432 [0.40000000, 1.20000000, 0.60000000],
433 [0.40000000, 1.20000000, 0.80000000],
434 [0.40000000, 1.00000000, 0.80000000],
435 ],
436 ]
437 ),
438 atol=TOLERANCE_ABSOLUTE_TESTS,
439 )
441 np.testing.assert_allclose(
442 primitive_vertices_cube_mpl(
443 width=-0.2,
444 height=-0.4,
445 depth=-0.6,
446 width_segments=1,
447 height_segments=2,
448 depth_segments=3,
449 origin=np.array([-0.2, -0.4, -0.6]),
450 ),
451 np.array(
452 [
453 [
454 [-0.20000000, -0.60000000, -0.40000000],
455 [-0.40000000, -0.60000000, -0.40000000],
456 [-0.40000000, -0.80000000, -0.40000000],
457 [-0.20000000, -0.80000000, -0.40000000],
458 ],
459 [
460 [-0.20000000, -0.80000000, -0.40000000],
461 [-0.40000000, -0.80000000, -0.40000000],
462 [-0.40000000, -1.00000000, -0.40000000],
463 [-0.20000000, -1.00000000, -0.40000000],
464 ],
465 [
466 [-0.20000000, -1.00000000, -0.40000000],
467 [-0.40000000, -1.00000000, -0.40000000],
468 [-0.40000000, -1.20000000, -0.40000000],
469 [-0.20000000, -1.20000000, -0.40000000],
470 ],
471 [
472 [-0.20000000, -0.60000000, -0.80000000],
473 [-0.40000000, -0.60000000, -0.80000000],
474 [-0.40000000, -0.80000000, -0.80000000],
475 [-0.20000000, -0.80000000, -0.80000000],
476 ],
477 [
478 [-0.20000000, -0.80000000, -0.80000000],
479 [-0.40000000, -0.80000000, -0.80000000],
480 [-0.40000000, -1.00000000, -0.80000000],
481 [-0.20000000, -1.00000000, -0.80000000],
482 ],
483 [
484 [-0.20000000, -1.00000000, -0.80000000],
485 [-0.40000000, -1.00000000, -0.80000000],
486 [-0.40000000, -1.20000000, -0.80000000],
487 [-0.20000000, -1.20000000, -0.80000000],
488 ],
489 [
490 [-0.20000000, -0.60000000, -0.40000000],
491 [-0.40000000, -0.60000000, -0.40000000],
492 [-0.40000000, -0.60000000, -0.60000000],
493 [-0.20000000, -0.60000000, -0.60000000],
494 ],
495 [
496 [-0.20000000, -0.60000000, -0.60000000],
497 [-0.40000000, -0.60000000, -0.60000000],
498 [-0.40000000, -0.60000000, -0.80000000],
499 [-0.20000000, -0.60000000, -0.80000000],
500 ],
501 [
502 [-0.20000000, -1.20000000, -0.40000000],
503 [-0.40000000, -1.20000000, -0.40000000],
504 [-0.40000000, -1.20000000, -0.60000000],
505 [-0.20000000, -1.20000000, -0.60000000],
506 ],
507 [
508 [-0.20000000, -1.20000000, -0.60000000],
509 [-0.40000000, -1.20000000, -0.60000000],
510 [-0.40000000, -1.20000000, -0.80000000],
511 [-0.20000000, -1.20000000, -0.80000000],
512 ],
513 [
514 [-0.20000000, -0.60000000, -0.40000000],
515 [-0.20000000, -0.80000000, -0.40000000],
516 [-0.20000000, -0.80000000, -0.60000000],
517 [-0.20000000, -0.60000000, -0.60000000],
518 ],
519 [
520 [-0.20000000, -0.60000000, -0.60000000],
521 [-0.20000000, -0.80000000, -0.60000000],
522 [-0.20000000, -0.80000000, -0.80000000],
523 [-0.20000000, -0.60000000, -0.80000000],
524 ],
525 [
526 [-0.20000000, -0.80000000, -0.40000000],
527 [-0.20000000, -1.00000000, -0.40000000],
528 [-0.20000000, -1.00000000, -0.60000000],
529 [-0.20000000, -0.80000000, -0.60000000],
530 ],
531 [
532 [-0.20000000, -0.80000000, -0.60000000],
533 [-0.20000000, -1.00000000, -0.60000000],
534 [-0.20000000, -1.00000000, -0.80000000],
535 [-0.20000000, -0.80000000, -0.80000000],
536 ],
537 [
538 [-0.20000000, -1.00000000, -0.40000000],
539 [-0.20000000, -1.20000000, -0.40000000],
540 [-0.20000000, -1.20000000, -0.60000000],
541 [-0.20000000, -1.00000000, -0.60000000],
542 ],
543 [
544 [-0.20000000, -1.00000000, -0.60000000],
545 [-0.20000000, -1.20000000, -0.60000000],
546 [-0.20000000, -1.20000000, -0.80000000],
547 [-0.20000000, -1.00000000, -0.80000000],
548 ],
549 [
550 [-0.40000000, -0.60000000, -0.40000000],
551 [-0.40000000, -0.80000000, -0.40000000],
552 [-0.40000000, -0.80000000, -0.60000000],
553 [-0.40000000, -0.60000000, -0.60000000],
554 ],
555 [
556 [-0.40000000, -0.60000000, -0.60000000],
557 [-0.40000000, -0.80000000, -0.60000000],
558 [-0.40000000, -0.80000000, -0.80000000],
559 [-0.40000000, -0.60000000, -0.80000000],
560 ],
561 [
562 [-0.40000000, -0.80000000, -0.40000000],
563 [-0.40000000, -1.00000000, -0.40000000],
564 [-0.40000000, -1.00000000, -0.60000000],
565 [-0.40000000, -0.80000000, -0.60000000],
566 ],
567 [
568 [-0.40000000, -0.80000000, -0.60000000],
569 [-0.40000000, -1.00000000, -0.60000000],
570 [-0.40000000, -1.00000000, -0.80000000],
571 [-0.40000000, -0.80000000, -0.80000000],
572 ],
573 [
574 [-0.40000000, -1.00000000, -0.40000000],
575 [-0.40000000, -1.20000000, -0.40000000],
576 [-0.40000000, -1.20000000, -0.60000000],
577 [-0.40000000, -1.00000000, -0.60000000],
578 ],
579 [
580 [-0.40000000, -1.00000000, -0.60000000],
581 [-0.40000000, -1.20000000, -0.60000000],
582 [-0.40000000, -1.20000000, -0.80000000],
583 [-0.40000000, -1.00000000, -0.80000000],
584 ],
585 ]
586 ),
587 atol=TOLERANCE_ABSOLUTE_TESTS,
588 )
590 for plane in MAPPING_PLANE_TO_AXIS:
591 np.testing.assert_allclose(
592 primitive_vertices_cube_mpl(planes=[plane]),
593 primitive_vertices_cube_mpl(planes=[MAPPING_PLANE_TO_AXIS[plane]]),
594 atol=TOLERANCE_ABSOLUTE_TESTS,
595 )
598class TestPrimitiveVerticesSphere:
599 """
600 Define :func:`colour.geometry.vertices.primitive_vertices_sphere`
601 definition unit tests methods.
602 """
604 def test_primitive_vertices_sphere(self) -> None:
605 """
606 Test :func:`colour.geometry.vertices.primitive_vertices_sphere`
607 definition.
608 """
610 np.testing.assert_allclose(
611 primitive_vertices_sphere(),
612 np.array(
613 [
614 [
615 [0.00000000, 0.00000000, 0.50000000],
616 [-0.19134172, -0.00000000, 0.46193977],
617 [-0.35355339, -0.00000000, 0.35355339],
618 [-0.46193977, -0.00000000, 0.19134172],
619 [-0.50000000, -0.00000000, 0.00000000],
620 [-0.46193977, -0.00000000, -0.19134172],
621 [-0.35355339, -0.00000000, -0.35355339],
622 [-0.19134172, -0.00000000, -0.46193977],
623 [-0.00000000, -0.00000000, -0.50000000],
624 ],
625 [
626 [0.00000000, 0.00000000, 0.50000000],
627 [-0.13529903, -0.13529903, 0.46193977],
628 [-0.25000000, -0.25000000, 0.35355339],
629 [-0.32664074, -0.32664074, 0.19134172],
630 [-0.35355339, -0.35355339, 0.00000000],
631 [-0.32664074, -0.32664074, -0.19134172],
632 [-0.25000000, -0.25000000, -0.35355339],
633 [-0.13529903, -0.13529903, -0.46193977],
634 [-0.00000000, -0.00000000, -0.50000000],
635 ],
636 [
637 [0.00000000, 0.00000000, 0.50000000],
638 [0.00000000, -0.19134172, 0.46193977],
639 [0.00000000, -0.35355339, 0.35355339],
640 [0.00000000, -0.46193977, 0.19134172],
641 [0.00000000, -0.50000000, 0.00000000],
642 [0.00000000, -0.46193977, -0.19134172],
643 [0.00000000, -0.35355339, -0.35355339],
644 [0.00000000, -0.19134172, -0.46193977],
645 [0.00000000, -0.00000000, -0.50000000],
646 ],
647 [
648 [0.00000000, 0.00000000, 0.50000000],
649 [0.13529903, -0.13529903, 0.46193977],
650 [0.25000000, -0.25000000, 0.35355339],
651 [0.32664074, -0.32664074, 0.19134172],
652 [0.35355339, -0.35355339, 0.00000000],
653 [0.32664074, -0.32664074, -0.19134172],
654 [0.25000000, -0.25000000, -0.35355339],
655 [0.13529903, -0.13529903, -0.46193977],
656 [0.00000000, -0.00000000, -0.50000000],
657 ],
658 [
659 [0.00000000, 0.00000000, 0.50000000],
660 [0.19134172, 0.00000000, 0.46193977],
661 [0.35355339, 0.00000000, 0.35355339],
662 [0.46193977, 0.00000000, 0.19134172],
663 [0.50000000, 0.00000000, 0.00000000],
664 [0.46193977, 0.00000000, -0.19134172],
665 [0.35355339, 0.00000000, -0.35355339],
666 [0.19134172, 0.00000000, -0.46193977],
667 [0.00000000, 0.00000000, -0.50000000],
668 ],
669 [
670 [0.00000000, 0.00000000, 0.50000000],
671 [0.13529903, 0.13529903, 0.46193977],
672 [0.25000000, 0.25000000, 0.35355339],
673 [0.32664074, 0.32664074, 0.19134172],
674 [0.35355339, 0.35355339, 0.00000000],
675 [0.32664074, 0.32664074, -0.19134172],
676 [0.25000000, 0.25000000, -0.35355339],
677 [0.13529903, 0.13529903, -0.46193977],
678 [0.00000000, 0.00000000, -0.50000000],
679 ],
680 [
681 [0.00000000, 0.00000000, 0.50000000],
682 [0.00000000, 0.19134172, 0.46193977],
683 [0.00000000, 0.35355339, 0.35355339],
684 [0.00000000, 0.46193977, 0.19134172],
685 [0.00000000, 0.50000000, 0.00000000],
686 [0.00000000, 0.46193977, -0.19134172],
687 [0.00000000, 0.35355339, -0.35355339],
688 [0.00000000, 0.19134172, -0.46193977],
689 [0.00000000, 0.00000000, -0.50000000],
690 ],
691 [
692 [0.00000000, 0.00000000, 0.50000000],
693 [-0.13529903, 0.13529903, 0.46193977],
694 [-0.25000000, 0.25000000, 0.35355339],
695 [-0.32664074, 0.32664074, 0.19134172],
696 [-0.35355339, 0.35355339, 0.00000000],
697 [-0.32664074, 0.32664074, -0.19134172],
698 [-0.25000000, 0.25000000, -0.35355339],
699 [-0.13529903, 0.13529903, -0.46193977],
700 [-0.00000000, 0.00000000, -0.50000000],
701 ],
702 ]
703 ),
704 atol=TOLERANCE_ABSOLUTE_TESTS,
705 )
707 np.testing.assert_allclose(
708 primitive_vertices_sphere(intermediate=True),
709 np.array(
710 [
711 [
712 [0.00000000, 0.00000000, 0.50000000],
713 [-0.25663998, -0.10630376, 0.41573481],
714 [-0.38408888, -0.15909482, 0.27778512],
715 [-0.45306372, -0.18766514, 0.09754516],
716 [-0.45306372, -0.18766514, -0.09754516],
717 [-0.38408888, -0.15909482, -0.27778512],
718 [-0.25663998, -0.10630376, -0.41573481],
719 [-0.00000000, -0.00000000, -0.50000000],
720 ],
721 [
722 [0.00000000, 0.00000000, 0.50000000],
723 [-0.10630376, -0.25663998, 0.41573481],
724 [-0.15909482, -0.38408888, 0.27778512],
725 [-0.18766514, -0.45306372, 0.09754516],
726 [-0.18766514, -0.45306372, -0.09754516],
727 [-0.15909482, -0.38408888, -0.27778512],
728 [-0.10630376, -0.25663998, -0.41573481],
729 [-0.00000000, -0.00000000, -0.50000000],
730 ],
731 [
732 [0.00000000, 0.00000000, 0.50000000],
733 [0.10630376, -0.25663998, 0.41573481],
734 [0.15909482, -0.38408888, 0.27778512],
735 [0.18766514, -0.45306372, 0.09754516],
736 [0.18766514, -0.45306372, -0.09754516],
737 [0.15909482, -0.38408888, -0.27778512],
738 [0.10630376, -0.25663998, -0.41573481],
739 [0.00000000, -0.00000000, -0.50000000],
740 ],
741 [
742 [0.00000000, 0.00000000, 0.50000000],
743 [0.25663998, -0.10630376, 0.41573481],
744 [0.38408888, -0.15909482, 0.27778512],
745 [0.45306372, -0.18766514, 0.09754516],
746 [0.45306372, -0.18766514, -0.09754516],
747 [0.38408888, -0.15909482, -0.27778512],
748 [0.25663998, -0.10630376, -0.41573481],
749 [0.00000000, -0.00000000, -0.50000000],
750 ],
751 [
752 [0.00000000, 0.00000000, 0.50000000],
753 [0.25663998, 0.10630376, 0.41573481],
754 [0.38408888, 0.15909482, 0.27778512],
755 [0.45306372, 0.18766514, 0.09754516],
756 [0.45306372, 0.18766514, -0.09754516],
757 [0.38408888, 0.15909482, -0.27778512],
758 [0.25663998, 0.10630376, -0.41573481],
759 [0.00000000, 0.00000000, -0.50000000],
760 ],
761 [
762 [0.00000000, 0.00000000, 0.50000000],
763 [0.10630376, 0.25663998, 0.41573481],
764 [0.15909482, 0.38408888, 0.27778512],
765 [0.18766514, 0.45306372, 0.09754516],
766 [0.18766514, 0.45306372, -0.09754516],
767 [0.15909482, 0.38408888, -0.27778512],
768 [0.10630376, 0.25663998, -0.41573481],
769 [0.00000000, 0.00000000, -0.50000000],
770 ],
771 [
772 [0.00000000, 0.00000000, 0.50000000],
773 [-0.10630376, 0.25663998, 0.41573481],
774 [-0.15909482, 0.38408888, 0.27778512],
775 [-0.18766514, 0.45306372, 0.09754516],
776 [-0.18766514, 0.45306372, -0.09754516],
777 [-0.15909482, 0.38408888, -0.27778512],
778 [-0.10630376, 0.25663998, -0.41573481],
779 [-0.00000000, 0.00000000, -0.50000000],
780 ],
781 [
782 [0.00000000, 0.00000000, 0.50000000],
783 [-0.25663998, 0.10630376, 0.41573481],
784 [-0.38408888, 0.15909482, 0.27778512],
785 [-0.45306372, 0.18766514, 0.09754516],
786 [-0.45306372, 0.18766514, -0.09754516],
787 [-0.38408888, 0.15909482, -0.27778512],
788 [-0.25663998, 0.10630376, -0.41573481],
789 [-0.00000000, 0.00000000, -0.50000000],
790 ],
791 ]
792 ),
793 atol=TOLERANCE_ABSOLUTE_TESTS,
794 )
796 np.testing.assert_allclose(
797 primitive_vertices_sphere(segments=6, axis="+y"),
798 np.array(
799 [
800 [
801 [0.00000000, 0.50000000, 0.00000000],
802 [-0.00000000, 0.43301270, -0.25000000],
803 [-0.00000000, 0.25000000, -0.43301270],
804 [-0.00000000, 0.00000000, -0.50000000],
805 [-0.00000000, -0.25000000, -0.43301270],
806 [-0.00000000, -0.43301270, -0.25000000],
807 [-0.00000000, -0.50000000, -0.00000000],
808 ],
809 [
810 [0.00000000, 0.50000000, 0.00000000],
811 [-0.21650635, 0.43301270, -0.12500000],
812 [-0.37500000, 0.25000000, -0.21650635],
813 [-0.43301270, 0.00000000, -0.25000000],
814 [-0.37500000, -0.25000000, -0.21650635],
815 [-0.21650635, -0.43301270, -0.12500000],
816 [-0.00000000, -0.50000000, -0.00000000],
817 ],
818 [
819 [0.00000000, 0.50000000, 0.00000000],
820 [-0.21650635, 0.43301270, 0.12500000],
821 [-0.37500000, 0.25000000, 0.21650635],
822 [-0.43301270, 0.00000000, 0.25000000],
823 [-0.37500000, -0.25000000, 0.21650635],
824 [-0.21650635, -0.43301270, 0.12500000],
825 [-0.00000000, -0.50000000, 0.00000000],
826 ],
827 [
828 [0.00000000, 0.50000000, 0.00000000],
829 [0.00000000, 0.43301270, 0.25000000],
830 [0.00000000, 0.25000000, 0.43301270],
831 [0.00000000, 0.00000000, 0.50000000],
832 [0.00000000, -0.25000000, 0.43301270],
833 [0.00000000, -0.43301270, 0.25000000],
834 [0.00000000, -0.50000000, 0.00000000],
835 ],
836 [
837 [0.00000000, 0.50000000, 0.00000000],
838 [0.21650635, 0.43301270, 0.12500000],
839 [0.37500000, 0.25000000, 0.21650635],
840 [0.43301270, 0.00000000, 0.25000000],
841 [0.37500000, -0.25000000, 0.21650635],
842 [0.21650635, -0.43301270, 0.12500000],
843 [0.00000000, -0.50000000, 0.00000000],
844 ],
845 [
846 [0.00000000, 0.50000000, 0.00000000],
847 [0.21650635, 0.43301270, -0.12500000],
848 [0.37500000, 0.25000000, -0.21650635],
849 [0.43301270, 0.00000000, -0.25000000],
850 [0.37500000, -0.25000000, -0.21650635],
851 [0.21650635, -0.43301270, -0.12500000],
852 [0.00000000, -0.50000000, -0.00000000],
853 ],
854 ]
855 ),
856 atol=TOLERANCE_ABSOLUTE_TESTS,
857 )
859 np.testing.assert_allclose(
860 primitive_vertices_sphere(segments=6, axis="+x"),
861 np.array(
862 [
863 [
864 [0.50000000, 0.00000000, 0.00000000],
865 [0.43301270, -0.25000000, -0.00000000],
866 [0.25000000, -0.43301270, -0.00000000],
867 [0.00000000, -0.50000000, -0.00000000],
868 [-0.25000000, -0.43301270, -0.00000000],
869 [-0.43301270, -0.25000000, -0.00000000],
870 [-0.50000000, -0.00000000, -0.00000000],
871 ],
872 [
873 [0.50000000, 0.00000000, 0.00000000],
874 [0.43301270, -0.12500000, -0.21650635],
875 [0.25000000, -0.21650635, -0.37500000],
876 [0.00000000, -0.25000000, -0.43301270],
877 [-0.25000000, -0.21650635, -0.37500000],
878 [-0.43301270, -0.12500000, -0.21650635],
879 [-0.50000000, -0.00000000, -0.00000000],
880 ],
881 [
882 [0.50000000, 0.00000000, 0.00000000],
883 [0.43301270, 0.12500000, -0.21650635],
884 [0.25000000, 0.21650635, -0.37500000],
885 [0.00000000, 0.25000000, -0.43301270],
886 [-0.25000000, 0.21650635, -0.37500000],
887 [-0.43301270, 0.12500000, -0.21650635],
888 [-0.50000000, 0.00000000, -0.00000000],
889 ],
890 [
891 [0.50000000, 0.00000000, 0.00000000],
892 [0.43301270, 0.25000000, 0.00000000],
893 [0.25000000, 0.43301270, 0.00000000],
894 [0.00000000, 0.50000000, 0.00000000],
895 [-0.25000000, 0.43301270, 0.00000000],
896 [-0.43301270, 0.25000000, 0.00000000],
897 [-0.50000000, 0.00000000, 0.00000000],
898 ],
899 [
900 [0.50000000, 0.00000000, 0.00000000],
901 [0.43301270, 0.12500000, 0.21650635],
902 [0.25000000, 0.21650635, 0.37500000],
903 [0.00000000, 0.25000000, 0.43301270],
904 [-0.25000000, 0.21650635, 0.37500000],
905 [-0.43301270, 0.12500000, 0.21650635],
906 [-0.50000000, 0.00000000, 0.00000000],
907 ],
908 [
909 [0.50000000, 0.00000000, 0.00000000],
910 [0.43301270, -0.12500000, 0.21650635],
911 [0.25000000, -0.21650635, 0.37500000],
912 [0.00000000, -0.25000000, 0.43301270],
913 [-0.25000000, -0.21650635, 0.37500000],
914 [-0.43301270, -0.12500000, 0.21650635],
915 [-0.50000000, -0.00000000, 0.00000000],
916 ],
917 ]
918 ),
919 atol=TOLERANCE_ABSOLUTE_TESTS,
920 )
922 np.testing.assert_allclose(
923 primitive_vertices_sphere(
924 radius=100,
925 segments=6,
926 origin=np.array([-0.2, -0.4, -0.6]),
927 axis="+x",
928 ),
929 np.array(
930 [
931 [
932 [99.80000000, -0.40000000, -0.60000000],
933 [86.40254038, -50.40000000, -0.60000000],
934 [49.80000000, -87.00254038, -0.60000000],
935 [-0.20000000, -100.40000000, -0.60000000],
936 [-50.20000000, -87.00254038, -0.60000000],
937 [-86.80254038, -50.40000000, -0.60000000],
938 [-100.20000000, -0.40000000, -0.60000000],
939 ],
940 [
941 [99.80000000, -0.40000000, -0.60000000],
942 [86.40254038, -25.40000000, -43.90127019],
943 [49.80000000, -43.70127019, -75.60000000],
944 [-0.20000000, -50.40000000, -87.20254038],
945 [-50.20000000, -43.70127019, -75.60000000],
946 [-86.80254038, -25.40000000, -43.90127019],
947 [-100.20000000, -0.40000000, -0.60000000],
948 ],
949 [
950 [99.80000000, -0.40000000, -0.60000000],
951 [86.40254038, 24.60000000, -43.90127019],
952 [49.80000000, 42.90127019, -75.60000000],
953 [-0.20000000, 49.60000000, -87.20254038],
954 [-50.20000000, 42.90127019, -75.60000000],
955 [-86.80254038, 24.60000000, -43.90127019],
956 [-100.20000000, -0.40000000, -0.60000000],
957 ],
958 [
959 [99.80000000, -0.40000000, -0.60000000],
960 [86.40254038, 49.60000000, -0.60000000],
961 [49.80000000, 86.20254038, -0.60000000],
962 [-0.20000000, 99.60000000, -0.60000000],
963 [-50.20000000, 86.20254038, -0.60000000],
964 [-86.80254038, 49.60000000, -0.60000000],
965 [-100.20000000, -0.40000000, -0.60000000],
966 ],
967 [
968 [99.80000000, -0.40000000, -0.60000000],
969 [86.40254038, 24.60000000, 42.70127019],
970 [49.80000000, 42.90127019, 74.40000000],
971 [-0.20000000, 49.60000000, 86.00254038],
972 [-50.20000000, 42.90127019, 74.40000000],
973 [-86.80254038, 24.60000000, 42.70127019],
974 [-100.20000000, -0.40000000, -0.60000000],
975 ],
976 [
977 [99.80000000, -0.40000000, -0.60000000],
978 [86.40254038, -25.40000000, 42.70127019],
979 [49.80000000, -43.70127019, 74.40000000],
980 [-0.20000000, -50.40000000, 86.00254038],
981 [-50.20000000, -43.70127019, 74.40000000],
982 [-86.80254038, -25.40000000, 42.70127019],
983 [-100.20000000, -0.40000000, -0.60000000],
984 ],
985 ]
986 ),
987 atol=TOLERANCE_ABSOLUTE_TESTS,
988 )
990 for plane in ("xy", "xz", "yz"):
991 np.testing.assert_allclose(
992 primitive_vertices_sphere(axis=plane),
993 primitive_vertices_sphere(axis=MAPPING_PLANE_TO_AXIS[plane]),
994 atol=TOLERANCE_ABSOLUTE_TESTS,
995 )
997 pytest.raises(ValueError, lambda: primitive_vertices_quad_mpl(axis="Undefined"))