# Create cartesian coordinate system # if you don't pass arguments the basis coincide with 'Absolute' (mayavi) coordinate system CS_1 = Cartesian(origin=np.array([0, 0, 0]), euler_angles_convention='bunge') CS_2 = Cartesian(origin=np.array([3, 0, 0]), euler_angles_convention='bunge') CS_3 = Cartesian(origin=np.array([6, 0, 0]), euler_angles_convention='bunge') CS_4 = Cartesian(origin=np.array([0, 3, 0]), euler_angles_convention='bunge') CS_5 = Cartesian(origin=np.array([3, 3, 0]), euler_angles_convention='bunge') CS_6 = Cartesian(origin=np.array([6, 3, 0]), euler_angles_convention='bunge') step = 1.0 # in degrees # to visualise the coordinate system basis the module Visual is used fig = mlab.figure('CS demo', bgcolor=(0.5, 0.5, 0.5)) # Create the mayavi figure cs_box_1, arrows_1, labels_1 = Visual.draw_coordinate_system_box(fig, CS_1) cs_box_2, arrows_2, labels_2 = Visual.draw_coordinate_system_box(fig, CS_2) cs_box_3, arrows_3, labels_3 = Visual.draw_coordinate_system_box(fig, CS_3) cs_box_4, arrows_4, labels_4 = Visual.draw_coordinate_system_box(fig, CS_4) cs_box_5, arrows_5, labels_5 = Visual.draw_coordinate_system_box(fig, CS_5) cs_box_6, arrows_6, labels_6 = Visual.draw_coordinate_system_box(fig, CS_6) direction = 1 @mlab.show @mlab.animate(delay=10) def anim(): direction = 1 while True: CS_1.rotate_axis_angle(np.array([0, 1, 0]), np.deg2rad(step)) # this is inplace transform CS_2.rotate_axis_angle(np.array([1, 0, 0]), np.deg2rad(step)) # this is inplace transform CS_3.rotate_axis_angle(np.array([0, 0, 1]), np.deg2rad(step)) # this is inplace transform
from Space.Coordinates import Cartesian import Space_visualization as Visual # Euler's angles are used in the proper notation Z (phi1) - X' (Phi) - Z" (phi2) # phi1 and phi2 are defined to have modulo 2*pi radians [-pi; pi] or [0; 2*pi] # Phi is defined to have modulo pi radians [-pi/2; pi/2] or [0; pi] M = 10 N = 5 # Here we use degrees and numpy deg2rad for conversion scale = min(360 / (2 * M), 180 / (2 * N)) # scale factor for mayavi scene fig = mlab.figure('CS demo', bgcolor=(0, 0, 0)) # Create the mayavi figure for phi1 in np.linspace(0, 360, M, endpoint=True): for Phi in np.linspace(0, 180, N, endpoint=True): for phi2 in np.linspace(0, 360, M, endpoint=True): euler_angles = np.deg2rad(np.array([phi1, Phi, phi2])) # Create cartesian coordinate system CS = Cartesian(origin=np.array([phi1, Phi, phi2]), labels=['i1', 'i2', 'i3'],) #euler_angles_convention='Bunge') # Set CS orientation using Euler's angles CS.euler_angles = euler_angles # CS_box visualize CS as a cube colored according to Euler's angles Visual.draw_coordinate_system_box(fig, CS, scale=scale, draw_axes=False) # mlab.outline(extent=[0, 360, 0, 180, 0, 360]) # uncomment to draw white outline mlab.show()
import Space_visualization as Visual # Create cartesian coordinate system # if you don't pass arguments the basis coincide with 'Absolute' (mayavi) coordinate system CS_1 = Cartesian(origin=np.array([0, 0, 0]), euler_angles_convention='Bunge') CS_2 = Cartesian(origin=np.array([0, 0, 0]), euler_angles_convention='Bunge') step_prec = 1.0 # in degrees step_rot = 1.0 # in degrees direction_prec = 1 direction_rot = 1 Phi = 30 # tilt in degrees CS_1.euler_angles += np.array([0, np.deg2rad(Phi), 0]) # tilt the CS # to visualise the coordinate system basis the module Visual is used fig = mlab.figure('CS demo', bgcolor=(0, 0, 0)) # Create the mayavi figure cs_box_1, arrows_1, labels_1 = Visual.draw_coordinate_system_box(fig, CS_1, draw_labels=True) arrows_2, labels_2 = Visual.draw_coordinate_system_axes(fig, CS_2, scale=2, draw_labels=True) @mlab.show @mlab.animate(delay=10) def anim(): while 1: delta_eulers = np.array([direction_prec * np.deg2rad(step_prec), 0, direction_rot * np.deg2rad(step_rot)]) CS_1.euler_angles += delta_eulers Visual.update_coordinate_system_box(CS_1, cs_box_1, arrows_1, labels_1) yield anim()