| 40 | |
| 41 | |
| 42 | class NumericalTest(unittest.TestCase): |
| 43 | |
| 44 | def test_sketch_ieq_triangle(self): |
| 45 | a, b, c = nm.sketch_ieq_triangle([]) |
| 46 | self.assertAlmostEqual(a.distance(b), b.distance(c)) |
| 47 | self.assertAlmostEqual(c.distance(a), b.distance(c)) |
| 48 | |
| 49 | def test_sketch_2l1c(self): |
| 50 | p = nm.Point(0.0, 0.0) |
| 51 | pi = np.pi |
| 52 | anga = unif(-0.4 * pi, 0.4 * pi) |
| 53 | a = Point(np.cos(anga), np.sin(anga)) |
| 54 | angb = unif(0.6 * pi, 1.4 * pi) |
| 55 | b = Point(np.cos(angb), np.sin(angb)) |
| 56 | |
| 57 | angc = unif(anga + 0.05 * pi, angb - 0.05 * pi) |
| 58 | c = Point(np.cos(angc), np.sin(angc)) * unif(0.2, 0.8) |
| 59 | |
| 60 | x, y, z, i = nm.sketch_2l1c([a, b, c, p]) |
| 61 | self.assertTrue(check_coll([x, c, a])) |
| 62 | self.assertTrue(check_coll([y, c, b])) |
| 63 | self.assertAlmostEqual(z.distance(p), 1.0) |
| 64 | self.assertTrue(check_coll([p, i, z])) |
| 65 | self.assertTrue(Line(i, x).is_perp(Line(c, a))) |
| 66 | self.assertTrue(Line(i, y).is_perp(Line(c, b))) |
| 67 | self.assertAlmostEqual(i.distance(x), i.distance(y)) |
| 68 | self.assertAlmostEqual(i.distance(x), i.distance(z)) |
| 69 | |
| 70 | def test_sketch_3peq(self): |
| 71 | a, b, c = random_points(3) |
| 72 | x, y, z = nm.sketch_3peq([a, b, c]) |
| 73 | |
| 74 | self.assertTrue(check_coll([a, b, x])) |
| 75 | self.assertTrue(check_coll([a, c, y])) |
| 76 | self.assertTrue(check_coll([b, c, z])) |
| 77 | self.assertTrue(check_coll([x, y, z])) |
| 78 | self.assertAlmostEqual(z.distance(x), z.distance(y)) |
| 79 | |
| 80 | def test_sketch_aline(self): |
| 81 | a, b, c, d, e = random_points(5) |
| 82 | ex = nm.sketch_aline([a, b, c, d, e]) |
| 83 | self.assertIsInstance(ex, HalfLine) |
| 84 | self.assertEqual(ex.tail, e) |
| 85 | x = ex.head |
| 86 | self.assertAlmostEqual(ang_between(b, a, c), ang_between(e, d, x)) |
| 87 | |
| 88 | def test_sketch_amirror(self): |
| 89 | a, b, c = random_points(3) |
| 90 | bx = nm.sketch_amirror([a, b, c]) |
| 91 | self.assertIsInstance(bx, HalfLine) |
| 92 | assert bx.tail == b |
| 93 | x = bx.head |
| 94 | |
| 95 | ang1 = ang_between(b, a, c) |
| 96 | ang2 = ang_between(b, c, x) |
| 97 | self.assertAlmostEqual(ang1, ang2) |
| 98 | |
| 99 | def test_sketch_bisect(self): |
nothing calls this directly
no outgoing calls
no test coverage detected