Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program that plots a rotated 3D image of a cube where the user can specify the rotation about the x, y and z

Write a program that plots a rotated 3D image of a cube where the user can specify the rotation about the x, y and z axis. Given a set of n, (x,y,z) coordinates, stored in a matrix as follows

:# ask user for x,y,z rotations in degrees. You will need to convert to radians for calculation

# call the rotateXYZ function with the XYZ matrix and the three rotations angles

# this function calculates the Rx, Ry and Rz matrices and calls the myMultMatrix

# three time to calculate the rotated

# XYZcalculate the three rotation matrices.

# extract the x and y vectors from the rotated matrix

# plot the data

image text in transcribed

MEGR 2810 Engineering Methods Homework Write a program that plots a rotated 3D image of a cube where the user can specify the rotation about the x, y and z axis Given a set of n, (x,y,z) coordinates, stored in a matrix as follows [o X1 X2 X3 . Xn-1 Zo Z1 Z2Z3 ...Zn-1J and rotational transformation matrices of the form 0 cos ez -sin e 0 0 sine- cose. 0 Then, the rotated (x,yz) set of coordinates is XYZrotated-Rot7x RotTx RotX XYZ Use the following x,y,z coordinates to define a cube xyz = np.array([[0, 1, 1,0,0, 0,0, 1, 1,0, 1,1,1,1, 0,0], To plot the 3D cube in 2D plot only the x and y points, connect with a line. You can extract the x and y vectors using numpy's submatrix formula as follows x xyzr[0,:] # row 0 and every column y -xyzr(1,'] # row 1 and every column Your code should have the following outline def myMultMatrix(A,B): # check for compatible matrices and return 0 if incompatible # your code to calculate C -A x B return O def rotateXYZ(XYz,rx, ry,rz): # calculate the rotation matrices and use myMultMatrix to # perform the calculations return C MEGR 2810 Engineering Methods Homework Write a program that plots a rotated 3D image of a cube where the user can specify the rotation about the x, y and z axis Given a set of n, (x,y,z) coordinates, stored in a matrix as follows [o X1 X2 X3 . Xn-1 Zo Z1 Z2Z3 ...Zn-1J and rotational transformation matrices of the form 0 cos ez -sin e 0 0 sine- cose. 0 Then, the rotated (x,yz) set of coordinates is XYZrotated-Rot7x RotTx RotX XYZ Use the following x,y,z coordinates to define a cube xyz = np.array([[0, 1, 1,0,0, 0,0, 1, 1,0, 1,1,1,1, 0,0], To plot the 3D cube in 2D plot only the x and y points, connect with a line. You can extract the x and y vectors using numpy's submatrix formula as follows x xyzr[0,:] # row 0 and every column y -xyzr(1,'] # row 1 and every column Your code should have the following outline def myMultMatrix(A,B): # check for compatible matrices and return 0 if incompatible # your code to calculate C -A x B return O def rotateXYZ(XYz,rx, ry,rz): # calculate the rotation matrices and use myMultMatrix to # perform the calculations return C

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

Oracle Database Administration The Essential Reference

Authors: Brian Laskey, David Kreines

1st Edition

1565925165, 978-1565925168

More Books

Students also viewed these Databases questions