Symetrizace matice transformace#
import numpy as np
np.set_printoptions(precision=3, suppress=True)
from numpy import sqrt, sin, cos, pi
import matplotlib.pyplot as plt
from matplotlib.patches import Polygon
vzory=np.array([[0,0],[1,0],[1,1],[.5,1.6],[0,1],[0,0]]).T
plt.plot(*vzory)
plt.gca().set_aspect('equal')
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
Cell In[1], line 1
----> 1 import numpy as np
2 np.set_printoptions(precision=3, suppress=True)
3 from numpy import sqrt, sin, cos, pi
ModuleNotFoundError: No module named 'numpy'
Modrý domeček postupně zobrazujeme různými maticemi.
import numpy as np
A=np.array([[.1,0.25],[0.05,-.2]])
AT=A.transpose()
B_sym=(A+AT)/2
B_asym=(A-AT)/2
def transformuj(M, vzory=vzory):
obrazy = (np.eye(2) + M) @ vzory
fig,ax = plt.subplots(figsize=(8,8))
poly = Polygon(vzory.T, facecolor='C0', alpha=0.5)
ax.add_patch(poly)
poly = Polygon(obrazy.T, facecolor='C1', alpha=0.5)
ax.add_patch(poly)
ax.plot(*vzory, *obrazy)
ax.set(title=M)
ax.set_aspect('equal')
ax.grid()
for M in [A,B_sym, B_asym]:
transformuj(M)