from __future__ import division, print_function import numpy as np from mayavi import mlab from Space.Coordinates import Cartesian from Space.Curve.Parametric import Helix from Space.Pathfinder import line_between_two_points, helix_between_two_points, arc_between_two_points import Space_visualization as Visual coordinate_system = Cartesian() coordinate_system.rotate_axis_angle(np.ones(3), np.deg2rad(45)) fig = mlab.figure('CS demo', bgcolor=(0, 0, 0)) Visual.draw_coordinate_system_axes(fig, coordinate_system) right_helix = Helix(name='Right Helix', coordinate_system=coordinate_system, radius=2, pitch=0.5, start=0, stop=np.pi * 4, right=True) left_helix = Helix(name='Left Helix', coordinate_system=coordinate_system, radius=2, pitch=0.5, start=0, stop=np.pi * 2, right=False) print('Helix length:', left_helix.length()) right_helix_view = Visual.CurveView(fig=fig, curve=right_helix) right_helix_view.draw() left_helix_view = Visual.CurveView(fig=fig, curve=left_helix) left_helix_view.draw() point1 = np.array([1, 1, 0]) point2 = np.array([2, 2, 0]) points = np.vstack((coordinate_system.to_parent(point1), coordinate_system.to_parent(point2)))
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()