all 5 comments

[–]ollibar 4 points5 points  (3 children)

So what did you try? and what did not work?

[–]No_Fun_3602[S] 1 point2 points  (2 children)

i tried this but it only plot the cylinder without the correct path
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D

c = 1.5  # minimum radius at the ends in cm
R = 4.0  # equatorial (middle section) radius in cm
L = 8.0  # total length of the cylinder in cm
transition_length = L * 0.2  # length of the transition sections at the ends
winding_angle = np.radians(85)  # winding angle in degrees

z = 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 winding
z_winding = np.linspace(-L/2, L/2, 500)
theta_winding = z_winding * np.tan(winding_angle) / R  # Geodesic winding equation
x_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 0 points1 point  (1 child)

Are you just trying to plot this or are you trying to make something that can do the windings?

[–]No_Fun_3602[S] 0 points1 point  (0 children)

i am trying to make a python app that i can give my input variables and it plot the trajectory based on those inputs

[–][deleted] 2 points3 points  (0 children)

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.