示例#1
0
    def test_pow(self):
        t = translation(1, 2)

        assert t**0 == Transformation(np.eye(3))
        assert t**1 == t
        assert t**2 == translation(2, 4)
        assert t**3 == translation(3, 6)
        assert t**(-2) == translation(-2, -4)
示例#2
0
    def test_pow(self):
        t = TransformationCollection([translation(1, 2)] * 10)

        assert t**0 == TransformationCollection([np.eye(3)] * 10)
        assert t**1 == t
        assert t**2 == TransformationCollection([translation(2, 4)] * 10)
        assert t**3 == TransformationCollection([translation(3, 6)] * 10)
        assert t**(-2) == TransformationCollection([translation(-2, -4)] * 10)
示例#3
0
    def test_translation(self):
        p = Point(0, 1)
        t = translation(0, -1)
        assert t * p == Point(0, 0)

        l = Line(Point(0, 0, 1), Point(1, 0, 1))
        t = translation(0, 0, -1)
        assert t * l == Line(Point(0, 0, 0), Point(1, 0, 0))
示例#4
0
    def test_transform(self):
        c = Cone(vertex=Point(1, 1, 1), base_center=Point(2, 2, 2), radius=2)
        t = translation(-1, -1, -1)

        assert t * c == Cone(vertex=Point(0, 0, 0),
                             base_center=Point(1, 1, 1),
                             radius=2)
示例#5
0
    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)
示例#6
0
    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)
示例#7
0
    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)
示例#8
0
    def test_transform(self):
        a = Point(0, 0, 0)
        b = Point(1, 0, 0)
        c = Point(0, 1, 0)
        d = Point(0, 0, 1)
        s = Simplex(a, b, c, d)
        x = Point(1, 1, 1)
        t = translation(x)

        assert t * s == Simplex(a + x, b + x, c + x, d + x)
示例#9
0
    def test_transform(self):
        a = Point(0, 0, 0)
        b = Point(1, 0, 0)
        c = Point(0, 1, 0)
        d = Point(0, 0, 1)
        cube = Cuboid(a, b, c, d)
        x = Point(1, 1, 1)
        t = translation(x)

        assert t * cube == Cuboid(a + x, b + x, c + x, d + x)
        assert isinstance(t * cube, Cuboid)
示例#10
0
def test_translation():
    p = Point(0, 1)
    t = translation(0,-1)
    assert t*p == Point(0,0)
示例#11
0
    def test_transform(self):
        s = Sphere(Point(0, 0, 2), 2)
        t = translation(1, 1, -1)

        assert t * s == Sphere(Point(1, 1, 1), 2)
示例#12
0
    def test_transform(self):
        c = Circle()
        t = translation(1, 1)

        assert t * c == Circle(Point(1, 1))
        assert t.apply(c).center == Point(1, 1)