def test_compute_center_from_both_tangents_but_same_points(self):
     candidate = Arc.compute_center_from_both_tangents(
         p0=Point(0, 0),
         p1=Point(0, 0),
         tangent_p0=Point(1, 1),
         tangent_p1=Point(1, -1))
     assert candidate == Point(0, 0)
 def test_compute_center_from_both_tangents_simple(self):
     candidate = Arc.compute_center_from_both_tangents(
         p0=Point(-1, 0),
         p1=Point(1, 0),
         tangent_p0=Point(0, 1),
         tangent_p1=Point(0, -1))
     assert candidate == Point(0, 0)
    def test_45deg_arc(self):
        candidate = Arc(Point(1, 0), Point(0, 1), Point(0, 1))

        assert math.isclose(candidate.angle, math.pi / 2)
        assert candidate.center == Point(0, 0)
        assert math.isclose(candidate.radius, 1)
        assert candidate.direction == Arc.DIRECT
 def test_arc_with_zero_radius(self):
     candidate = Arc(start=Point(0, 0),
                     end=Point(0, 0),
                     start_tangent=Point(0, 1),
                     end_tangent=Point(0, -1))
     assert candidate.radius == 0
     assert candidate.angle == math.pi
     assert candidate.center == Point(0., 0.)
    def test_reverse_45deg_arc_BUG(self):
        candidate = Arc(start=Point(1, 0),
                        end=Point(0, 1),
                        start_tangent=Point(0, -1))

        assert candidate.center == Point(0, 0)
        assert math.isclose(candidate.radius, 1)
        assert candidate.end_tangent == Point(1, 0)
        assert math.isclose(candidate.angle, -3 * math.pi / 2)
        assert candidate.direction == Arc.INDIRECT
        assert candidate.length > 0
Example #6
0
 def __init__(self, start: Point, end: Point, start_vector: Point,
              end_vector: Point):
     self.arc = Arc(start, end, start_vector, end_vector)
 def test_circular_arc(self):
     arc = Arc(start=Point(1, 0),
               end=Point(0, 1),
               start_tangent=Point(0, 1))
     assert math.isclose(arc.angle, (math.pi / 2.0))
 def test_compute_center_from_both_tangents_impossible(self):
     with pytest.raises(AssertionError) as ae:
         Arc.compute_center_from_both_tangents(p0=Point(-5, 2),
                                               p1=Point(1, 0),
                                               tangent_p0=Point(0, 1),
                                               tangent_p1=Point(1, -1))
 def test_simple_arc(self):
     candidate = Arc(Point(-1, 0), Point(1, 0), Point(0, 1))
     assert candidate.radius == 1
     assert candidate.angle == -math.pi
     assert candidate.center == Point(0., 0.)
 def test_find_find_angle_and_chord_vector(self):
     angle, u, distance = Arc.find_angle_and_chord_vector(
         Point(-1, 0), Point(1, 0), Point(0, 1))
     assert angle == math.pi