Exemplo n.º 1
0
 def test_scalar_mul_sqrt2(self):
     a, b, c = (0, 0), (10, -10), (20, 0)
     v = bisector_unit(a, b, c)
     s = sqrt(2)
     m = vector_mul_scalar(v, s)
     assert v != m  # multiplied vector is not the same as input
     assert m[0] == 0  # dx == 0
     assert m[1] == s  # dy == sqrt(2)
Exemplo n.º 2
0
 def test_nearly_0degs_right(self):
     """Bisector to the right
     """
     bi = bisector_unit((0, 1e-56), (1, 0), (0, 0))
     assert bi == (1.0, -5e-57)
Exemplo n.º 3
0
 def test_nearly_0degs_left(self):
     """Bisector to the left
     """
     bi = bisector_unit((0, 0), (1, 0), (0, 1e-56))
     assert bi == (-1.0, 5e-57)
Exemplo n.º 4
0
 def test_45degs0(self):
     """Test "V" points from left to right
     """
     bi = bisector_unit((0, 1), (1, 0), (2, 1))
     assert bi == (0, 1)
Exemplo n.º 5
0
 def test_near_0degs(self):
     """Folding back from p0 via p1 to p2
     x==x
     """
     bi = bisector_unit((0, 0), (1, 0), (0, 0.000001))
     assert bi == (-0.999999999999875, 4.999999999998125e-07)
Exemplo n.º 6
0
 def test_45degs3(self):
     """Test "V" points from top to bottom
     """
     bi = bisector_unit((0, 2), (-1, 1), (0, 0))
     assert bi == (1, 0)
Exemplo n.º 7
0
 def test_45degs2(self):
     """Test "V" points from bottom to top
     """
     bi = bisector_unit((0, 0), (-1, 1), (0, 2))
     assert bi == (-1, 0)
Exemplo n.º 8
0
 def test_45degs1(self):
     """Test "V" points from right to left
     """
     bi = bisector_unit((2, 1), (1, 0), (0, 1))
     assert bi == (0, -1)
Exemplo n.º 9
0
 def test_scalar_mul_one(self):
     a, b, c = (0, 0), (10, 0), (20, 0)
     v = bisector_unit(a, b, c)
     s = 1
     assert v == vector_mul_scalar(v, s)