-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcross_section_test.py
32 lines (25 loc) · 1.04 KB
/
cross_section_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import numpy as np
from cross_section import *
def test_normal_vector_of_plane_has_unit_length():
plane = Plane([0, 0, 0], [-3, 4, 12])
np.testing.assert_almost_equal(np.linalg.norm(plane.n), 1.0)
def test_init_cross_section():
plane = Plane([50, 0, 0], n=[1, 0, 0])
cs = CrossSection(plane)
assert isinstance(cs.vertices_3d, np.ndarray)
assert isinstance(cs.vertices_2d, np.ndarray)
assert isinstance(cs.vertex_colors, np.ndarray)
assert isinstance(cs.faces, np.ndarray)
assert isinstance(cs.mapping_3d_to_2d, Mapping3Dto2D)
assert np.allclose(cs.vertices_3d[:, 0], 50)
def test_init_cross_section_L():
cs = CrossSectionL(L=40)
assert np.allclose(cs.vertices_3d[:, 0], 40)
assert isinstance(cs.vertices_3d, np.ndarray)
assert isinstance(cs.vertices_2d, np.ndarray)
assert isinstance(cs.vertex_colors, np.ndarray)
assert isinstance(cs.faces, np.ndarray)
assert isinstance(cs.mapping_3d_to_2d, Mapping3Dto2D)
cs.L = 10
assert cs.L == 10
assert np.allclose(cs.vertices_3d[:, 0], 10)