I have two coils, which I make with code from here
I want to add the coils together, like cos(x) + cos(2x), to get a new one. But I am not sure this is even possible with how I made them. Can it be done?
If it can't be done, I would appreciate any help in drawing helices using mathematical functions -- it would then be trivial to add them. I tried this first but couldn't figure it out.
The code is:
\documentclass[11pt]{article}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usetikzlibrary{calc,intersections,through}
\usetikzlibrary{bending}
\usetikzlibrary{shapes.geometric}
\tikzset{point/.style={circle,inner sep=0pt,minimum size=3pt,fill=black}}
\usetikzlibrary{arrows}
\usetikzlibrary{decorations.pathmorphing}
\makeatletter
% gluon decoration (based on the original coil decoration)
\pgfdeclaredecoration{gluon}{coil}
{
\state{coil}[switch if less than=%
0.5\pgfdecorationsegmentlength+%>
\pgfdecorationsegmentaspect\pgfdecorationsegmentamplitude+%
\pgfdecorationsegmentaspect\pgfdecorationsegmentamplitude to last,
width=+\pgfdecorationsegmentlength]
{
\pgfpathcurveto
{\pgfpoint@oncoil{0 }{ 0.555}{1}}
{\pgfpoint@oncoil{0.445}{ 1 }{2}}
{\pgfpoint@oncoil{1 }{ 1 }{3}}
\pgfpathcurveto
{\pgfpoint@oncoil{1.555}{ 1 }{4}}
{\pgfpoint@oncoil{2 }{ 0.555}{5}}
{\pgfpoint@oncoil{2 }{ 0 }{6}}
\pgfpathcurveto
{\pgfpoint@oncoil{2 }{-0.555}{7}}
{\pgfpoint@oncoil{1.555}{-1 }{8}}
{\pgfpoint@oncoil{1 }{-1 }{9}}
\pgfpathcurveto
{\pgfpoint@oncoil{0.445}{-1 }{10}}
{\pgfpoint@oncoil{0 }{-0.555}{11}}
{\pgfpoint@oncoil{0 }{ 0 }{12}}
}
\state{last}[next state=final]
{
\pgfpathcurveto
{\pgfpoint@oncoil{0 }{ 0.555}{1}}
{\pgfpoint@oncoil{0.445}{ 1 }{2}}
{\pgfpoint@oncoil{1 }{ 1 }{3}}
\pgfpathcurveto
{\pgfpoint@oncoil{1.555}{ 1 }{4}}
{\pgfpoint@oncoil{2 }{ 0.555}{5}}
{\pgfpoint@oncoil{2 }{ 0 }{6}}
}
\state{final}{}
}
\def\pgfpoint@oncoil#1#2#3{%
\pgf@x=#1\pgfdecorationsegmentamplitude%
\pgf@x=\pgfdecorationsegmentaspect\pgf@x%
\pgf@y=#2\pgfdecorationsegmentamplitude%
\pgf@xa=0.083333333333\pgfdecorationsegmentlength%
\advance\pgf@x by#3\pgf@xa%
}
\makeatother
\begin{document}
\begin{center}
\begin{tikzpicture}
\draw[very thick,rotate=90,decoration={
aspect=0.41,
segment length=.5cm,
amplitude=.5cm,
gluon},
decorate,] (0,10) --(0,0);
\end{tikzpicture}
\medskip
\begin{tikzpicture}
\draw[very thick,rotate=90,decoration={
aspect=0.41,
segment length=.25cm,
amplitude=.25cm,
gluon},
decorate,] (0,10) --(0,0);
\end{tikzpicture}
\end{center}
\end{document}


