I have been trying this research using python but i cant seem to get it working
I would like to write the python code that would help me plot the figures in figure 21.
please help
5 comments · 78% upvoted · other discussions
I would like to write the python code that would help me plot the figures in figure 21.
please help
5 comments · 78% upvoted · other discussions
Matplotlib can do that. Have a look at the simple plot on the matplotlib gallery page. Install matplotlib, copy/paste the code in the example page to a file and execute it. You should get the same plot shown in the example. Then make changes to get closer to what you want. You will have to change the t data to match your time range, and change the s list to hold your data. Also change the Y axis label. You can use unicode symbols and LaTeX. You will have to search on how to do things like sub- and super-scripts.
So what did you try? and what did not work?
No_Fun_3602 [OP] 2 points · Nov 2024
i tried this but it only plot the cylinder without the correct path
import numpy as npimport matplotlib.pyplot as pltfrom mpl_toolkits.mplot3d import Axes3Dc = 1.5 # minimum radius at the ends in cmR = 4.0 # equatorial (middle section) radius in cmL = 8.0 # total length of the cylinder in cmtransition_length = L * 0.2 # length of the transition sections at the endswinding_angle = np.radians(85) # winding angle in degreesz = np.linspace(-L/2, L/2, 100)radii = np.piecewise(z,[z < -L/2 + transition_length,(z >= -L/2 + transition_length) & (z <= L/2 - transition_length),z > L/2 - transition_length],[lambda z: c + (R - c) * np.sqrt(1 - ((z + L/2 - transition_length) / transition_length) ** 2),R,lambda z: c + (R - c) * np.sqrt(1 - ((L/2 - transition_length - z) / transition_length) ** 2)])theta = np.linspace(0, 2 * np.pi, 100)theta_grid, z_grid = np.meshgrid(theta, z)x_grid = np.outer(radii, np.cos(theta))y_grid = np.outer(radii, np.sin(theta))n_turns = 5 # Number of turns for the windingz_winding = np.linspace(-L/2, L/2, 500)theta_winding = z_winding * np.tan(winding_angle) / R # Geodesic winding equationx_winding = R * np.cos(theta_winding)y_winding = R * np.sin(theta_winding)fig = plt.figure(figsize=(8, 6))ax = fig.add_subplot(111, projection='3d')ax.plot_surface(x_grid, y_grid, z_grid, color='cyan', alpha=0.7, edgecolor='k')ax.plot(x_winding, y_winding, z_winding, color='red', linewidth=2, label="Geodesic Helical Winding")ax.set_xlabel('X (cm)')ax.set_ylabel('Y (cm)')ax.set_zlabel('Z (cm)')ax.set_title('3D Model of Cylinder with Geodesic Helical Winding')ax.legend()plt.show()Ajax_Minor 1 points · Nov 2024
Are you just trying to plot this or are you trying to make something that can do the windings?
No_Fun_3602 [OP] 1 points · Nov 2024
i am trying to make a python app that i can give my input variables and it plot the trajectory based on those inputs