Draw an ecuator circle given a unit 3D vector (the North pole)

I found the package tikz-3dplot extremely useful and really appreciate all the effort and good work Jeff Hein put on this.

After seen so many ways to describe the $\alpha-\beta-\gamma$ in terms of:

1. Euler Angles
2. Nautical Angles (pitch,yaw, roll)
3. Matrix Rotations, etc.

I have to confess that those confuse me a lot. It might be my skills at rotating three axes in my head (three times!) and know where I will land.

In particular the function tdplotsetrotatedcoords in the manual linked above, is of great importance.

I propose that given a unit vector we find the three rotation angles and from there the great circle corresponding to it. That is, for example, if my vector is $(1,0,0)$ the great circle is in the $y-z$, plane if my vector is $(0,0,1)$ my great circle is in the $x-y$ plane. In this way, I just need to know the direction of the new "north pole" (which is the $z$ axis after the three rotations) to find my tilted equator. The advantage of this parameterization is that a unit vector is easy to imagine, and there is one and only one equator for each unit vector (considered as the north pole).

The parametrization seems easy by using some basic trigonometry. I will start this task now, but if someone knows that this is job done already please let me know. I do not want to re-invent the wheel.

The final product should be a macro which is a wrapper of tdplotsetrotatedcoords where instead of $\alpha, \beta, \gamma$, we enter three coordinates corresponding to the new north pole. These three components cannot all be zero, of coruse since they lie in the surface of a unit sphere.

Thanks.

H.

We want to input a unit vector which is the north pole. Three coordinates $(x,y,z)$. The equation that evaluates the rotation for the tikz-3dplot coordinate system in the manual tikz-3dplot is the equation (2.3) which is a product of three rotation matrices. Since we are interested ONLY on known where the north pole (0,0,1) is moved after rotation we can multiply the matrix (2.3) by (0,0,1) and get that the new north pole N=(x_3, y_3, z_3). By matching the three equations we see that only the y_3 and z_3 are involved. It is easy to see that beta=arccos(z_3) , and if beta is no 0, then alpha=arcsin(y_3/beta). The algorithm is easy to implement and it is called here \getEquator. I wrote a little macro also to plot the vectors leaving the sphere at the north pole. The whole algorithm is next:

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{enumerate}
\usepackage{tikz}
\usepackage{xcolor}
\usepackage{tikz-3dplot}
\usepackage{hyperref}
\usepackage{ifthen}
\usepackage{pgfplots}
\usetikzlibrary{calc,3d,intersections, positioning,intersections,shapes}
\pgfplotsset{compat=1.11}

\newcommand\DrawVect[5]
{
\def\xt{#1}
\def\yt{#2}
\def\zt{#3}
\def\mycolor{#4}
\def\myR{#5}
% end of vector
\pgfmathsetmacro{\xte}{\myR*\xt}
\pgfmathsetmacro{\yte}{\myR*\yt}
\pgfmathsetmacro{\zte}{\myR*\zt}
\pgfmathsetmacro{\xtet}{\myR*\xt + \xt/\myR}
\pgfmathsetmacro{\ytet}{\myR*\yt + \yt/\myR}
\pgfmathsetmacro{\ztet}{\myR*\zt + \zt/\myR}

\draw[-latex, color=\mycolor, line width=1] (\xte,\yte,\zte) -- (\xtet , \ytet ,\ztet);
}

\newcommand\getEquator[2]
{
\def\yt{#1}
\def\zt{#2}

\pgfmathsetmacro{\betav}{acos(\zt)};

\def\gammav{0}
\ifthenelse{\equal{\betav}{0.0}}
{
\def\alphav{0}
}
{
\pgfmathsetmacro{\alphav}{asin(\yt/(sin(\betav))}
};
}

\begin{document}
\begin{center}
\begin{tikzpicture}[scale=1.0]
\tdplotsetmaincoords{80}{110}
\pgfmathsetmacro\R{sqrt(3)}
\coordinate (O) at (0,0,0);
\fill[ball color=white!10, opacity=0.2] (O) circle (\R); % 3D lighting effect
\begin{scope}[tdplot_main_coords, shift={(0,0)}]
\pgfmathsetmacro\R{sqrt(3)}
\pgfmathsetmacro{\thetavec}{0};
\pgfmathsetmacro{\phivec}{0};
\pgfmathsetmacro{\gammav}{0};
\tdplotsetrotatedcoords{\phivec}{\thetavec}{\gammav};

\def\x{1};
\def\y{0};
\def\z{0};

\DrawVect{\x}{\y}{\z}{blue}{\R};
\getEquator{\y}{\z};

\tdplotsetrotatedcoords{\alphav}{\betav}{\gammav};
\tdplotdrawarc[tdplot_rotated_coords,color=blue]{(O)}{\R}{0}{360}{}{};
\node[color=blue] at (-1,3.2,3.5) {\tiny
$N=$(\x,\y,\z)$\implies \alpha=$\alphav, $\beta=$\betav, $\gamma=$\gammav};

\def\x{0};
\def\y{0};
\def\z{1};
\def\colr{red}

\DrawVect{\x}{\y}{\z}{\colr}{\R};
\getEquator{\y}{\z};

\tdplotsetrotatedcoords{\alphav}{\betav}{\gammav};
\tdplotdrawarc[tdplot_rotated_coords,color=\colr]{(O)}{\R}{0}{360}{}{};
\node[color=\colr, yshift=-3mm] at (-1,3.2,3.5) {\tiny
$N=$(\x,\y,\z)$\implies \alpha=$\alphav, $\beta=$\betav, $\gamma=$\gammav};

\def\x{0};
\def\y{1};
\def\z{0};
\def\colr{black}

\DrawVect{\x}{\y}{\z}{\colr}{\R};
\getEquator{\y}{\z};

\tdplotsetrotatedcoords{\alphav}{\betav}{\gammav};
\tdplotdrawarc[tdplot_rotated_coords,color=\colr]{(O)}{\R}{0}{360}{}{};
\node[color=\colr, yshift=-6mm] at (-1,3.2,3.5) {\tiny
$N=$(\x,\y,\z)$\implies \alpha=$\alphav, $\beta=$\betav, $\gamma=$\gammav};

\def\x{-0.577};
\def\y{0.577};
\def\z{0.577};
\def\colr{brown}

\DrawVect{\x}{\y}{\z}{\colr}{\R};
\getEquator{\y}{\z};

\tdplotsetrotatedcoords{\alphav}{\betav}{\gammav};
\tdplotdrawarc[tdplot_rotated_coords,color=\colr]{(O)}{\R}{0}{360}{}{};
\node[color=\colr, yshift=-9mm] at (-1,3.5,3.5) {\tiny
$N=$(\x,\y,\z)$\implies \alpha=$\alphav, $\beta=$\betav, $\gamma=$\gammav};

%axis
\coordinate (X) at (5,0,0) ;
\coordinate (Y) at (0,3,0) ;
\coordinate (Z) at (0,0,3) ;

\draw[-latex] (O) -- (X) node[anchor=west] {$X$};
\draw[-latex] (O) -- (Y) node[anchor=north] {$Y$};
\draw[-latex] (O) -- (Z) node[anchor=south west] {$Z$};

% compute the equator in a different way.
\end{scope}
\end{tikzpicture}
\end{center}
\end{document}


The figure that it produces is next.