def test_init_from_sdl(): """Test the initalization of LineSegment3D from start, direction, length.""" pt = Point3D(2, 0, 2) vec = Vector3D(0, 1, 0) seg = LineSegment3D.from_sdl(pt, vec, 2) assert seg.p == Point3D(2, 0, 2) assert seg.v == Vector3D(0, 2, 0) assert seg.p1 == Point3D(2, 0, 2) assert seg.p2 == Point3D(2, 2, 2) assert seg.length == 2
def test_subdivide_tolerance_issue(): """Test the LineSegment3D subdivide method handles Python tolerance. This case was taken from an originally failing situation in Rhino. """ origin = Point3D(-68.773857131759087, 20.836167334772536, 18.897600000000001) dir = Vector3D(-0.026879795220556984, -0.99963867302585929, 0.0) bottom_seg = LineSegment3D.from_sdl(origin, dir, 21.5037894118) assert len(bottom_seg.subdivide_evenly(5)) == 6 assert len(bottom_seg.subdivide_evenly(7)) == 8