LaTeX forum ⇒ GeneralHow can I draw this cylinder Topic is solved

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

How can I draw this cylinder

Postby Tran Van Toan » Fri Nov 03, 2017 5:32 pm

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 461 times

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Fri Nov 03, 2017 6:21 pm

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
Site admin

Tran Van Toan
Posts: 17
Joined: Sat Oct 28, 2017 1:18 am

Postby Tran Van Toan » Sat Nov 04, 2017 9:24 am

My cylinder.
  1. \documentclass[border=5]{standalone}
  2. \usepackage{tikz}
  3. \usepackage{tkz-euclide}
  4. \usetkzobj{all}
  5. \usetikzlibrary{shadings}
  6. \begin{document}
  7. \begin{tikzpicture}
  8. \def\R{2}
  9. \fill[top color = gray!50!black,
  10. bottom color = gray!10,
  11. middle color = gray,
  12. shading = axis,
  13. opacity = 0.25]
  14. (0,0) circle (\R cm and 0.5cm);
  15. \fill[left color = gray!50!black,
  16. right color = gray!50!black,
  17. middle color = gray!50,
  18. shading = axis,
  19. opacity = 0.25]
  20. (\R,0) -- (\R,2*\R) arc (360:180:\R cm and 0.5cm)
  21. -- (-\R,0) arc (180:360:\R cm and 0.5cm);
  22. \fill[top color = gray!90!,
  23. bottom color = gray!2,
  24. middle color = gray!30,
  25. shading = axis,
  26. opacity = 0.25]
  27. (0,2*\R) circle (\R cm and 0.5cm);
  28. \draw (-\R,2*\R) -- (-\R,0) arc (180:360:\R cm and 0.5cm)
  29. -- (\R,2*\R) ++ (-\R,0) circle (\R cm and 0.5cm);
  30. \draw[densely dashed] (-\R,0) arc (180:0:\R cm and 0.5cm);
  31.  
  32. \end{tikzpicture}
  33. \end{document}

Tran Van Toan
Posts: 17
Joined: Sat Oct 28, 2017 1:18 am

Postby Tran Van Toan » Sat Nov 04, 2017 2:08 pm

I tried
  1. \documentclass[border=5]{standalone}
  2. \usepackage{tikz}
  3. \usepackage{tkz-euclide}
  4. \usetkzobj{all}
  5. \usetikzlibrary{shadings}
  6. \begin{document}
  7. \begin{tikzpicture}
  8. \def\R{2}
  9. \def\a{1}
  10. \def\z{1}
  11. \def\h{2*\R}
  12. \fill[top color = gray!50!black,
  13. bottom color = gray!10,
  14. middle color = gray,
  15. shading = axis,
  16. opacity = 0.25]
  17. (0,0) circle (\R cm and \a cm);
  18. \fill[left color = gray!50!black,
  19. right color = gray!50!black,
  20. middle color = gray!50,
  21. shading = axis,
  22. opacity = 0.25]
  23. (\R,0) -- (\R,\h) arc (360:180:\R cm and \a cm)
  24. -- (-\R,0) arc (180:360:\R cm and \a cm);
  25. \fill[top color = gray!90!,
  26. bottom color = gray!2,
  27. middle color = gray!30,
  28. shading = axis,
  29. opacity = 0.25]
  30. (0,\h) circle (\R cm and \a cm);
  31. \draw (-\R,\h) -- (-\R,0) arc (180:360:\R cm and \a cm)
  32. -- (\R,\h) ++ (-\R,0) circle (\R cm and \a cm);
  33. \draw[densely dashed] (-\R,0) arc (180:0:\R cm and \a cm);
  34. \coordinate (B) at (0,0);
  35. \coordinate (A) at ($(B)+(0,\h)$);
  36. \coordinate (E) at (-\R,\h);
  37. \coordinate (F) at (\R,\h);
  38. \coordinate (G) at (-\R,0);
  39. \coordinate (H) at (\R,0);
  40. \coordinate (C) at ($(B) + (225:{\R} and {\a})$);
  41. \coordinate (D) at ($(C)+(0,\h)$);
  42. \tkzFillPolygon[pattern=north west lines](A,B,C,D)
  43. \tkzDrawSegments[](A,D D,C E,G F,H)
  44. \tkzDrawSegments[dashed](A,B B,C)
  45. \tkzDrawPoints[fill = black,size = 2 pt](A,B,C,D)
  46.  
  47. \tkzLabelPoints[right](A,B)
  48. \tkzLabelPoints[above](D)
  49. \tkzLabelPoints[below](C)
  50. \end{tikzpicture}
  51. \end{document}


And got
Attachments
ScreenHunter 37.png
ScreenHunter 37.png (87.69 KiB) Viewed 442 times

Tran Van Toan
Posts: 17
Joined: Sat Oct 28, 2017 1:18 am

Postby Tran Van Toan » Sat Nov 04, 2017 2:09 pm

But not good at here. How can I repair?
Attachments
ScreenHunter 36.png
ScreenHunter 36.png (3.03 KiB) Viewed 442 times

User avatar
Stefan Kottwitz
Site Admin
Posts: 8522
Joined: Mon Mar 10, 2008 9:44 pm
Location: Hamburg, Germany
Contact:

Postby Stefan Kottwitz » Sat Nov 04, 2017 7:08 pm

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
Site admin

Tran Van Toan
Posts: 17
Joined: Sat Oct 28, 2017 1:18 am

Postby Tran Van Toan » Sun Nov 05, 2017 1:11 am

Thank you very much.


Return to “General”

Who is online

Users browsing this forum: No registered users and 3 guests