def setup(self): self.a = as_numpy([1, 2, 4]) self.b = as_numpy([3, 3, 3]) self.ab = as_numpy([2, 1, -1]) self.example_tn = Orientation(tangent=self.a, normal=self.b) self.example_sn = Orientation(surface=self.b, normal=self.a) self.example_ts = Orientation(tangent=self.a, surface=self.b)
def __init__(self, position=None): if position is None: position = [0, 0, 0] self.position = as_numpy(position)
from geoscad.orientation import as_numpy, Orientation X_DIRECTION = as_numpy([1, 0, 0]) Y_DIRECTION = as_numpy([0, 1, 0]) Z_DIRECTION = as_numpy([0, 0, 1]) class Node: """A location in three dimensional space""" def __init__(self, position=None): if position is None: position = [0, 0, 0] self.position = as_numpy(position) class OrientedNode(Node, Orientation): """Oriented location in three dimensional space.""" def __init__(self, position=None, node=None, orientation=None, tangent=None, normal=None, surface=None): if position is None: position = node.position Node.__init__(self, position=position) if orientation is None: orientation = Orientation(tangent=tangent, normal=normal, surface=surface)
def test_numpy_compare(): aa = as_numpy([1, 2, 3]) bb = as_numpy([1, 2, 4]) cc = as_numpy([1, 2, 3]) assert aa != pytest.approx(bb) assert aa == pytest.approx(cc)
def test_reduction(): ccc = orthogonal_reduction(as_numpy([3, 4, 99]), as_numpy([0.6, 0.8, 0.0])) assert ccc[0] == pytest.approx(0.0) assert ccc[1] == pytest.approx(0.0) assert ccc[2] == pytest.approx(99.0)
def test_component(): ccc = component(as_numpy([3, 4, 99]), as_numpy([0.6, 0.8, 0.0])) assert ccc[0] == pytest.approx(3) assert ccc[1] == pytest.approx(4) assert ccc[2] == pytest.approx(0.0)
def test_direction(): aaa = [3, 4, 12] ddd = direction(as_numpy(aaa)) for iii in range(3): ddd[iii] == pytest.approx(aaa[iii] / 13)
def test_length(): assert length(as_numpy([3, 4, 12])) == pytest.approx(13)
def test_surfaces(self): for phase in [-1, 0, 0.5, 1, 1.1]: assert self.pathway.at_phase(phase).surface == pytest.approx( as_numpy([0.8, -0.6, 0.0]))
def test_tangents(self): for phase in [-1, 0, 0.5, 1, 1.1]: assert self.pathway.at_phase(phase).tangent == pytest.approx( as_numpy([0.6, 0.8, 0.0]))