%matplotlib inline %config InlineBackend.figure_format='retina' # import libraries import numpy as np import matplotlib as mp import pandas as pd import matplotlib.pyplot as plt import laUtilities as ut import slideUtilities as sl import demoUtilities as dm from IPython.display import Image from IPython.display import display_html from IPython.display import display from IPython.display import Math from IPython.display import Latex reload(dm) reload(ut) print '' %%html # image credit: Scan from Lay, 4th edition sl.hide_code_in_slideshow() display(Image("images/Lay-fig-1-8-1.jpg", width=450)) # image credit: Scan from Lay, 4th edition sl.hide_code_in_slideshow() display(Image("images/Lay-fig-1-8-2.jpg", width=450)) square = np.array([[0.0,1,1,0],[1,1,0,0]]) ax = dm.plotSetup(-3,3,-3,3) print square dm.plotSquare(square) ax = dm.plotSetup(-3,3,-3,3) print "square = "; print square dm.plotSquare(square) # # create the A matrix A = np.array([[1.0, 1.5],[0.0,1.0]]) print "A matrix = "; print A # # apply the shear matrix to the square ssquare = np.zeros(np.shape(square)) for i in range(4): ssquare[:,i] = dm.AxVS(A,square[:,i]) print "sheared square = "; print ssquare dm.plotSquare(ssquare,'r') sl.hide_code_in_slideshow() ax = dm.plotSetup(-3,3,-3,3) ax.plot([0],[1],'ro') ax.text(0.25,1,'(0,1)') ax.plot([1],[0],'ro') ax.text(1.25,0.25,'(1,0)') print '' # image credit: Scan from Lay, 4th edition sl.hide_code_in_slideshow() display(Image("images/rotate-example.jpeg", width=450)) ax = dm.plotSetup(-4,4,-4,4) note = dm.mnote() angle = 180.0; phi = (angle/360.0) * 2.0 * np.pi rotate = np.array([[np.cos(phi), -np.sin(phi)],[np.sin(phi), np.cos(phi)]]) rnote = rotate.dot(note) dm.plotShape(rnote) sl.hide_code_in_slideshow() ax = dm.plotSetup(-3,3,-3,3) ax.plot([0],[1],'ro') ax.text(0.25,1,'(0,1)') ax.plot([1],[0],'ro') ax.text(1.25,0.25,'(1,0)') print '' A = np.array([[2.5,0],[0,2.5]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') sl.hide_code_in_slideshow() ax = dm.plotSetup(-3,3,-3,3) ax.plot([0],[1],'ro') ax.text(0.25,1,'(0,1)') ax.plot([1],[0],'ro') ax.text(1.25,0.25,'(1,0)') print '' A = np.array([[1,0],[0,-1]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') Latex(r'Reflection through the $x_1$ axis') A = np.array([[-1,0],[0,1]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') Latex(r'Reflection through the $x_2$ axis') A = np.array([[0,1],[1,0]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') plt.plot([-2,2],[-2,2],'b--') Latex(r'Reflection through the line $x_1 = x_2$') A = np.array([[0,-1],[-1,0]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') plt.plot([-2,2],[2,-2],'b--') Latex(r'Reflection through the line $x_1 = -x_2$') A = np.array([[-1,0],[0,-1]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') Latex(r'Reflection through the origin') A = np.array([[0.45,0],[0,1]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') ax.arrow(1.0,1.5,-1.0,0,head_width=0.15, head_length=0.1, length_includes_head=True) Latex(r'Horizontal Contraction') A = np.array([[2.5,0],[0,1]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') Latex(r'Horizontal Expansion') A = np.array([[1,0],[-1.5,1]]) print A ax = dm.plotSetup(-3,3,-3,3) dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') Latex(r'Vertical Shear') A = np.array([[1,0],[0,0]]) print A ax = dm.plotSetup(-3,3,-3,3) # dm.plotSquare(square) dm.plotSquare(A.dot(square),'r') # ax.arrow(1.0,1.0,0,-0.9,head_width=0.15, head_length=0.1, length_includes_head=True) # ax.arrow(0.0,1.0,0,-0.9,head_width=0.15, head_length=0.1, length_includes_head=True) Latex(r'Projection onto the $x_1$ axis') A = np.array([[0,0],[0,1]]) print A ax = dm.plotSetup(-3,3,-3,3) # dm.plotSquare(square) dm.plotSquare(A.dot(square)) #ax.arrow(1.0,1.0,-0.9,0,head_width=0.15, head_length=0.1, length_includes_head=True) #ax.arrow(1.0,0.0,-0.9,0,head_width=0.15, head_length=0.1, length_includes_head=True) Latex(r'Projection onto the $x_2$ axis') # image credit: Scan from Lay, 4th edition sl.hide_code_in_slideshow() display(Image("images/Lay-fig-1-9-3.jpeg", width=450)) # image credit: Scan from Lay, 4th edition sl.hide_code_in_slideshow() display(Image("images/Lay-fig-1-9-4.jpeg", width=450))