function
function
Roll no : 2163
Program name : Study of graphical aspects of Threedimensional transformation
matrix using matplotlib
*********************************************************
Question no 1: Rotate the line passing through points A[1 1] and B[5 5] about origin through an angle 90
degree.
*************************************************************************************
>>> L=Line((1,1),(5,5))
>>> L.rotate(pi/2)
Question no 2: If the line segment joining the points A[2,5], B[4 -13] Is transformed to the line segment
A* B* by the transformation matrix [T]= [2 3] then find the midpoint of A* B*
[4 1]
2 3 0
4 1 0
0 0 1
>>> A=Point(2,5)
>>> B=Point(4,-13)
>>> A1=A.transform(Matrix([[2,3,0],[4,1,0],[0,0,1]]))
>>> B1=B.transform(Matrix([[2,3,0],[4,1,0],[0,0,1]]))
>>> L=Segment(A1,B1)
>>> L.midpoint
Point2D(-10, 5)
>>>
Question no 3: Reflect the line segment joining the points A[5 3] and B[1 4] through the line y=x+1
*************************************************************************************
>>> x,y=symbols('x,y')
>>> A=Point(5,3)
>>> B=Point(1,4)
>>> S=Segment(A,B)
>>> S.reflect(Line(x-y+1))
>>>
Question no 4: Suppose that the line segment between the points A[1 4] and B [3 6] is transformed to
the line segment A* B* using the transformation matrix [T]= 2 -1 Find slope of the transformed
line segment A* B* 1 3
*************************************************************************************
>>> A=Point(1,4)
>>> B=Point(3,6)
>>> A1=A.transform(Matrix([[2,-1,0],[1,3,0],[0,0,1]]))
>>> B1=B.transform(Matrix([[2,-1,0],[1,3,0],[0,0,1]]))
>>> L=Segment(A1,B1)
>>> L.slope
2/3
>>>
Question no 5: Find the combined transformation of the line segment between the points A[4 -1] and
B[3 0] for the following sequence of transformations : First rotation about origin through an angle πc ;
followed by scaling in x coordinate by 3 units ; followed by reflection through the line y=x.
*************************************************************************************
>>> A=Point(4,-1)
>>> B=Point(3,0)
>>> S=Segment(A,B)
>>> S=S.rotate(pi)
>>> S=S.scale(3,0)
>>> points=S.points
>>> p=points[0]
>>> q=points[1]
>>> p1=p.transform(Matrix([[0,1,0],[1,0,0],[0,0,1]]))
>>> q1=q.transform(Matrix([[0,1,0],[1,0,0],[0,0,1]]))
>>> Segment(p1,q1)
>>>