# Tikz: How can I use the power of LaTeX to find the rotation angle of the ellipse?

I need to rotate my second ellipse around some angle. I have made guesses and determined it is around 88.5 degrees. However, I want to identify the exact angle.

The code I have so far is:

  \documentclass{article}
\usepackage{tikz}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{tikzpicture}[scale = 1.5,
every label/.append style = {font = \small},
dot/.style = {outer sep = +0pt, inner sep = +0pt,
shape = circle, draw = black, label = {#1}},
dot/.default =,
small dot/.style = {minimum size = 2.5pt, dot = {#1}},
small dot/.default =,
big dot/.style = {minimum size = 5pt, dot = {#1}},
big dot/.default =
]
\pgfmathsetmacro{\e}{0.2768}
\pgfmathsetmacro{\etilde}{0.6789}
\pgfmathsetmacro{\rone}{1}
\pgfmathsetmacro{\rtwo}{1.524}
\pgfmathsetmacro{\deltanu}{107}
\pgfmathsetmacro{\a}{1.36}
\pgfmathsetmacro{\am}{1.1442}
\pgfmathsetmacro{\b}{\a * sqrt(1 - \e^2)}
\pgfmathsetmacro{\btilde}{\a * sqrt(1 - (\etilde)^2)}
\pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}
\pgfmathsetmacro{\ctilde}{sqrt(\a^2 - (\btilde)^2)}
\pgfmathsetmacro{\angle}{88.5}
\draw[dashed] (-2 * \c, 0) -- (0, 0);
\begin{scope}[rotate around = {\angle:(0, 0)}]
\draw[dashed] (2 * \ctilde, 0) -- (0, 0);
\end{scope}
\node[scale = .75, fill = orange, big dot = {below: $$F$$}] (F)
at (0, 0) {};
\node[scale = .75, fill = white, big dot = {below: $$F^*$$}] (FS)
at (-2 * \c cm, 0) {};
\draw[red, thick, name path = r2] (0, 0) circle (1.523679cm);
\draw[blue, thick, name path = r1] (0, 0) circle (1cm);
\draw[name path = ecc2768] (-\c, 0) ellipse (\a cm and \b cm);
\draw[name intersections = {of = ecc2768 and r1}] (F) -- (intersection-1)
coordinate (P1) node[fill, big dot = {right: $$P_1$$}, minimum size = 3pt]
{};
\draw[name intersections = {of = ecc2768 and r2}] (F) -- (intersection-1)
coordinate (P2) node[fill, big dot = {left: $$P_2$$}, minimum size = 3pt]
{};
\draw (P1) -- (P2) node[scale = .75, fill = white, shape = circle, pos = .5]
{$$c$$};
\draw let
\p0 = (F),
\p1 = (P1),
\p2 = (P2),
\n1 = {atan2(\x1 - \x0, \y1 - \y0)},
\n2 = {atan2(\x2 - \x0, \y2 - \y0)},
\n3 = {.35cm}
in (F) +(\n1:\n3) arc [radius = \n3, start angle = \n1, end angle = \n2]
node[scale = .45, pos = 0.5, above = 10pt] {\pgfmathparse{\n2 - \n1}%
$\pgfmathprintnumber{\pgfmathresult}^{\circ}$
};
\begin{scope}[rotate around = {\angle:(0, 0)}]
\draw (\ctilde, 0) ellipse (\a cm and \btilde cm);
\node[scale = .75, fill = white, big dot = {above: $$\tilde{F}^*$$}] (FST)
at (2 * \ctilde cm, 0) {};
\end{scope}
\end{tikzpicture}
\end{document}


From the picture, we can see that guess seems decent but it may or may not be correct.

Is there a some built in function that will let us rotate the near side of the ellipse to the the intersection point P2 and the far side to P1?

-

You can do this by finding the intersection P3 between the unrotated ellipse and the circle with radius r1, and then calculating the angle P1-F-P3: That's the angle you need to rotate the ellipse by:

  \documentclass[border=5mm]{standalone}
\usepackage{tikz}
\usetikzlibrary{intersections, calc}
\begin{document}
\begin{tikzpicture}[scale = 1.5,
every label/.append style = {font = \small},
dot/.style = {outer sep = +0pt, inner sep = +0pt,
shape = circle, draw = black, label = {#1}},
dot/.default =,
small dot/.style = {minimum size = 2.5pt, dot = {#1}},
small dot/.default =,
big dot/.style = {minimum size = 5pt, dot = {#1}},
big dot/.default =
]
\pgfmathsetmacro{\e}{0.2768}
\pgfmathsetmacro{\etilde}{0.6789}
\pgfmathsetmacro{\rone}{1}
\pgfmathsetmacro{\rtwo}{1.524}
\pgfmathsetmacro{\deltanu}{107}
\pgfmathsetmacro{\a}{1.36}
\pgfmathsetmacro{\am}{1.1442}
\pgfmathsetmacro{\b}{\a * sqrt(1 - \e^2)}
\pgfmathsetmacro{\btilde}{\a * sqrt(1 - (\etilde)^2)}
\pgfmathsetmacro{\c}{sqrt(\a^2 - \b^2)}
\pgfmathsetmacro{\ctilde}{sqrt(\a^2 - (\btilde)^2)}
\pgfmathsetmacro{\angle}{88.5}
\node[scale = .75, fill = orange, big dot = {below: $$F$$}] (F)
at (0, 0) {};
\draw[draw=none, thick, name path = r2] (0, 0) circle (1.523679cm);
\draw[blue, thick, name path = r1] (0, 0) circle (1cm);
\draw[name path = ecc2768] (-\c, 0) ellipse (\a cm and \b cm);
\draw[name intersections = {of = ecc2768 and r1}] (F) -- (intersection-1)
coordinate (P1) node[fill, big dot = {right: $$P_1$$}, minimum size = 3pt]
{};
\draw [name path = ecc6789unrotated, gray!50, thick] (\ctilde, 0) ellipse (\a cm and \btilde cm);
\draw [name intersections={of=r1 and ecc6789unrotated}]
(intersection-2) circle [radius=1.5pt] node [above] {$P_3$}
let
\p0=(F),
\p1=(P1),
\p2=(intersection-2),
\n1={atan2(\x1-\x0,\y1-\y0)},
\n2={atan2(\x2-\x0,\y2-\y0)},
\n3={\n1-\n2}
in
\pgfextra{\xdef\myangle{\n3}}
[rotate=\n3] (\ctilde, 0) ellipse (\a cm and \btilde cm);

\node at (0,3) {The angle of rotation is: \pgfmathparse{\myangle} $\pgfmathprintnumber{\pgfmathresult}^\circ$};
\end{tikzpicture}
\end{document}

-
You are great at this. I wish I was able to do this on my own like you. How can I use \n3 out of the let statement? Would name global path work? – dustin Jun 18 '13 at 16:26
@dustin: Usually \n3 is only available in the path command with the let statement. However, you can store the result in a macro by putting something like \pgfextra{\xdef\myangle{\n3}} in the path (so \draw ... let ... \n3={\n1-\n2} in \pgfextra{\xdef\myangle{\n3}} [rotate=\n3] ...) – Jake Jun 18 '13 at 16:44
That didn't work. Can we print out \n3 some how so I can record it? – dustin Jun 18 '13 at 16:51
@dustin: I've edited my answer to show how to save the result. – Jake Jun 18 '13 at 17:00
Thanks. My angle of 88.5 was pretty close to the actual value of 88.23. – dustin Jun 18 '13 at 17:04