Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Help with numpy in python for matrix calculations! We can also represent the rotation operation using matrices as well. Given a point (x,y) the rotated
Help with numpy in python for matrix calculations!
We can also represent the rotation operation using matrices as well. Given a point (x,y) the rotated point around the origin is given by (you will later learn how to derive these equations): x=xcosysiny=xsin+ycos Check your answers! Using the equations above, create and plot a rotation 90 degrees counter-clockwise around the origin. Hint: how can you turn the above into a matrix? Can you rewrite this as [xy]=A[xy] ? First store the rotation matrix in rotation (note: use radians with np.pi ): \#grade (enter your code in this cell - DO NOT DELETE THIS LINE) Then store the rotated bunny in bunny_rot : \#grade (enter your code in this cell - DO NOT DELETE THIS LINE) What does the rotation matrix look like? Is the structure similar to the identity matrix and mirror transformation from above? Plot the rotated bunny below: ax=plt.gca() ax.set_aspect('equal') ax.plot(bunny_rot [], bunny_rot[1], 'o-') By multiplying these matrices together, we can combine multiple operations into one matrix: TrotTscalex=(TrotTscale)x=Tbothx Note that the first transformation we apply is first on the left multiplying our vector - matrix multiplication in general is not commutative so this distinction is important. Check your answers! Try creating a transformation matrix that first scales points by two in each direction, then rotates 90 degrees around the origin. Store the transformed bunny in bunny_trans . \#grade (enter your code in this cell - DO NOT DELETE THIS LINE)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started