How can I draw the triangle tangent to sphere?
With some calculations, I have this code
\documentclass[border=2mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot-circleofsphere}
\usepackage{fouriernc}
\begin{document}
\tdplotsetmaincoords{60}{140}
\begin{tikzpicture}[tdplot_main_coords,scale=1/2,line join = round, line cap = round,declare function={R=6;r=4;h=2*sqrt(5); Angle=acos(r/R);}]
\path
(-3, -4,h) coordinate (A)
(12, -4,h) coordinate (B)
(-36/5, 52/5,h) coordinate (C)
(0,0,h) coordinate (I)
(0,0,0) coordinate (O)
(0,-4,h) coordinate (H)
(-96/25, -28/25, h) coordinate (K)
;
\begin{scope}
\fill[ball color=gray!10,tdplot_screen_coords] (O) circle (R);
\end{scope}
\begin{scope}[shift={(O)}]
\tdplotCsDrawLatCircle[blue, thick]{R}{{Angle}}
\end{scope}
\draw[thick] (A) -- (B) -- (C) -- cycle;
\draw[dashed] (O) -- (I) -- (H) -- cycle (I) -- (K) -- (O);
\foreach \p in {A,B,C,I,O,H,K}
\draw[fill=black] (\p) circle (2.5pt);
\foreach \p/\g in {A/90,B/-90,C/-90,I/90,O/-90,H/90,K/90}
\path (\p)+(\g:6mm) node{$\p$};
\end{tikzpicture}
\end{document}
This is a version that computes the points from the inputs with pgf methods. The output is much less spectacular than minthien_2016's nice answer, I do not (in this answer) distinguish between visible and hidden parts of the triangle and circle. The steps are:
- compute the radius
r
of the incircle; - compute the height
h
of the plane containing the triangle; - compute the distances of the points where the incircle touches the triangle to the corners of the triangle and the angles of the triangle;
- add the corners. One edge can be taken to be parallel to the x axis. So two corners are at
z=h
,y=-r
andx
at the respective touching distances. The third corner can then be reconstructed from the angles.
This is the result:
\documentclass[border=2mm,12pt,tikz]{standalone}
\usepackage{tikz-3dplot}
\usetikzlibrary{fpu}
\def\pgfmathsetmacroFPU#1#2{\begingroup%
\pgfkeys{/pgf/fpu,/pgf/fpu/output format=fixed}%
\pgfmathsetmacro{#1}{#2}%
\pgfmathsmuggle#1\endgroup}%
\begin{document}
\begin{tikzpicture}[scale=1/2,declare
function={a=15;b=15;c=24;R=6;}]
\path (0,0,0) coordinate (O);
% compute radius of incircle
\pgfmathsetmacroFPU{\saux}{(a+b+c)/2}
\pgfmathsetmacroFPU{\inradius}{sqrt(\saux*(\saux-a)*(\saux-b)*(\saux-c))/\saux}
% compute height of circle
\pgfmathsetmacro{\haux}{sqrt(R*R-\inradius*\inradius)}
% compute angles of triangle
\pgfmathsetmacro{\alphaaux}{acos((b*b+c*c-a*a)/(2*b*c))}
\pgfmathsetmacro{\betaaux}{acos((a*a+c*c-b*b)/(2*a*c))}
\pgfmathsetmacro{\gammaaux}{acos((a*a+b*b-c*c)/(2*a*b))}
% compute distances from the corners of the triangle to the points where
% the triangle touches the circle
\pgfmathsetmacro{\touchA}{(b+c-a)/2}
\pgfmathsetmacro{\touchB}{(a+c-b)/2}
\pgfmathsetmacro{\touchC}{(a+b-c)/2}
\tdplotsetmaincoords{60}{140}
\begin{scope}[tdplot_main_coords]
\fill[ball color=gray!10,tdplot_screen_coords] (O) circle[radius=6];
\path (-\touchA,-\inradius,\haux) coordinate[label=right:$A$](A)
(\touchB,-\inradius,\haux) coordinate[label=left:$B$](B)
({-\touchA+cos(\alphaaux)*b},{-\inradius+sin(\alphaaux)*b},\haux)
coordinate[label=right:$C$](C)
(0,-\inradius,\haux) coordinate (TAB)
({-\touchA+cos(\alphaaux)*\touchA},{-\inradius+sin(\alphaaux)*\touchA},\haux)
coordinate (TAC)
({\touchB+cos(180-\betaaux)*\touchB},{-\inradius+sin(180-\betaaux)*\touchB},\haux)
coordinate (TBC)
(0,0,\haux) coordinate (M);
\draw (A) -- (B) -- (C) -- cycle;
\begin{scope}[canvas is xy plane at z=\haux]
\draw[blue,thick] (M) circle[radius=\inradius];
\end{scope}
\foreach \X in {A,B,C,M,TAB,TAC,TBC}
{\fill (\X) circle[radius=3pt];}
\end{scope}
\end{tikzpicture}
\end{document}
Asymptote version with removed top of the sphere, suitable for general triangle:
//
// file tri-tan-sphere.asy
// run "asy -f png -render=4 tri-tan-sphere.asy"
// to get tri-tan-sphere.png
//
import graph3; size(200,0);
currentprojection=orthographic(camera=(-20,-25,27),up=(0.2,0.9,1));
triple f(pair t){return (cos(t.y)*cos(t.x),cos(t.y)*sin(t.x),sin(t.y));}
real R=6, a=15, b=20, c=24,
rho=(a+b+c)/2,
r=1/4*sqrt(4*a^2*b^2-(a^2+b^2-c^2)^2)/rho,
alpha=2*aTan(r/(rho-a)),
h=sqrt(R^2-r^2);
triple O,A,B,C,I,At,Bt,Ct;
A=O; B=(c,0,0); C=(b*Cos(alpha),b*Sin(alpha),0);
I=(a*A+b*B+c*C)/2/rho;
transform3 t=shift(Z*h-I);
A=t*A; B=t*B; C=t*C; I=t*I;
guide3 gt=A--B--C--cycle;
At=B+(rho-b)/a*(C-B); Bt=C+(rho-c)/b*(A-C); Ct=A+(rho-a)/c*(B-A);
surface s=surface(gt);
draw(s,lightyellow+opacity(0.5));
draw(circle(I,r)^^gt,deepblue);
triple[] P={O,A,B,C,I,At,Bt,Ct,};
string[] L={"O","A","B","C","I","A_t","B_t","C_t",};
triple[] T={Z+Y,A-I,B-I,C-I,Z+Y,I-A,I-B,I-C,};
for(int i=0;i<P.length;++i){dot(P[i]); label("$"+L[i]+"$",P[i],2unit(T[i]));}
surface sc=scale3(R)*surface(f,(0,-pi/2),(2pi,acos(r/R)),Spline);
draw(sc,lightgray,meshpen=nullpen,render(merge=true));
Alternatively, command asy -f html tri-tan-sphere.asy
generates tri-tan-sphere.html
with interactive
3D vector WebGL graphics.