def test_transform(self): p = RegularPolygon(Point(0, 0, 0), 1, 6, axis=Point(0, 0, 1)) t = translation(1, 1, 0) assert t * p == RegularPolygon(Point(1, 1, 0), 1, 6, axis=Point(0, 0, 1)) assert isinstance(t * p, RegularPolygon)
def test_copy(self): a = Point(0, 0) b = Point(0, 2) c = Point(2, 2) d = Point(2, 0) r1 = Rectangle(a, b, c, d) p1 = RegularPolygon(a, 1, 6) r2 = r1.copy() p2 = p1.copy() assert r1 == r2 assert r1 is not r2 assert r1.vertices == r2.vertices assert p1 == p2 assert p1 is not p2 assert p1.vertices == p2.vertices
def test_init(self): a = Point(0, 0, 0) p = RegularPolygon(a, 1, 6, axis=Point(0, 0, 1)) d = p.edges[0].length assert len(p.vertices) == 6 assert np.isclose(dist(a, p.vertices[0]), 1) assert all(np.isclose(s.length, d) for s in p.edges[1:]) assert np.allclose(p.angles, np.pi / 3) assert p.center == a
def test_radius(self): p = RegularPolygon(Point(0, 0, 0), 1, 6, axis=Point(0, 0, 1)) assert np.isclose(p.radius, 1) assert np.isclose(p.inradius, np.cos(np.pi / 6))