0% found this document useful (0 votes)
1 views

Assingment No . 4

The document contains a series of Python code snippets demonstrating geometric transformations using the SymPy and Shapely libraries. It includes operations such as reflection, scaling, rotation, and plotting of geometric shapes like points, polygons, and 3D scatter plots. Various examples illustrate the application of these transformations on different points and shapes.

Uploaded by

snehaajadhav8565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views

Assingment No . 4

The document contains a series of Python code snippets demonstrating geometric transformations using the SymPy and Shapely libraries. It includes operations such as reflection, scaling, rotation, and plotting of geometric shapes like points, polygons, and 3D scatter plots. Various examples illustrate the application of these transformations on different points and shapes.

Uploaded by

snehaajadhav8565
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Assingment No : 4

Q 1)

>>> from numpy import*

>>> from sympy import*

>>> P=Point(3,-1)

>>> x,y=symbols('x,y')

>>> P.reflect(Line(y))

Point2D(3, 1)

>>> P.scale(2,0)

Point2D(6, 0)

>>> P.scale(0,1.5)

Point2D(0, -3/2)

>>> P.reflect(Line(y-x))

Point2D(-1, 3)

Q2)

>>> from sympy import*

>>> P=Point(4,-2)

>>> x,y=symbols('x,y')

>>> P.reflect(Line(x))

Point2D(-4, -2)

>>> P.scale(3,0)

Point2D(12, 0)

>>> P.scale(0,2.5)

Point2D(0, -5)

>>> P.reflect(Line(y+x))

Point2D(2, -4)

Q3)

>>> P=Point(-2,4)

>>> P.transform(Matrix([[1,7,0],[0,1,0],[0,0,1]]))

Point2D(-2, -10)

>>> P.scale(7/2,7)
Point2D(-7, 28)

>>> P.transform(Matrix([[1,7,0],[4,1,0],[0,0,1]]))

Point2D(14, -10)

>>> P.rotate(pi/6)

Point2D(-2 - sqrt(3), -1 + 2*sqrt(3))

Q5)

>>>from sympy import*

>>> P=Point(2,-3)

>>> P.reflect(Line(y))

Point2D(2, 3)

>>> P.scale(2,0)

Point2D(4, 0)

>>> P.scale(0,1.5)

Point2D(0, -9/2)

>>> P.reflect(Line(y-x))

Point2D(-3, 2)

Q8)

>>> from sympy import*

>>> from math import*

>>> x,y=symbols('x,y')

>>> P=Point(-2,4)

>>> P.rotate(48*(pi/180))

Point2D(-431084051462729/100000000000000, 929869355063/781250000000)

>>> P.scale(2,0)

Point2D(-4, 0)

>>> P.reflect(Line(y-2*x-3))

Point2D(2, 2)

>>> P.transform(Matrix([[7,0,0],[0,1,0],[0,0,1]]))

Point2D(-14, 4)

Q9)

>>> from sympy import*


>>> from math import*

>>> x,y=symbols('x,y')

>>> P.scale(6,0)

Point2D(-12, 0)

>>> P.scale(0,4)

Point2D(0, 16)

>>> P.reflect(Line(y-2*x+3))

Point2D(34/5, -2/5)

>>> P.reflect(Line(2*x+4*y-5))

Point2D(-17/5, 6/5)

Q4)

>>> from sympy import*

>>> from math import*

>>> P=Point(-2,4)

>>> P.reflect(Line(y))

Point2D(-2, -4)

>>> P.scale(6,0)

Point2D(-12, 0)

>>> P.transform(Matrix([[1,0,0],[4,1,0],[0,0,1]]))

Point2D(14, 4)

>>> P.rotate(30*(pi/180))

Point2D(-46650635094611/12500000000000, 9856406460551/4000000000000)

Q6)

>>> from sympy import*

>>> from math import*

>>> from numpy import*

>>> A=Point(5,3)

>>> B=Point(2,-3)

>>> x=array([[0,1],[-1,0]])

>>> y=array([[5,0],[0,1]])

>>> z=array([[0,-1],[-1,0]])

>>> dot(x,y,z)
array([[ 0, 1],

[-5, 0]])

