def test_rotation(): p = Point(0, 1) t = rotation(-np.pi) assert t*p == Point(0, -1) p = Point(1, 0, 0) t = rotation(-np.pi/2, axis=Point(0, 0, 1)) assert t * p == Point(0, 1, 0)
def test_is_cocircular(): p = Point(0, 1) t = rotation(np.pi / 3) assert is_cocircular(p, t * p, t * t * p, t * t * t * p) p = PointCollection([(0, 1), (1, 0)], homogenize=True) t = rotation(np.pi / 3) assert all(is_cocircular(p, t * p, t * t * p, t * t * t * p))
def test_rotation(self): p = Point(0, 1) t = rotation(-np.pi) assert t * p == Point(0, -1) p = Point(1, 0, 0) t = rotation(-np.pi / 2, axis=Point(0, 0, 1)) assert t * p == Point(0, 1, 0) p = Point(-1, 1, 0) a = np.pi / 7 t = rotation(a, axis=Point(1, 1, 2)) assert np.isclose(angle(p, t * p), a)
def test_transform(self): a = PointCollection([(1, 0), (0, 1)], homogenize=True) assert translation(1, 1) * a == PointCollection([(2, 1), (1, 2)], homogenize=True) assert rotation(np.pi / 2) * a == PointCollection([(0, 1), (-1, 0)], homogenize=True)
def test_transform(self): c = Cylinder(center=Point(1, 0, 0), direction=Point(1, 0, 0), radius=4) t = translation(1, 1, 1) r = rotation(np.pi / 2, axis=Point(0, 1, 0)) assert t * c == Cylinder(center=Point(2, 1, 1), direction=Point(1, 0, 0), radius=4) assert r * c == Cylinder(center=Point(0, 0, 1), direction=Point(0, 0, 1), radius=4)
def test_transformation(self): p = Point(0, 0) q = Point(2, 2) s = Segment(p, q) r = rotation(np.pi / 2) assert r * s == Segment(p, Point(-2, 2)) assert r.apply(s)._line == r.apply(s._line)
def test_transformation(self): a = Point(0, 0) b = Point(0, 1) c = Point(2, 1) d = Point(2, 0) r = Rectangle(a, b, c, d) r2 = rotation(np.pi/2)*r assert r.area == r2.area assert r2.contains(Point(-0.5, 1.5)) l = Line(Point(0, 0, -10), Point(0, 0, 10)) r = Rectangle(Point(-10, -10, 0), Point(10, -10, 0), Point(10, 10, 0), Point(-10, 10, 0)) t = rotation(np.pi/6, Point(1, 0, 0)) assert r.intersect(l) == [Point(0, 0, 0)] assert (t*r).intersect(l) == [Point(0, 0, 0)]
def test_inverse(self): E = TransformationCollection([np.eye(4)] * 10) M = TransformationCollection([rotation(np.pi, axis=Point(0, 1, 0))] * 10) assert M.inverse() * M == E
def test_inverse(self): E = Transformation(np.eye(4)) M = rotation(np.pi, axis=Point(0, 1, 0)) assert M.inverse() * M == E