Question: In Python 3.6, complete the following assignment. There is starter code posted below, just needs to be edited. Please post the correct answer, this is

In Python 3.6, complete the following assignment. There is starter code posted below, just needs to be edited. Please post the correct answer, this is the fourth time I am posting the same question. Everytime I posted this I got a random answer that had nothing to do with the question. If you don't know how to do this, then please don;t answer it and let someone else answer. Please help. Thank You!

In Python 3.6, complete the following assignment. There is starter code posted

import matplotlib.pyplot as plt import numpy as np from time import sleep # %%%%%%%%%%%%%%%%%%% # Define function to plot our object (for animations) # - You may change the axis limits for your needs # %%%%%%%%%%%%%%%%%%

def plotmat (M): plt.gcf().clear() # plt.hold(False) plt.plot(np.transpose(M[0,:]),np.transpose(M[1,:])) plt.xlim(-30,30) plt.ylim(-2,50) plt.show()

return;

# %%%%%%%%%%%%%%%%%%% # Define functions for the transformations # %%%%%%%%%%%%%%%%%% # Translation Transformation def translateM (tx, ty): Mout=np.matrix('1 0 %s; 0 1 %s; 0 0 1' % (tx,ty)) return Mout;

# Scaling Transformation

# Rotation1 Transformation

# Rotation2 Transformation

# Shearing Transformation

# And any transformation I am missing

# %%%%%%%%%%%%%%%%% # Create Your Object # - Store the vertices of the object in a 2 x n matrix where the x coordinates of the vertices are stored in first row and the y coordinates in the second row. # Each successsive pair of points is connected by a straight line. # EXAMPLE: Consider the parallelogram formed by the vertices (2,0), (1,2), (2,4) and (3,2) . # Form Object matrix using vertices as columns and adding starting vector (2,0) onto tail/end (otherwise we would be missing a line) is M=( 2 1 2 3 2; 0, 2, 4, 2 0)

M=np.matrix('6,5,6,7,8,7,6, 5,4,3,2,3,4,5 ;6,5,4,4,5,6,6, 5,4,4,5,6,6,5') # M=np.matrix('2 1 2 3 2; 0, 2, 4, 2 0')

# Add row of ones to M since we need a 3 x n matrix for the translation transformation (projected into R^3 with z=1) onesRow=np.ones(M.shape[1]) M=np.vstack((M,onesRow))

# Initiate Interactive plot plt.ion() plt.show()

# Translate 1 unit in x and 1 in y 10 times T=translateM(1,1) for j in range(0,10): M=T*M plotmat(M) plt.pause(0.4) plotmat(M) plt.pause(1) # Translate for no good reason M=translateM(-3,-8)*M plotmat(M) plt.pause(1) plt.title('Animate Object Example') plt.grid(True)

2. PART II: ANIMATIONS VIA TRANSFORMATIONS 2.1. 2D Animation (1) Create two objects each with at least 6 vertices (2) Animate these objects using (all of the following at least once) Translation Rotation around origin . Rotation about the object itself (away from the origin) Reflect the object over x-axis or y-axis or both Reflect the object over a line (i.e. line y =-x) Shearing 2. PART II: ANIMATIONS VIA TRANSFORMATIONS 2.1. 2D Animation (1) Create two objects each with at least 6 vertices (2) Animate these objects using (all of the following at least once) Translation Rotation around origin . Rotation about the object itself (away from the origin) Reflect the object over x-axis or y-axis or both Reflect the object over a line (i.e. line y =-x) Shearing

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!