Application of Linear Transformation: Pororo (선형변환의 응용: 뽀로로)
Shears on $$$$R^2$$$$
The transformation matrix $$$$S$$$$ for a shear with $$$$x$$$$-axis and ratio $$$$r$$$$ is $$$$\begin{bmatrix} 1 & r \\ 0 & 1 \end{bmatrix}$$$$,
and the transformation matrix $$$$S$$$$ for a shear with $$$$y$$$$-axis and ratio $$$$r$$$$ is $$$$\begin{bmatrix} 1 & 0 \\ r & 1 \end{bmatrix}$$$$.
Rotation
The transformation matrix $$$$T$$$$ for a rotation of a point through an angle $$$$\theta$$$$ about the origin is
$$$$T=\begin{bmatrix} cos \theta & -sin \theta \\ sin \theta & cos \theta \end{bmatrix}$$$$.
@interact
def _(d=('x축', (1,3,0.1)), e=('y축', (1,3,0.1)), g=('회전', (-pi(),pi(),pi()/180))): #x,y축방향으로 확대비율과 회전각을 정의한다.
d=round(d,0)
e=round(e,0)
PP = polygon([(x,f(x)) for x in range(20,41,1)] + [(x,f1(x)) for x in range(40,35,-1)] + [(35,f1(35)),(35,35),(25,35),(25,f1(25))]+ [(x,f1(x)) for x in range(25,19,-1)], rgbcolor =(1,1,0) )
PP += polygon([(x,f(x)) for x in range(27,34,1)] + [(x,f2(x)) for x in range(33,26,-1)], rgbcolor =(0,1,1) )
PP += polygon([(x,f1(x)) for x in range(25,36,1)] + [(x,f3(x)) for x in range(35,24,-1)] , rgbcolor =(0,0,1) )
PP += polygon([(30,33),(32,35),(28,35)], rgbcolor =(0,0,1) )
PP += polygon([(x,f2(x)+0.1) for x in range(25,36,1)] + [(x,f2(x)-0.1) for x in range(35,24,-1)] , rgbcolor =(0,0,0) )
PP += polygon([(30,34),(31,35),(29,35)], rgbcolor =(0,0,1) )
PP += polygon([(x,f4(x)) for x in range(28,33,1)] + [(x,f5(x)) for x in range(32,27,-1)], rgbcolor =(1,0.5,0) )
PP += circle((27.5,30),0.2,thickness=5)
PP += circle((32.5,30),0.2,thickness=5)
PP += polygon([(30,24),(31,25),(29,25)], rgbcolor =(1,0,0) )
PP += parametric_plot((27.5+c(t),30+s(t)),(t,0,2*pi),rgbcolor =(1,0.5,0) ,thickness=10)
PP += parametric_plot((32.5+c(t),30+s(t)),(t,0,2*pi),rgbcolor =(1,0.5,0) ,thickness=10) # 선형변환전의 뽀로로를 그린다
P = polygon([(x,f(x)) for x in range(20,41,1)] + [(x,f1(x)) for x in range(40,35,-1)] + [(35,f1(35)),(35,35),(25,35),(25,f1(25))]+ [(x,f1(x)) for x in range(25,19,-1)], rgbcolor =(1,1,0) )
P += polygon([(x,f(x)) for x in range(27,34,1)] + [(x,f2(x)) for x in range(33,26,-1)], rgbcolor =(0,1,1) )
P += polygon([(x,f1(x)) for x in range(25,36,1)] + [(x,f3(x)) for x in range(35,24,-1)] , rgbcolor =(0,0,1) )
P += polygon([(30,33),(32,35),(28,35)], rgbcolor =(0,0,1) )
P += polygon([(x,f2(x)+0.1) for x in range(25,36,1)] + [(x,f2(x)-0.1) for x in range(35,24,-1)] , rgbcolor =(0,0,0) )
P += polygon([(30,34),(31,35),(29,35)], rgbcolor =(0,0,1) )
P += polygon([(x,f4(x)) for x in range(28,33,1)] + [(x,f5(x)) for x in range(32,27,-1)], rgbcolor =(1,0.5,0) )
P += circle((27.5,30),0.2,thickness=5)
P += circle((32.5,30),0.2,thickness=5)
P += polygon([(30,24),(31,25),(29,25)], rgbcolor =(1,0,0) )
h = cos(g)
i = sin(g)
A = matrix(2,2,[d,0,0,e]) #translation matrix을 정의한다.
B = matrix(2,2,[h,-i,i,h])#rotation matrix을 정의한다.
C = B*A # RT를 계산한다.
c11 = C[0][0]
c12 = C[0][1]
c21 = C[1][0]
c22 = C[1][1]
P += parametric_plot((27.5+c11*c(t)+c12*s(t),30+c21*c(t)+c22*s(t)),(t,0,2*pi),rgbcolor =(1,0.5,0) ,thickness=10)
P += parametric_plot((32.5+c11*c(t)+c12*s(t),30+c21*c(t)+c22*s(t)),(t,0,2*pi),rgbcolor =(1,0.5,0) ,thickness=10) #선형변환후의 뽀로로를 그린다
AS=matrix(2,2,[c(t),-s(t),s(t),c(t)])
AS1=matrix(2,2,[a,0,0,b])
PPP = 'linear transformation $T: R^2 \mapsto R^2$'
PPP += '<p>Rotation : $R_{t}= %s$ '%(latex(AS))
PPP += '<p>Translation= $T=%s$ '%(latex(AS1))
PPP += '<p>when in the x-direction with factor <b><i>a</i></b>,'
PPP += '<p>in the y-direction with factor <b><i>b</i></b>'#정의를 출력한다.
d1=round(d,2)
e1=round(e,2)
PPPP = 'sol) The image under a rotation $%s$ '%(latex(g))
PPPP += '<p>and in the x-direction with factor $%s$'%(latex(d1))
PPPP += '<p>and in the y-direction with factor $%s$'%(latex(e1))
PPPP += '<p>so $ R= %s ,<p/>$'%(latex(B))
PPPP += '<p> $ T= %s <p/>$'%(latex(A))
PPPP += '<p> $ \Rightarrow RT=%s <p/>$'%(latex(C)) #계산과정을 출력한다.