import open3d as o3d
import numpy as np
import copy
mesh_cylinder1 = o3d.geometry.TriangleMesh.create_cylinder(radius=0.05, height=0.3)
mesh_cylinder1.compute_vertex_normals()
mesh_cylinder1.paint_uniform_color([0.1, 0.1, 0.9])
mesh_cylinder2 =copy.deepcopy(mesh_cylinder1)
mesh_cylinder2.paint_uniform_color([0.1, 0.9, 0.1])
mesh_cylinder3 =copy.deepcopy(mesh_cylinder1)
mesh_cylinder3.paint_uniform_color([0.9, 0.1, 0.1])
R1 = mesh_cylinder2.get_rotation_matrix_from_xyz((np.pi / 2, 0, 0)) # x축 회전
T1 = np.eye(4)
T1[:3, :3] = R1
mesh_cylinder2.transform(T1)
print("mesh_cylinder2 회전행렬:\n", T1)
R2 = mesh_cylinder3.get_rotation_matrix_from_xyz((0, np.pi / 2, 0)) # y축 회전
T2 = np.eye(4)
T2[:3, :3] = R2
mesh_cylinder3.transform(T2)
print("mesh_cylinder3 회전행렬:\n", T2)
axis_frame = o3d.geometry.TriangleMesh.create_coordinate_frame(size=0.5, origin=[0, 0, 0])
o3d.visualization.draw_geometries([mesh_cylinder1,mesh_cylinder2,mesh_cylinder3, axis_frame],
width=500, height=500)