LaTeX forum ⇒ GeneralHow can I draw a cylinder insribes a sphere?

LaTeX specific issues not fitting into one of the other forums of this category.
Tran Van Toan
Posts: 17
Joined: Sat Oct 28, 2017 1:18 am

How can I draw a cylinder insribes a sphere?

Postby Tran Van Toan » Fri Nov 10, 2017 5:05 am

I am trying to draw this picture in Tikz. I tried.
  1. \documentclass[12pt,border=3mm]{standalone}
  2. \usepackage{fouriernc}
  3. \usepackage{tikz}
  4. \usepackage{tkz-euclide}
  5. \usetkzobj{all}
  6. \usepackage{tikz-3dplot}
  7. \usetikzlibrary{calc,backgrounds}
  8. \begin{document}
  9. \tdplotsetmaincoords{60}{110}
  10. \def\r{{2*sqrt(3)}}
  11. \begin{tikzpicture}
  12. [scale=1,tdplot_main_coords]
  13. \path
  14. coordinate (O) at (0,0,0)
  15. coordinate (T) at (0,0,2)
  16. coordinate (A') at (0,\r,4)
  17. coordinate (A) at (0,\r,0);
  18. \coordinate (B) at ($(O) + (-50:{2*sqrt(3)} and \r)$);
  19. \coordinate (B') at ($(B)+(0,0,4)$);
  20. \coordinate (O') at ($(O)+(0,0,4)$);
  21. \draw[dashed] (A)--(A') (B) --(B') (O)--(O') (O)--(A) (T) --(A);
  22. \foreach \v/\position in {T/above,O/below,O'/above,A/below,B/below,A'/left,B'/left} {
  23. \draw[draw =black, fill=black] (\v) circle (1.2pt) node [\position=0.2mm] {$\v$};
  24. }
  25. \begin{scope}[tdplot_screen_coords, on background layer]
  26. \pgfmathsetmacro{\R}{4}%
  27. %\pgfmathsetmacro{\r}{{2*sqrt(3)}}%
  28. \fill[ball color=cyan!50, opacity=1.0] (T) circle (\R);
  29. \end{scope}
  30. \tkzMarkRightAngle[size = 0.3](T,O,A);
  31. \draw [thick] (B) arc (-50:90:\r);
  32. \draw [thick, dashed] (A) arc (90:310:\r);
  33. \draw [thick] (B') arc (-50:90:\r);
  34. \draw [thick, dashed] (A') arc (90:310:\r);
  35. \end{tikzpicture}
  36. \end{document}


The cylinder look very bad. How can I repair?
Attachments
ScreenHunter 52.png
ScreenHunter 52.png (117.68 KiB) Viewed 98 times
ScreenHunter 51.png
ScreenHunter 51.png (7.53 KiB) Viewed 98 times

Return to “General”

Who is online

Users browsing this forum: Bing [Bot] and 12 guests