Set of Equations to Helically Wrap a Sine Curve

pythontrigonometry

I am attempting to plot (3d) a Sine Curve along a helical path. Very similar to the following answer, but I need to be able to control the phase and angular frequency of the sine curve as well and this answer does not provide expected results when modifying the inputs in Python: https://math.stackexchange.com/a/828579/1176881

So, I need to wrap the following curve:
$$
f(x) = A*sin(\omega x+\phi) + y_{shift}
$$

Around a cylinder of radius $r$ with z-angle (helical angle) of $\theta$.

Again, when I tried the above community answer, I did not get expected results when modifying the input parameters to the sine curve. Additionally, that answer does not say how to modify the angular frequency or the cylinder radius and I am guessing I did not apply it properly.

For reference, here is my Python code thus far:

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.mplot3d import Axes3D                         
from mpl_toolkits.mplot3d import proj3d    


tmin = 0
tmax = 100

diam = 50
res = 1e6 # point resolution
amp = 100 # amplitude of sine wave
freq = 20 # frequency of sine wave
t = np.linspace(tmin,tmax,int(res)) # primary axis (time, etc)
theta = 5 # deg, tilting angle of sine wave
omega = freq*2*np.pi

x = diam * (np.cos(t*np.cos(np.radians(theta)) - amp*np.sin(np.radians(theta))*np.sin(freq*t)))
y = diam * (np.sin(t*np.cos(np.radians(theta)) - amp*np.sin(np.radians(theta))*np.sin(freq*t)))
z = t*np.sin(np.radians(theta)) + amp*np.cos(np.radians(theta))*np.sin(freq*t)


plt.close('all')       
fig = plt.figure()

ax = fig.add_subplot(1,2,1, projection='3d')
ax.plot(x,y,z)
ax.set_box_aspect((np.ptp(x), np.ptp(y), np.ptp(z)))  # aspect ratio is 1:1:1 in data space


ax2 = fig.add_subplot(1,2,2)
ax2.plot(x,z)

plt.show()
```

Best Answer

Given an arc of a cylindrical helix of radius $r>0$ and pitch $p>0$:

$$ \mathbf{r}(t) = \left(r\cos t,\;r\sin t,\;\frac{p}{2\pi}t\right) \quad \quad \quad \text{with} \; t \in [0,T] $$

computed the respective tangent, normal and binormal unit vectors:

$$ \mathbf{t}(t) = \frac{\mathbf{r}'(t)}{||\mathbf{r}'(t)||}, \quad \quad \quad \mathbf{n}(t) = \frac{\mathbf{t}'(t)}{||\mathbf{t}'(t)||}, \quad \quad \quad \mathbf{b}(t) = \mathbf{t}(t) \times \mathbf{n}(t) $$

the graph of $f(t)$ along the helical arc and adherent to the cylinder has parametric equations:

$$ \mathbf{r}^*(t) = \mathbf{r}(t) + f(t)\,\mathbf{b}(t) $$

that is, in full:

$$ \mathbf{r}^*(t) = \left(r\cos t + \frac{f(t)\sin t}{\sqrt{1+\left(\frac{2\pi r}{p}\right)^2}},\;r\sin t - \frac{f(t)\cos t}{\sqrt{1+\left(\frac{2\pi r}{p}\right)^2}},\;\frac{p}{2\pi}t + \frac{f(t)}{\sqrt{1+\left(\frac{p}{2\pi r}\right)^2}}\right). $$

Naturally, due to the relation $\tan\theta=p/(2\pi r)$, these equations also take the form:

$$ \boxed{\mathbf{r}^*(t) = \left(r\cos t + f(t)\sin\theta\sin t,\;r\sin t - f(t)\sin\theta\cos t,\;r\,t\tan\theta + f(t)\cos\theta\,\right)}\,. $$

$\quad\quad\quad\quad\quad\quad\quad\quad\quad\quad$enter image description here

Related Question