def test_subtraction07(self): a = Segment(0.0, 1.0) b = Segment(0.1, 0.2) c = Segment(0.4, 0.8) assert len( list(not t.is_degenerate() for t in flatten( s.subtraction(c) for s in a.subtraction(b)))) == 3
def test_shadow_02(self): s = Edge(R3(0.0, 0.0, 1.0), R3(1.0, 1.0, 1.0)) f = Facet([ R3(0.0, 0.0, 0.0), R3(2.0, 0.0, 0.0), R3(2.0, 2.0, 0.0), R3(0.0, 2.0, 0.0) ]) s.shadow(f) assert s.gaps[0].approx(Segment(0.0, 1.0))
def test_intersect_05(self): s = Edge(R3(0.0, 0.0, 1.0), R3(1.0, 0.0, -1.0)) a = R3(1.0, 1.0, 0.0) n = R3(0.0, 0.0, 1.0) assert s.intersect_edge_with_normal(a, n).approx(Segment(0.5, 1.0))
def test_subtraction04(self): a, b = Segment(-1.0, 2.0), Segment(0.0, 1.0) assert all(s.is_degenerate() for s in b.subtraction(a))
def test_subtraction03(self): a, b = Segment(-1.0, 2.0), Segment(0.0, 1.0) assert all(not s.is_degenerate() for s in a.subtraction(b))
def test_intersect03(self): a = Segment(0.0, 1.0) b = Segment(0.0, 2.0) c = Segment(0.0, 1.0) d = Segment(0.0, 2.0) assert a.intersect(b).approx(d.intersect(c)) a = Segment(0.0, 1.0) b = Segment(0.5, 1.0) c = Segment(0.0, 1.0) d = Segment(0.5, 1.0) assert a.intersect(b).approx(d.intersect(c)) a = Segment(0.0, 1.0) b = Segment(-0.5, 0.0) c = Segment(0.0, 1.0) d = Segment(-0.5, 0.0) assert a.intersect(b).approx(d.intersect(c)) a = Segment(0.0, 1.0) b = Segment(-0.5, -0.1) c = Segment(0.0, 1.0) d = Segment(-0.5, -0.1) assert a.intersect(b).approx(d.intersect(c))
def test_intersect02(self): a = Segment(0.0, 1.0) b = Segment(0.0, 2.0) c = Segment(1.0, 0.0) assert a.intersect(b).approx(c)
def test_degenerate03(self): assert Segment(0.0, -1.0).is_degenerate()
def test_degenerate01(self): assert not Segment(0.0, 1.0).is_degenerate()
def test_subtraction05(self): a = Segment(0.0, 1.0) b = Segment(0.0, 0.5) c = Segment(0.5, 1.0) assert all(t.is_degenerate() for t in flatten( s.subtraction(c) for s in a.subtraction(b)))