1

What is the right method to draw a small circle at a certain angle?

I can only do it improvisational for the right angle.

enter image description here

Hint: I want to draw such a picture:

enter image description here

\documentclass[margin=5mm, tikz]{standalone}
\usepackage{amsmath, amsfonts}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,calc,backgrounds}
\begin{document}

\pgfmathsetmacro{\r}{2.6} %  

\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[
tdplot_main_coords,
%tdplot_rotated_coords,
font=\footnotesize,
Helpcircle/.style={gray!70!black,
%densely dashed
},
]

\pgfmathsetmacro{\h}{0.9*\r} %  
\coordinate[label=$M$] (M) at (0,0,0); 
\coordinate[label=$S$] (S) at (0,0,\h); 

\draw[Helpcircle] (M) circle[radius=\r];

\draw[Helpcircle] ([shift={(0,0,\h)}]M) circle[radius=sqrt(\r^2-\h^2)];

\draw[Helpcircle, rotate=90, red] (0,0,-\h) coordinate[label=$A$] (A) circle[radius=sqrt(\r^2-\h^2)];
\draw[] (M) -- (A);

\pgfmathsetmacro{\teta}{30} %
\pgfmathsetmacro{\y}{-\h*cos(\teta)} %    
\draw[blue] (M) -- ([xshift=\r cm, yshift=\y cm]M);

% Sphere
\begin{scope}[tdplot_screen_coords, on background layer]
\fill[ball color= gray!20, opacity = 0.25] (M) circle (\r); 
\end{scope}

%% Points
\foreach \P in {M,S, A}{
\shade[ball color=white] (\P) circle (1.75pt);
}

\begin{scope}[-latex, shift={(M)}, xshift=1.5*\r cm, yshift=0.1*\r cm]
\foreach \P/\s/\Pos in {(1,0,0)/x/right, (0,1,0)/y/below, (0,0,1)/z/right} 
\draw[] (0,0,0) -- \P node[\Pos, pos=0.9,inner sep=2pt]{$\s$};
\end{scope}

\end{tikzpicture}
\end{document} 
2
  • The blue line was drawn using screen coordinates (xshift,yshift), as was coordinate (A) [rotate]. You can translate 3D coordinates into screen coordinate, but not the inverse. Jul 24, 2019 at 15:58
  • tikz-3dplot autoloads the 3d (and calc) libraries. You can switch to specific plane using e.g. canvas is xz plane at y=1.
    – user121799
    Jul 25, 2019 at 1:43

1 Answer 1

1

This shows how to draw the circle at (A) using 3D coordinates, assuming you intended (A) to be at (0,\h,0).

Using rotated coordinates can be tricky. The first angle rotates the XY plane, and has no effect on the Z axis. The second angle rotates in the (new) XZ plane, and has no effect on the (new) Y axis. Try to avoid using the third angle, which rotates in the new XY plane, although some transformations can only be done that way; e.g. \tdplotsetrotatedcoords{90}{90}{-90}.

Note that the transformations are NOT cumulative.

BTW, \r^2 is computed using exp(2*log(\r)) which is slow and only works for positive numbers.

\documentclass[margin=5mm, tikz]{standalone}
\usepackage{amsmath, amsfonts}
\usepackage{tikz}
\usepackage{tikz-3dplot}
\usetikzlibrary{arrows,calc,backgrounds}
\begin{document}

\pgfmathsetmacro{\r}{2.6} %  

\tdplotsetmaincoords{60}{110}
\begin{tikzpicture}[
tdplot_main_coords,
%tdplot_rotated_coords,
font=\footnotesize,
Helpcircle/.style={gray!70!black,
%densely dashed
},
]

\pgfmathsetmacro{\h}{0.9*\r} %  
\coordinate[label=$M$] (M) at (0,0,0); 
\coordinate[label=$S$] (S) at (0,0,\h); 
\coordinate[label=$A$] (A) at (0,\h,0); 

\draw[Helpcircle] (M) circle[radius=\r];

\draw[Helpcircle] (S) circle[radius=sqrt(\r*\r-\h*\h)];% much faster then ^2

\tdplotsetrotatedcoords{90}{90}{0}%
\draw[Helpcircle, red, tdplot_rotated_coords] (A) circle[radius=sqrt(\r*\r-\h*\h)];
\draw[] (M) -- (A);

% Sphere
\begin{scope}[tdplot_screen_coords, on background layer]
\fill[ball color= gray!20, opacity = 0.25] (M) circle (\r); 
\end{scope}

%% Points
\foreach \P in {M,S, A}{
\shade[ball color=white] (\P) circle (1.75pt);
}

\begin{scope}[-latex, shift={(M)}, xshift=1.5*\r cm, yshift=0.1*\r cm]
\foreach \P/\s/\Pos in {(1,0,0)/x/right, (0,1,0)/y/below, (0,0,1)/z/right} 
\draw[] (0,0,0) -- \P node[\Pos, pos=0.9,inner sep=2pt]{$\s$};
\end{scope}

\end{tikzpicture}
\end{document} 

demo

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .