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

Assignment 3 python

The document contains a series of programming assignments using the SymPy library for geometric computations. It covers topics such as line reflection, polygon rotation, triangle area and perimeter calculations, point collinearity, and transformations. Each question includes code snippets and expected outputs for various geometric shapes and properties.

Uploaded by

munnabhaiya.7001
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Assignment 3 python

The document contains a series of programming assignments using the SymPy library for geometric computations. It covers topics such as line reflection, polygon rotation, triangle area and perimeter calculations, point collinearity, and transformations. Each question includes code snippets and expected outputs for various geometric shapes and properties.

Uploaded by

munnabhaiya.7001
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Assignment -3

Q.1
from sympy import*
L=Line(Point(5,3),Point(1,4))

x,y=symbols('x,y')
L1=Line(x-y+1)
#reflection of L through L1
Line=L.reflect(L1)
Line.equation()

>> 4x+y-14

Q.2
from sympy import*
p1,p2,p3,p4=[(0,0),(2,0),(2,3),(1,6)]

P=Polygon(p1,p2,p3,p4)
P.rotate(pi)
>>Polygon (Point 2D (0, 0), Point 2D (-2, 0), Point 2D (-2, -3), Point 2D (-1,6))

Q.3

from sympy import*


p1,p2,p3=[(0,0),(5,0),(3,3)]
P=Triangle(p1,p2,p3)
print(P.area)
print(P.perimeter)

>>15/2
sqrt(13) + 3*sqrt(2) + 5

Q.4
from sympy import*
A,B,C=[(0,2),(5,2),(3,0)]
print(Point.is_collinear(A,B,C))

L=Line(Point(0,2),Point(5,2))
L.distance(C)
>> False
2

Q.5
from sympy import*
P=RegularPolygon(Point(1,2),1,6)
print(P.area)
print(P.perimeter)

>>3*sqrt(3)/2
6

Q.6
from sympy import*

A,B,C=[(0,0),(6,0),(4,4)]
P=Triangle(A,B,C)
print(P.area)
print(P.perimeter)
>>12

2^ * sqrt(5)+4^ * sqrt(2) + 6

Q.7
from sympy import*
A=Point(2,1)
B=Point(4,-1)
A1=A.transform(Matrix([[1,2,0],[2,1,0],[0,0,1]]))
B1=B.transform(Matrix([[1,2,0],[2,1,0],[0,0,1]]))
L=Line(A1,B1)

L.equation()
>> -2x-2y+18

Q.8
from sympy import*

A=Point(0,0)
B=Point(10,10)
L=Segment(A,B)
L.midpoint
>> Point 2D (5,5)

Q.9
from sympy import*
A=Point(3,1)
B=Point(5,-1)

A1=A.transform(Matrix([[1,2,0],[2,1,0],[0,0,1]]))
B1=B.transform(Matrix([[3,2,0],[-2,1,0],[0,0,1]]))
L=Line(A1,B1)
L.equation()
>> -2x+12y-74

Q.12
from sympy import*
T=Triangle(Point(0,0),Point(4,0),Point(4,3))
T.is_right()
T.is_isosceles()
T.is_scalene()
>> True

You might also like