Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the 5th time I am posting the same question. Please help me with this assignment. We are using Python 3.6 to code this

This is the 5th time I am posting the same question. Please help me with this assignment. We are using Python 3.6 to code this and I have also provided the starter code, which just needs to be edited in order to add one more object and the functions for the transformations. Please help. If you do not know how to do this, then please don't post the wrong answer. Everytime I posted this before I would get an answer that had nothing to do with the question; it was a random answer. So please help and provide the correct code. Thank You!

image text in transcribed

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(-10,20) plt.ylim(-2,30) 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 (around origin) Transformation

# Rotation2 (away from origin) Transformation

#Reflection over x-axis (or y-axis)

#Reflection over line

# 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;6,5,4,4,5,6,6')

# 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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Management With Website Development Applications

Authors: Greg Riccardi

1st Edition

0201743876, 978-0201743876

More Books

Students also viewed these Databases questions