GeneralHow can I draw this cylinder

General information and discussion about TeXnicCenter
Post Reply
Tran Van Toan
Posts: 23
Joined: Sat Oct 28, 2017 1:18 am

How can I draw this cylinder

Post by Tran Van Toan »

I want to draw this picture, but I can't. My difficult is how can I make points on two circles of cylinder.
Attachments
ScreenHunter 33.png
ScreenHunter 33.png (25.48 KiB) Viewed 89437 times

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

How can I draw this cylinder

Post by Stefan Kottwitz »

Hi,

can you post the code here, that you already have?
Tran Van Toan wrote:how can I make points on two circles of cylinder
If it's just the points, we don't have to work on drawing a cylinder etc. if you might have that already, that's why I ask for the code.

Stefan
LaTeX.org admin
Tran Van Toan
Posts: 23
Joined: Sat Oct 28, 2017 1:18 am

How can I draw this cylinder

Post by Tran Van Toan »

My cylinder.

Code: Select all

Code, edit and compile here:
\documentclass[border=5]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\def\R{2}
\fill[top color = gray!50!black,
bottom color = gray!10,
middle color = gray,
shading = axis,
opacity = 0.25]
(0,0) circle (\R cm and 0.5cm);
\fill[left color = gray!50!black,
right color = gray!50!black,
middle color = gray!50,
shading = axis,
opacity = 0.25]
(\R,0) -- (\R,2*\R) arc (360:180:\R cm and 0.5cm)
-- (-\R,0) arc (180:360:\R cm and 0.5cm);
\fill[top color = gray!90!,
bottom color = gray!2,
middle color = gray!30,
shading = axis,
opacity = 0.25]
(0,2*\R) circle (\R cm and 0.5cm);
\draw (-\R,2*\R) -- (-\R,0) arc (180:360:\R cm and 0.5cm)
-- (\R,2*\R) ++ (-\R,0) circle (\R cm and 0.5cm);
\draw[densely dashed] (-\R,0) arc (180:0:\R cm and 0.5cm);
\end{tikzpicture}
\end{document}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Tran Van Toan
Posts: 23
Joined: Sat Oct 28, 2017 1:18 am

How can I draw this cylinder

Post by Tran Van Toan »

I tried

Code: Select all

Code, edit and compile here:
\documentclass[border=5]{standalone}
\usepackage{tikz}
\usepackage{tkz-euclide}
\usetkzobj{all}
\usetikzlibrary{shadings}
\begin{document}
\begin{tikzpicture}
\def\R{2}
\def\a{1}
\def\z{1}
\def\h{2*\R}
\fill[top color = gray!50!black,
bottom color = gray!10,
middle color = gray,
shading = axis,
opacity = 0.25]
(0,0) circle (\R cm and \a cm);
\fill[left color = gray!50!black,
right color = gray!50!black,
middle color = gray!50,
shading = axis,
opacity = 0.25]
(\R,0) -- (\R,\h) arc (360:180:\R cm and \a cm)
-- (-\R,0) arc (180:360:\R cm and \a cm);
\fill[top color = gray!90!,
bottom color = gray!2,
middle color = gray!30,
shading = axis,
opacity = 0.25]
(0,\h) circle (\R cm and \a cm);
\draw (-\R,\h) -- (-\R,0) arc (180:360:\R cm and \a cm)
-- (\R,\h) ++ (-\R,0) circle (\R cm and \a cm);
\draw[densely dashed] (-\R,0) arc (180:0:\R cm and \a cm);
\coordinate (B) at (0,0);
\coordinate (A) at ($(B)+(0,\h)$);
\coordinate (E) at (-\R,\h);
\coordinate (F) at (\R,\h);
\coordinate (G) at (-\R,0);
\coordinate (H) at (\R,0);
\coordinate (C) at ($(B) + (225:{\R} and {\a})$);
\coordinate (D) at ($(C)+(0,\h)$);
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
And got
Attachments
ScreenHunter 37.png
ScreenHunter 37.png (87.69 KiB) Viewed 89418 times
Tran Van Toan
Posts: 23
Joined: Sat Oct 28, 2017 1:18 am

How can I draw this cylinder

Post by Tran Van Toan »

But not good at here. How can I repair?
Attachments
ScreenHunter 36.png
ScreenHunter 36.png (3.03 KiB) Viewed 89418 times
User avatar
Stefan Kottwitz
Site Admin
Posts: 10324
Joined: Mon Mar 10, 2008 9:44 pm

How can I draw this cylinder

Post by Stefan Kottwitz »

Looks already good! Change this line

\tkzDrawSegments[](A,D D,C E,G F,H)

to that one, removing the unnecessary two last segments:

\tkzDrawSegments[](A,D D,C)

Stefan
LaTeX.org admin
Tran Van Toan
Posts: 23
Joined: Sat Oct 28, 2017 1:18 am

How can I draw this cylinder

Post by Tran Van Toan »

Thank you very much.
Post Reply