def test_transform(): p = Point(1, 1) assert p.transform(rotate(pi / 2)) == Point(-1, 1) assert p.transform(scale(3, 2)) == Point(3, 2) assert p.transform(translate(1, 2)) == Point(2, 3) assert Point(1, 1).scale(2, 3, (4, 5)) == Point(-2, -7) assert Point(1, 1).translate(4, 5) == Point(5, 6)
def test_geometry_transforms(): from sympy import Tuple c = Curve((x, x ** 2), (x, 0, 1)) pts = [Point(0, 0), Point(S(1) / 2, S(1) / 4), Point(1, 1)] cout = Curve((2 * x - 4, 3 * x ** 2 - 10), (x, 0, 1)) pts_out = [Point(-4, -10), Point(-3, -S(37) / 4), Point(-2, -7)] assert c.scale(2, 3, (4, 5)) == cout assert [c.subs(x, xi / 2) for xi in Tuple(0, 1, 2)] == pts assert [cout.subs(x, xi / 2) for xi in Tuple(0, 1, 2)] == pts_out assert Triangle(*pts).scale(2, 3, (4, 5)) == Triangle(*pts_out) assert Ellipse((0, 0), 2, 3).scale(2, 3, (4, 5)) == Ellipse(Point(-4, -10), 4, 9) assert Circle((0, 0), 2).scale(2, 3, (4, 5)) == Ellipse(Point(-4, -10), 4, 6) assert Ellipse((0, 0), 2, 3).scale(3, 3, (4, 5)) == Ellipse(Point(-8, -10), 6, 9) assert Circle((0, 0), 2).scale(3, 3, (4, 5)) == Circle(Point(-8, -10), 6) assert Circle(Point(-8, -10), 6).scale(S(1) / 3, S(1) / 3, (4, 5)) == Circle((0, 0), 2) assert Curve((x + y, 3 * x), (x, 0, 1)).subs(y, S.Half) == Curve((x + S(1) / 2, 3 * x), (x, 0, 1)) assert Curve((x, 3 * x), (x, 0, 1)).translate(4, 5) == Curve((x + 4, 3 * x + 5), (x, 0, 1)) assert Circle((0, 0), 2).translate(4, 5) == Circle((4, 5), 2) assert Circle((0, 0), 2).scale(3, 3) == Circle((0, 0), 6) assert Point(1, 1).scale(2, 3, (4, 5)) == Point(-2, -7) assert Point(1, 1).translate(4, 5) == Point(5, 6) assert scale(1, 2, (3, 4)).tolist() == [[1, 0, 0], [0, 2, 0], [0, -4, 1]] assert RegularPolygon((0, 0), 1, 4).scale(2, 3, (4, 5)) == Polygon( Point(-2, -10), Point(-4, -7), Point(-6, -10), Point(-4, -13) )
def test_transform(): p = Point(1, 1) assert p.transform(rotate(pi/2)) == Point(-1, 1) assert p.transform(scale(3, 2)) == Point(3, 2) assert p.transform(translate(1, 2)) == Point(2, 3) assert Point(1, 1).scale(2, 3, (4, 5)) == \ Point(-2, -7) assert Point(1, 1).translate(4, 5) == \ Point(5, 6)
def test_geometry_transforms(): from sympy import Tuple c = Curve((x, x**2), (x, 0, 1)) pts = [Point(0, 0), Point(S(1) / 2, S(1) / 4), Point(1, 1)] cout = Curve((2 * x - 4, 3 * x**2 - 10), (x, 0, 1)) pts_out = [Point(-4, -10), Point(-3, -S(37) / 4), Point(-2, -7)] assert c.scale(2, 3, (4, 5)) == cout assert [c.subs(x, xi / 2) for xi in Tuple(0, 1, 2)] == pts assert [cout.subs(x, xi / 2) for xi in Tuple(0, 1, 2)] == pts_out assert Triangle(*pts).scale(2, 3, (4, 5)) == Triangle(*pts_out) assert Ellipse((0, 0), 2, 3).scale(2, 3, (4, 5)) == \ Ellipse(Point(-4, -10), 4, 9) assert Circle((0, 0), 2).scale(2, 3, (4, 5)) == \ Ellipse(Point(-4, -10), 4, 6) assert Ellipse((0, 0), 2, 3).scale(3, 3, (4, 5)) == \ Ellipse(Point(-8, -10), 6, 9) assert Circle((0, 0), 2).scale(3, 3, (4, 5)) == \ Circle(Point(-8, -10), 6) assert Circle(Point(-8, -10), 6).scale(S(1)/3, S(1)/3, (4, 5)) == \ Circle((0, 0), 2) assert Curve((x + y, 3*x), (x, 0, 1)).subs(y, S.Half) == \ Curve((x + S(1)/2, 3*x), (x, 0, 1)) assert Curve((x, 3*x), (x, 0, 1)).translate(4, 5) == \ Curve((x + 4, 3*x + 5), (x, 0, 1)) assert Circle((0, 0), 2).translate(4, 5) == \ Circle((4, 5), 2) assert Circle((0, 0), 2).scale(3, 3) == \ Circle((0, 0), 6) assert Point(1, 1).scale(2, 3, (4, 5)) == \ Point(-2, -7) assert Point(1, 1).translate(4, 5) == \ Point(5, 6) assert scale(1, 2, (3, 4)).tolist() == \ [[1, 0, 0], [0, 2, 0], [0, -4, 1]] assert RegularPolygon((0, 0), 1, 4).scale(2, 3, (4, 5)) == \ Polygon(Point(-2, -10), Point(-4, -7), Point(-6, -10), Point(-4, -13))
def test_transform(): p = Point(1, 1) assert p.transform(rotate(pi / 2)) == Point(-1, 1) assert p.transform(scale(3, 2)) == Point(3, 2) assert p.transform(translate(1, 2)) == Point(2, 3)
def test_transform(): assert scale(1, 2, (3, 4)).tolist() == \ [[1, 0, 0], [0, 2, 0], [0, -4, 1]]