Objectives
- Compute a matrix transformation using NumPy.
- Visualize a matrix transformation using basis vectors or a grid in Matplotlib.
- Animate a visual of a Matrix Transformation.
transpose or .T function to convert if needed.Transpose() or .T to convert.transpose() function to make \(\vec{x}\) a column vector to fix the error.transpose(arrayname), or arrayname.T
meshgrid() works great for plotting a grid of points, the arrays are not the right size to act as input vectors for the matrix-vector multiplication.array.reshape(size) function that allows us to reshape each array of x-values and y-values from meshgrid() into rows. We can then row_stack() those two rows to form the desired input matrix.c= inside scatter tells Matplotlib how to assign colors to our scatterplot. Here we assign colors according to the first array in xygrid. What happens if you assign colors according to the second array inside xygrid?plot instead of scatter. Note: horizontal lines have incrementing x-values and constant y-values, while vertical lines have incrementing y-values and constant x-values. We will need to think carefully about which arrays we pass into plot..reshape() the X,Y grid into a row of x-values and a row of y-values so we can matrix multiply each point as a column of a matrix. We will then .reshape() back into a transformed meshgrid in order to graph our grid of transformed lines.scatter which has an argument c=array that allows us to color code based on an x-coordinate or y-coordinate, plot does not. To better see the effects of a reflection, we will use a sequential color map to color our lines.PillowWriter we will start with a somewhat simple .gif of the transformation, then add features.plt.cla() in Example 2.34. What happens to your animation?