MCPcopy Create free account
hub / github.com/danieljfarrell/pvtrace / test_coodinate_system_conversions

Method test_coodinate_system_conversions

tests/test_node.py:37–62  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

35 assert b.parent == a
36
37 def test_coodinate_system_conversions(self):
38 a = Node(name='a')
39 b = Node(name='b', parent=a)
40 c = Node(name='c', parent=b)
41 d = Node(name='d', parent=a)
42 b.translate((1,1,1))
43 c.translate((0,1,1))
44 d.translate((-1, -1, -1))
45 theta = 0.5 * np.pi
46 b.rotate(theta, (0, 0, 1))
47 c.rotate(theta, (1, 0, 0))
48 d.rotate(theta, (0, 1, 0))
49 # Points in node d to a require just travelling up the nodes.
50 assert np.allclose(d.point_to_node((0, 0, 0), a), (-1, -1, -1))
51 assert np.allclose(d.point_to_node((1, 1, 1), a), (0, 0, -2))
52 # Directions in node d to a require just travelling up the nodes.
53 assert np.allclose(d.vector_to_node((1, 0, 0), a), (0, 0, -1))
54 assert np.allclose(d.vector_to_node((0, 1, 0), a), (0, 1, 0))
55 assert np.allclose(d.vector_to_node((0, 0, 1), a), (1, 0, 0))
56 # Points in node d to c requires going up and down nodes
57 assert np.allclose(c.point_to_node((0, 0, 0), d), (-3, 2, 1))
58 assert np.allclose(c.point_to_node((1, 1, 1), d), (-4, 3, 2))
59 # Directions in node d to c require going up and down nodes
60 assert np.allclose(c.vector_to_node((1, 0, 0), d), (0, 1, 0))
61 assert np.allclose(c.vector_to_node((0, 1, 0), d), (-1, 0, 0))
62 assert np.allclose(c.vector_to_node((0, 0, 1), d), (0, 0, 1))
63
64 def test_intersections(self):
65 a = Node(name="A", parent=None)

Callers

nothing calls this directly

Calls 5

point_to_nodeMethod · 0.95
vector_to_nodeMethod · 0.95
NodeClass · 0.90
translateMethod · 0.80
rotateMethod · 0.80

Tested by

no test coverage detected