Mathematical Girl's Secret Note "What the Procession Draws" Demonstration of linear transformation performed by "Lisa" in Chapter 4 Transform I went with Python
Python3
Below, they are listed in the order of description in this manual.
Displayed at point (2, 1) on the graph
import matplotlib.pyplot as plt
import numpy as np
p21 = np.array([2, 1])
plt.plot(p21[0], p21[1], marker='.')
plt.show()
Matrix points (2, 1)
\begin{pmatrix}
2 & 0 \\
0 & 2
\end{pmatrix}
Linearly transform with to move to point (4, 2)
import matplotlib.pyplot as plt
import numpy as np
p21 = np.array([2, 1])
p21to42 = np.array([[2, 0], [0, 2]]) @ p21
fig = plt.figure()
ax = fig.add_subplot(111)
ax.annotate('', xy=p21to42,
xytext=p21,
arrowprops=dict(shrink=0, width=1, headwidth=8))
ax.set_xlim([0, 5])
ax.set_ylim([0, 5])
plt.plot(p21[0], p21[1], marker='.')
plt.plot(p21to42[0], p21to42[1], marker='.')
plt.show()
Matrix multiple points
\begin{pmatrix}
2 & 0 \\
0 & 2
\end{pmatrix}
Linear transformation with
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax = fig.add_subplot(111)
for x in np.linspace(-1, 1, 11):
for y in np.linspace(-1, 1, 11):
marker = '8'
if x > 0 and y > 0:
marker = '$1$'
elif x < 0 and y > 0:
marker = '$2$'
elif x < 0 and y < 0:
marker = '$3$'
elif x > 0 and y < 0:
marker = '$4$'
pOrg = np.array([x, y])
pTra = np.array([[2, 0], [0, 2]]) @ pOrg
ax.annotate('', xy=pTra,
xytext=pOrg,
arrowprops=dict(shrink=0.1, width=1, headwidth=3))
plt.plot(pOrg[0], pOrg[1], marker = marker)
plt.plot(pTra[0], pTra[1], marker = marker)
ax.set_xlim([-2, 2])
ax.set_ylim([-2, 2])
plt.show()
\begin{pmatrix}
1/2 & 0 \\
0 & 1/2
\end{pmatrix}
When linearly transformed with
\begin{pmatrix}
3 & 0 \\
0 & 2
\end{pmatrix}
When linearly transformed with
\begin{pmatrix}
2 & 1 \\
1 & 3
\end{pmatrix}
When linearly transformed with
Matrix of figures surrounded by (0, 0), (1, 0), (1, 1), (0, 1)
\begin{pmatrix}
2 & 1 \\
1 & 3
\end{pmatrix}
Matrix after conversion with
\begin{pmatrix}
0 & -1 \\
1 & 0
\end{pmatrix}
Convert with
import matplotlib.pyplot as plt
import numpy as np
fig = plt.figure()
ax1 = fig.add_subplot(131)
ax2 = fig.add_subplot(132)
ax3 = fig.add_subplot(133)
original = np.array([[0, 0], [0, 1], [1, 1], [1, 0], [0, 0]])
trans1 = np.array([[0, 0]])
trans2 = np.array([[0, 0]])
for ele in original:
_ele1 = np.array([[2, 1], [1, 3]]) @ ele
_ele2 = np.array([[0, -1], [1, 0]]) @ _ele1
trans1 = np.vstack((trans1, np.array([_ele1])))
trans2 = np.vstack((trans2, np.array([_ele2])))
ax1.plot(original[:,0], original[:,1], marker = ".", label='original')
ax2.plot(trans1[:,0], trans1[:,1], marker = ".", label='trans1')
ax3.plot(trans2[:,0], trans2[:,1], marker = ".", label='trans2')
ax1.legend(loc = 'upper center')
ax2.legend(loc = 'upper center')
ax3.legend(loc = 'upper center')
ax1.set_xlim([-4, 4])
ax1.set_ylim([-4, 4])
ax2.set_xlim([-4, 4])
ax2.set_ylim([-4, 4])
ax3.set_xlim([-4, 4])
ax3.set_ylim([-4, 4])
plt.show()
If the conversion order is different as shown in the figure below, the figure will also be different. You can see that ABx = BAx does not hold like a normal formula
Recommended Posts