The source of the difficulty is that ellipses are constructed in a particular way in TikZ. They are paths that start from the x-axis and proceed counter-clockwise around their centre. The vast majority of the time, the exact parametrisation doesn't matter. You appear to have found the one situation where it does!
In the actual question, you only want to be able to mirror the ellipse, and so draw it starting from the negative x-axis (the title of the question suggests a more flexible approach). That's actually not too hard since we can exploit the symmetry of the ellipse. The key is to provide it with a negative x-radius, since then it will start from the negative x-axis (and proceed clockwise, but we could correct for that by negating the y-radius as well). To do this, we interrupt the call from the node shape to the drawing command and flip the sign of the x-radius. The simplest way to do this is to redefine the \pgfpathellipse
macro to do the negation and then call the original macro. The following code does this.
\documentclass{article}
\usepackage{tikz}
\usetikzlibrary{decorations,shapes,decorations.markings}
\makeatletter
\let\origpgfpathellipse=\pgfpathellipse
\def\revpgfpathellipse#1#2#3{%
#2%
\pgf@xa=-\pgf@x
\origpgfpathellipse{#1}{\pgfqpoint{\pgf@xa}{0pt}}{#3}}
\makeatother
\tikzset{
reversed ellipse/.style={
ellipse,
reverse the ellipse%
},
reverse the ellipse/.code={
\let\pgfpathellipse=\revpgfpathellipse
}
}
\begin{document}
\begin{tikzpicture}
\node[ellipse,
draw,
postaction={
decorate,
decoration={
markings,
mark=at position 1 with {
\arrow[line width=5pt,blue]{>}
}
}
}
] at (0,0) {hello world};
\node[reversed ellipse,
draw,
postaction={
decorate,
decoration={
markings,
mark=at position 1 with {
\arrow[line width=5pt,blue]{>}
}
}
}
] at (0,-2) {hello world};
\end{tikzpicture}
\end{document}
Here's the result:
![rotated ellipse](https://i.stack.imgur.com/wUjPy.png)
(the arrow got clipped, but you can see where it lies)
TikZ isn't great at drawing (curvy) 3D stuff, usually you have to use tricks of some sort. Here I just defined a 2D shape of the wave and then drew it 100 times in front of each other to achieve a 3D look.
Code
\documentclass[tikz, border=2mm]{standalone}
\usetikzlibrary{3d}
\usepackage{xifthen}
\makeatletter
\tikzoption{canvas is xy plane at z}[]{%
\def\tikz@plane@origin{\pgfpointxyz{0}{0}{#1}}%
\def\tikz@plane@x{\pgfpointxyz{1}{0}{#1}}%
\def\tikz@plane@y{\pgfpointxyz{0}{1}{#1}}%
\tikz@canvas@is@plane
}
\makeatother
\tikzset{xyp/.style={canvas is xy plane at z=#1}}
\begin{document}
\begin{tikzpicture}
[ x={(20:1cm)},
y={(90:1cm)},
z={(160:0.5cm)},
line join=round,
]
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0,0) -- (3,0.3,0) -- cycle;
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0.3,0) -- (3,0.3,3) -- (0,0,3) -- cycle;
\draw[blue!50!cyan!50!black,thick] (3,1,0) -- (3,1,3);
\foreach \z in {100,...,0}
{ \pgfmathsetmacro{\drawperc}{or(\z==0,\z==100) ? 1 : 0}
\ifthenelse{\z=0 \OR \z=100}
{ \gdef\myc{blue!50!cyan!50!black}}
{ \gdef\myc{blue!50!cyan!50!gray}}
\filldraw[blue!50!cyan!50!gray,xyp=\z/100*3,opacity=1,draw=\myc,draw opacity=1] (0,0) -- (3,0.3) -- (3,1) to[out=180,in=220,looseness=0.8] (2,2.5) to[out=180,in=0] (0,1.5) -- cycle;
}
\draw[blue!50!cyan!50!black] (2,2.5,0) -- (2,2.5,3);
\draw[blue!50!cyan!50!black] (0,1.5,0) -- (0,1.5,3);
\end{tikzpicture}
\begin{tikzpicture}
[ x={(20:1cm)},
y={(90:1cm)},
z={(160:0.5cm)},
line join=round,
]
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0,0) -- (3,0.3,0) -- cycle;
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0.3,0) -- (3,0.3,3) -- (0,0,3) -- cycle;
\draw[blue!50!cyan!50!black,thick] (3,0.7,0) -- (3,0.7,3);
\foreach \z in {100,...,0}
{ \pgfmathsetmacro{\drawperc}{or(\z==0,\z==100) ? 1 : 0}
\ifthenelse{\z=0 \OR \z=100}
{ \gdef\myc{blue!50!cyan!50!black}}
{ \gdef\myc{blue!50!cyan!50!gray}}
\filldraw[blue!50!cyan!50!gray,xyp=\z/100*3,opacity=1,draw=\myc,draw opacity=1] (0,0) -- (3,0.3) -- (3,0.7) to[out=170,in=315,looseness=1] (1.5,2) to[out=225,in=20] (0,1.5) -- cycle;
}
\draw[blue!50!cyan!50!black] (1.5,2,0) -- (1.5,2,3);
\draw[blue!50!cyan!50!black] (0,1.5,0) -- (0,1.5,3);
\end{tikzpicture}
\begin{tikzpicture}
[ x={(20:1cm)},
y={(90:1cm)},
z={(160:0.5cm)},
line join=round,
]
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0,0) -- (3,0.3,0) -- cycle;
\filldraw[brown!50,draw=black] (0,0,0) -- (3,0.3,0) -- (3,0.3,3) -- (0,0,3) -- cycle;
\draw[blue!50!cyan!50!black,thick] (3,1,0) -- (3,1,3);
\foreach \z in {100,...,0}
{ \pgfmathsetmacro{\drawperc}{or(\z==0,\z==100) ? 1 : 0}
\ifthenelse{\z=0 \OR \z=100}
{ \gdef\myc{blue!50!cyan!50!black}}
{ \gdef\myc{blue!50!cyan!50!gray}}
\filldraw[blue!50!cyan!50!gray,xyp=\z/100*3,opacity=1,draw=\myc,draw opacity=1] (0,0) -- (3,0.3) -- (3,1) to[out=170,in=0,looseness=1] (1.5,2) to[out=180,in=20] (0,1.5) -- cycle;
}
\draw[blue!50!cyan!50!black] (0,1.5,0) -- (0,1.5,3);
\end{tikzpicture}
\end{document}
Output
![enter image description here](https://i.stack.imgur.com/49GSM.png)
Best Answer
It seems that if there isn't room for a complete loop, the path will be finished with a straight line. By making a slight change in the endpoint for the first path, the result is better. Also, to make the loop continous, and not turn around at the midpoint, you can make the amplitude negative for the second and third path.