2-D Transformation-1
2-D Transformation-1
import numpy as np
p=[-20,20]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
grid()
legend()
show()
# Reflected point
p=[-10,10]
q=[0,0]
plot(p,q,label='x-axis',color='black')
plot(q,p,label='y-axis',color='black')
x=matrix([[2.5,2.5]])
x1=(x[0,0],x[0,0])
y1=(x[0,1],x[0,1])
plot(x1,y1,'*',label='Given point',color='red')
t=matrix([[1,0],[0,-1]])
x=x*t
x1=(x[0,0],x[0,0])
y1=(x[0,1],x[0,1])
print(x1,y1)
plot(x1,y1,'*',label='reflected point',color='blue')
legend()
grid()
show()
# Square #
import numpy as np
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5],[5,2.5],[5,5],[2.5,5]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='original object',color='blue')
# Line #
import numpy as np
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
z=np.matrix([[-2.5,-2.5],[-5,-5]])
z1=(z[0,0],z[1,0])
z2=(z[0,1],z[1,1])
plot(z1,z2,label='original object',color='green')
grid()
import numpy as np
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5],[5,2.5],[5,5],[2.5,5]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='original object',color='blue')
x=np.matrix([[2.5,-2.5],[5,-2.5],[5,-5],[2.5,-5]])
x2=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y2=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x2,y2,label='reflected object',color='green')
grid()
legend()
show()
import numpy as np
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5],[5,2.5],[5,5],[2.5,5]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='original object',color='blue')
t=np.matrix([[1,0],[0,-1]])
x=x*t
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='Reflected Object',color='Green')
grid()
legend()
show()
import numpy as np
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
z=np.matrix([[-10,-10],[10,10]])
z1=(z[0,0],z[1,0])
z2=(z[0,1],z[1,1])
plot(z1,z2,label='Given line',color='red')
x=np.matrix([[2.5,7.5],[5,7.5],[2.5,10]])
x1=(x[0,0],x[1,0],x[2,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[0,1])
plot(x1,y1,label='original object',color='blue')
x=np.matrix([[7.5,2.5],[7.5,5],[10,2.5]])
x1=(x[0,0],x[1,0],x[2,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[0,1])
plot(x1,y1,label='reflectedl object',color='green')
grid()
legend()
show()
# Reflection through the line y=- x #
import numpy as np
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
z=np.matrix([[10,-10],[- 10,10]])
z1=(z[0,0],z[1,0])
z2=(z[0,1],z[1,1])
plot(z1,z2,label='Given line',color='red')
x=np.matrix([[2.5,7.5],[5,7.5],[2.5,10]])
x1=(x[0,0],x[1,0],x[2,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[0,1])
plot(x1,y1,label='original object',color='blue')
x=np.matrix([[-7.5,-2.5],[-7.5,-5],[-10,-2.5]])
x1=(x[0,0],x[1,0],x[2,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[0,1])
plot(x1,y1,label='reflected object',color='green')
grid()
legend()
show()
# Rotation about origin by an angle 90 #
import numpy as np
import math as m
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
a=m.cos(np.pi/2)
b=m.sin(np.pi/2)
x=np.matrix([[2.5,2.5],[5,2.5],[5,5],[2.5,5]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='original object',color='blue')
t=np.matrix([[a,b],[-b,a]])
x2=(x[0,0],x[1,0])
y2=(x[0,1],x[1,1])
x=x*t
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='Reflected Object',color='Green')
grid()
legend()
show()
# Rotation about origin by an angle 35 #
import numpy as np
import math as m
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5],[5,2.5],[5,5],[2.5,5]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='original object',color='blue')
a=m.cos(7*np.pi/36)
b=m.sin(7*np.pi/36)
t=np.matrix([[a,b],[-b,a]])
x=x*t
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
plot(x1,y1,label='Reflected Object',color='Green')
grid()
legend()
show()
# Rotation about point (2,5) #
import numpy as np
import math as m
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5,1],[5,2.5,1],[5,5,1],[2.5,5,1]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='original object',color='blue')
t1=np.matrix([[1,0,0],[0,1,0],[-2,-5,1]])
x=x*t1
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='Translated Object1',color='Green')
t2=np.matrix([[0,1,0],[-1,0,0],[0,0,1]])
x=x*t2
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='Reflected Object2',color='red')
t3=np.matrix([[1,0,0],[0,1,0],[2,5,1]])
x=x*t3
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='INV Object',color='black')
print(x1,y1,z1)
grid()
legend()
show()
import numpy as np
import math as m
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5,1],[5,2.5,1],[5,5,1],[2.5,5,1]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='original object',color='blue')
t1=np.matrix([[1,0,0],[0,1,0],[-2,-5,1]])
t2=np.matrix([[0,1,0],[-1,0,0],[0,0,1]])
t3=np.matrix([[1,0,0],[0,1,0],[2,5,1]])
t=t1*t2*t3
x=x*t
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='Rotated Object',color='black')
print(x1,y1,z1)
grid()
legend()
show()
import numpy as np
import math as m
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5,1],[5,2.5,1],[5,5,1],[2.5,5,1]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='original object',color='blue')
t1=np.matrix([[1,0,0],[0,1,0],[0,-5,1]])
x=x*t1
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='Translated Object1',color='Green')
t2=np.matrix([[1,0,0],[0,-1,0],[0,0,1]])
x=x*t2
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='Reflected Object2',color='red')
t3=np.matrix([[1,0,0],[0,1,0],[0,5,1]])
x=x*t3
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='INV Object3',color='black')
print(x1,y1,z1)
grid()
legend()
show()
import numpy as np
import math as m
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5,1],[5,2.5,1],[5,5,1],[2.5,5,1]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='original object',color='blue')
t1=np.matrix([[1,0,0],[0,1,0],[0,-5,1]])
t2=np.matrix([[1,0,0],[0,-1,0],[0,0,1]])
t3=np.matrix([[1,0,0],[0,1,0],[0,5,1]])
t=t1*t2*t3
x=x*t
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='Reflected Object3',color='black')
print(x1,y1,z1)
grid()
legend()
show()
import numpy as np
import math as m
p=[-10,10]
q=[0,0]
plot(p,q,label='x axis',color='black')
plot(q,p,label='y axis',color='black')
x=np.matrix([[2.5,2.5,1],[5,2.5,1],[5,5,1],[2.5,5,1]])
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='original object',color='blue')
t1=np.matrix([[1,0,0],[0,1,0],[0,-1,1]])
t2=np.matrix([[0.707,-0.707,0],[0.707,0.707,0],[0,0,1]])
t3=np.matrix([[1,0,0],[0,-1,0],[0,0,1]])
t4=np.matrix([[0.707,0.707,0],[-0.707,0.707,0],[0,0,1]])
t5=np.matrix([[1,0,0],[0,1,0],[0,1,1]])
t=t1*t2*t3*t4*t5
x=x*t
x1=(x[0,0],x[1,0],x[2,0],x[3,0],x[0,0])
y1=(x[0,1],x[1,1],x[2,1],x[3,1],x[0,1])
Z1=(x[0,2],x[1,2],x[2,2],x[3,2],x[0,2])
plot(x1,y1,Z1,label='Reflected Object3',color='black')
print(x1,y1,z1)
grid()
legend()
show()