示例#1
0
 def test_normal_vector(self, a: Point):
     if isclose(abs(a), 0.0):
         with pytest.raises(ZeroDivisionError):
             a.normal()
     else:
         angle = a.normal().angle() - a.angle()
         assert isclose(angle, np.pi / 2.0)
示例#2
0
 def test_unit_vector(self, x: float, y: float):
     a = Point(x, y)
     if isclose(abs(a), 0.0):
         with pytest.raises(ZeroDivisionError):
             a.unit_vector()
     else:
         b = a.unit_vector()
         note(f"angle of a: {np.format_float_scientific(a.angle())}")
         note(f"angle of b: {np.format_float_scientific(b.angle())}")
         assert isclose(a.angle(), b.angle())
         note(f"magnitude of b: {abs(b)}")
         assert isclose(abs(b), 1.0)
示例#3
0
 def test_rotation(self, a: Point, angle: Angle, center: Point):
     assume(abs(a - center) != 0)
     b = a.rotate(angle, center)
     new_angle = (b - center).angle() - (a - center).angle()
     note(angle)
     note(new_angle)
     assert isclose(angle, angle)
示例#4
0
 def test_rotation_about_zero(self, a: Point, angle: Angle):
     assume(abs(a) != 0)
     b = a.rotate(angle, Point(0.0, 0.0))
     aa = a.angle()
     bb = b.angle()
     note(f"a angle: {aa}")
     note(f"b angle: {bb}")
     assert isclose(bb - aa, angle)