Question: 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

Write a program that plots a rotated 3D image of a cube

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

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!