>>> A.transform(Matrix([[0,1,0],[-5,0,0],[0,0,1]]))

Point2D(-15, 5)

>>> B.transform(Matrix([[0,1,0],[-5,0,0],[0,0,1]]))

Point2D(15, 2)

Q7)

>>> from numpy import*

>>> from sympy import*

>>> from math import*

>>> A=Point(3,2)

>>> b=Point(2,-3)

>>> x=array([[1,0],[0,1]])

>>> y=array([[1,0],[0,4]])

>>> z=array([[-1,0],[0,-1]])

>>> dot(x,y,z)

array([[1, 0],

[0, 4]])

>>> A.transform(Matrix([[1,0,0],[0,4,0],[0,0,1]]))

Point2D(3, 8)

>>> b.transform(Matrix([[1,0,0],[0,4,0],[0,0,1]]))

Point2D(2, -12)
Assingment No . 2

Q1 )

1 >>> from shapely.geometry import Polygon

>>> import matplotlib.pyplot as plt

>>> triangle = Polygon([(5,4),(7,4),(6,6)])

>>> x,y = triangle.exterior.xy

>>> plt.plot(x,y,c='green')

[<matplotlib.lines.Line2D object at 0x000001B37531B620>]

>>> plt.show()

>>> from shapely.geometry import Polygon

>>> import matplotlib.pyplot as plt

>>> rectangle = Polygon([(2,2),(10,2),(10,8),(2,8)])

>>> x,y = rectangle.exterior.xy

>>> plt.plot(x,y,c='blue')

[<matplotlib.lines.Line2D object at 0x0000016330A5AD50>]

>>> plt.show()
3

>>> from shapely.geometry import Polygon

>>> import matplotlib.pyplot as plt

>>> polygon1 = Polygon([(6,2),(10,4),(8,7),(4,8),(2,4)])

>>> x,y = polygon1.exterior.xy

>>> plt.plot(x,y)

[<matplotlib.lines.Line2D object at 0x0000016334535040>]

>>> plt.show()

>>> from shapely.geometry import Polygon

>>> import matplotlib.pyplot as plt

>>> Iso_trangle = Polygon([(0,0),(4,0),(2,4)])

>>> x,y = Iso_trangle.exterior.xy

>>> plt.plot(x,y)

[<matplotlib.lines.Line2D object at 0x00000163345E89B0>]

>>> plt.show()
Q3)

>>> from numpy import*

>>> import matplotlib.pyplot as plt

>>> from mpl_toolkits.mplot3d import Axes3D

>>> fig = plt.figure()

>>> from pylab import*

>>> ax = axes(projection='3d')

>>> ax.scatter(70,-25,15,color='black',marker='d')

<mpl_toolkits.mplot3d.art3d.Path3DCollection object at 0x000002B1A67A7470>

>>> plt.show()

>>> from numpy import*

>>> from pylab import*

>>> from mpl_toolkits.mplot3d import Axes3D


>>> import matplotlib.pyplot as plt

>>> fig = plt.figure()

>>> ax = axes(projection='3d')

>>> ax.scatter(50,72,-45,c='green',marker='d')

<mpl_toolkits.mplot3d.art3d.Path3DCollection object at 0x000001A77BBBC200>

>>> plt.show()

>>> from numpy import*

>>> from pylab import*

>>> from mpl_toolkits.mplot3d import Axes3D

>>> import matplotlib.pyplot as plt

>>> fig = plt.figure()

>>> ax = axes(projection='3d')

>>> ax.scatter(58,-82,65,c='green',marker='d')

<mpl_toolkits.mplot3d.art3d.Path3DCollection object at 0x000001A77DE39790>

>>> plt.show()
4

>>> from numpy import*

>>> from pylab import*

>>> from mpl_toolkits.mplot3d import Axes3D

>>> import matplotlib.pyplot as plt

>>> fig = plt.figure()

>>> ax = axes(projection='3d')

>>> ax.scatter(20,72,-45,c='red',marker='d')

<mpl_toolkits.mplot3d.art3d.Path3DCollection object at 0x000001A77EC98EF0>

>>> plt.show()

You might also like