[Math] Helix perpendicular to parametric equation

3dparametric

What I am trying to achieve

Firstly, this is just for fun and has no real world purpose.

I am trying to create a plot of a helix that is perpendicular to a curve. The helix is defined by a parametric equation (see below).
The helix looks almost like I wanted it to (see plots below). However, there is something wrong with my equation that causes some imperfections in certain areas of the helix (see 2D plot).

Plot: 2D view

2D plot

Plot: 3D view

3D plot

Equation for basic curve

This is the equation for the basic curve that the helix should go around. This equation produces the desired plot. In the plot it is represented by the orange line.
$$
t=[0,2\pi[\\
r_1=5\\
\omega _1=1\\
r_2=2\\
\omega _2=7\\
r_3=0.5\\
\omega _3=500\\
\\
\begin{pmatrix}
x\\
y\\
z\\
\end{pmatrix}
=
\begin{pmatrix}
r_1\cdot cos(\omega_1\cdot t)+
r_2\cdot cos(\omega_2\cdot t)\\
r_1\cdot sin(\omega_1\cdot t)+
r_2\cdot sin(\omega_2\cdot t)\\
0 \\
\end{pmatrix}
$$

Equation with the helix

This is the equation for the helix (represented by the blue lines in the plots). It produces mostly the curve that I am trying to achieve. However the helix is not everywhere exactly perpendicular to its centre (basic curve, see above). I think this is due to the red part of the equation.
$$
\begin{pmatrix}
x\\
y\\
z\\
\end{pmatrix}
=
\begin{pmatrix}
r_1\cdot cos(\omega_1\cdot t)+
r_2\cdot cos(\omega_2\cdot t)+
r_3\cdot cos(\omega_3\cdot t)
\color{red}{\cdot cos(\omega_2\cdot t)}\\
r_1\cdot sin(\omega_1\cdot t)+
r_2\cdot sin(\omega_2\cdot t)+
r_3\cdot cos(\omega_3\cdot t)
\color{red}{\cdot sin(\omega_2\cdot t)}\\
r_3 \cdot sin(\omega_3 \cdot t) \\
\end{pmatrix}
$$
Question

How do I need to change the red part of the equation in order to get a helix that is always perpendicular to its centre?

Best Answer

Let us denote your original curve by a vector function $\vec{p}$. Thus,

$$\vec{p}(t) = \begin{pmatrix} x(t)\\ y(t)\\ z(t)\\ \end{pmatrix} = \begin{pmatrix} r_1\cdot \cos(\omega_1\cdot t)+ r_2\cdot \cos(\omega_2\cdot t)\\ r_1\cdot \sin(\omega_1\cdot t)+ r_2\cdot \sin(\omega_2\cdot t)\\ 0 \\ \end{pmatrix}. $$ With this notation, the vector $\vec{p}'(t)$ obtained by differentiating componentwise $$\vec{p}'(t) = \begin{pmatrix} x'(t)\\ y'(t)\\ z'(t)\\ \end{pmatrix} $$ is tangent to the curve. Since your curve is contained in the plane, an easy way to obtain a vector perpendicular to the curve is to compute the cross product of $\vec{p}'$ with $\langle 0,0,1\rangle$. Using this, I obtained the unit normal vector $$ \vec{N}(t) = \begin{pmatrix} \frac{r_1 \omega _1 \cos \left(t \omega _1\right)+r_2 \omega _2 \cos \left(t \omega _2\right)}{\sqrt{2 r_1 r_2 \omega _2 \omega _1 \cos \left(t \left(\omega _1-\omega _2\right)\right)+r_1^2 \omega _1^2+r_2^2 \omega _2^2}}\\\frac{r_1 \omega _1 \sin \left(t \omega _1\right)+r_2 \omega _2 \sin \left(t \omega _2\right)}{\sqrt{2 r_1 r_2 \omega _2 \omega _1 \cos \left(t \left(\omega _1-\omega _2\right)\right)+r_1^2 \omega _1^2+r_2^2 \omega _2^2}}\\0 \end{pmatrix}. $$

At this point, your spiral (or, helix, really) can be parametrized by the vector function

$$\vec{p}(t) + r_3 \vec{N}(t)\cos(\omega_3 t) + r_3 \langle 0,0,1\rangle\sin(\omega_3 t).$$

Using your parameters, this produces the following pictures:

enter image description here

enter image description here

Related Question