Professional Documents
Culture Documents
COMputerDA 3
COMputerDA 3
LAB ASSESSMENT – 3
Name: DevaDharshini.P
Reg.No: 20MIC0162
ax.add_collection3d(poly3d)
ax.set_xlabel('X')
ax.set_ylabel('Y')
ax.set_zlabel('Z')
# De ine the vertices of the triangular pyramid
ig = plt. igure()
ax = ig.add_subplot(111, projection='3d')
ax.legend()
plt.show()
OUTPUT:
f
f
f
f
2. Perform 3D transformation on the drawn object (3)
CODE:
def translate(vertices, tx, ty, tz):
T = np.array([[1, 0, 0, tx],
[0, 1, 0, ty],
[0, 0, 1, tz],
[0, 0, 0, 1]])
translated_vertices = vertices_homogeneous.dot(T.T)
ig = plt. igure()
ax = ig.add_subplot(111, projection='3d')
translated_vertices = translate(vertices, 1, 1, 1)
ax.legend()
plt.show()
f
f
f
OUTPUT:
3. Perform 3D scaling with respect to pivot point of the drawn object
(3)
CODE:
def scale(vertices, sx, sy, sz, pivot):
S = np.array([[sx, 0, 0, 0],
[0, 0, 0, 1]])
pivot_homogeneous = np.append(pivot, 1)
vertices_homogeneous = np.c_[vertices, np.ones(len(vertices))]
pivot_homogeneous
ig = plt. igure()
ax = ig.add_subplot(111, projection='3d')
ax.legend()
plt.show()
f
f
f
OUTPUT:
4. Perform the 3D rotation concerning the x-axis, y-axis, and z-axis on
the drawn 3D object. (2)
CODE:
def rotate_x(vertices, angle, pivot):
R = np.array([[1, 0, 0, 0],
[0, 0, 0, 1]])
pivot_homogeneous = np.append(pivot, 1)
vertices_homogeneous = np.c_[vertices, np.ones(len(vertices))]
pivot_homogeneous
ig = plt. igure()
ax = ig.add_subplot(111, projection='3d')
ax.legend()
plt.show()
[0, 1, 0, 0],
[0, 0, 0, 1]])
pivot_homogeneous = np.append(pivot, 1)
f
f
f
vertices_homogeneous = np.c_[vertices, np.ones(len(vertices))]
ig = plt. igure()
ax = ig.add_subplot(111, projection='3d')
ax.legend()
plt.show()
[0, 0, 1, 0],
[0, 0, 0, 1]])
pivot_homogeneous = np.append(pivot, 1)
ig = plt. igure()
ax = ig.add_subplot(111, projection='3d')
ax.legend()
plt.show()
OUTPUT: