How can I draw a cylinder inside a sphere?

Post a reply


This question is a means of preventing automated form submissions by spambots.
Smilies
:D :) ;) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :!: :?: :idea: :arrow: :| :mrgreen: :geek: :ugeek:

BBCode is ON
[img] is ON
[flash] is ON
[url] is ON
Smilies are ON

Topic review
   

Expand view Topic review: How can I draw a cylinder inside a sphere?

How can I draw a cylinder inside a sphere?

by Kaw Sar » Fri Dec 23, 2022 2:43 pm

Hi every body. I want sketch a cylinder inside a sphere, I use the following command from https://tex.stackexchange.com/questions ... -with-tikz.

Code: Select all

\documentclass[12pt,border=3mm]{standalone}
\usepackage{fouriernc}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usepackage{tikz-3dplot}
\usetikzlibrary{calc,backgrounds}
\begin{document}
\tdplotsetmaincoords{70}{110}
\def\r{{2*sqrt(3)}}
\def\d{-60}
\begin{tikzpicture}
[scale=1,tdplot_main_coords]
\path
coordinate (O) at (0,0,0)
coordinate (I) at  (0,0,2)
coordinate (A') at  (0,\r,4)
coordinate (A) at  (0,\r,0);
\coordinate (B) at ($(O) + (\d:{2*sqrt(3)} and \r)$);
\coordinate (B') at ($(B)+(0,0,4)$);
\coordinate (O') at ($(O)+(0,0,4)$);
\draw[dashed] (A)--(A') (B) --(B') (O)--(O') (O)--(A) (I) --(A);
\foreach \v/\position in {I/left,O/below,O'/above,A/below,B/below,A'/left,B'/left} {
    \draw[draw =black, fill=black] (\v) circle (1.2pt) node [\position=0.2mm] {$\v$};
}
\begin{scope}[tdplot_screen_coords, on background layer]
\pgfmathsetmacro{\R}{4}%
%\pgfmathsetmacro{\r}{{2*sqrt(3)}}%
\fill[ball color=orange!70, opacity=1.0] (I) circle (\R);
\end{scope}
\tkzMarkRightAngle[size = 0.3](I,O,A);
\draw [thick] (B) arc (\d:90:\r);
\draw [thick, dashed] (A) arc (90:310:\r);
\draw [thick] (B') arc (\d:90:\r);
\draw [thick, dashed] (A') arc (90:310:\r);
\end{tikzpicture}
\end{document}

I don't want A, B, A',B', ..., appear in it.
I want the shape to be like this picture.
with respect
cylinder inside  sphere.jpg
cylinder inside sphere.jpg (41.82 KiB) Viewed 19838 times

Top