Draw the three cylindrical sections

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
2
down vote

favorite
1












I want to draw the three conic sections (circle, ellipse and rectangle) where the cylinder and cross sections are colored:



documentclassstandalone
usepackagetikz
usepackageanimate
usepackagefilecontents

begindocument

beginfilecontentstime2.txt
::0x0
::1
::2
::3
endfilecontents

beginanimateinline[
begin=
begintikzpicture[line cap=round,line join=round,x=1.0cm,y=1.0cm,scale=0.6]
clip(-3,0) rectangle (6,6);
,
end=endtikzpicture,
controls,timeline=time2.txt]1


draw [rotate around=0.:(1.5,1.),line width=1.pt] (1.5,1.) ellipse (1.5897934007793624cm and 0.5267286371193529cm);
draw [rotate around=0.:(1.5,5.),line width=1.pt] (1.5,5.) ellipse (1.5897934007793588cm and 0.5267286371193518cm);
draw [line width=1.pt] (-0.089793400779358,5.)-- (-0.089793400779362,1.);
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);

newframe %elipse
draw [rotate around=-22.21759426951831:(1.5,3.14),line width=1.pt,color=blue,fill=blue,fill opacity=0.2] (1.5,3.14) ellipse (1.6601578476760366cm and 0.6350780103265238cm);

newframe %circunferencia
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=green,fill=green,fill opacity=0.2] (1.5,3) ellipse (1.57 and 0.6);

newframe %rectangulo
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=orange,fill=orange,fill opacity=0.2](0.4,5.38) -- (0.39,1.38) -- (2.63,0.63) -- (2.62,4.63) -- cycle;

endanimateinline


enddocument









share|improve this question





















  • I guess you might be better off if you use tikz-3dplot instead of these rotate around commands.
    – marmot
    3 hours ago










  • Do not use the command, the manuals that I have seen are not good, I'm trying to understand the construction that you helped me with the "Draw the four conic sections"
    – Samuel Diaz
    3 hours ago














up vote
2
down vote

favorite
1












I want to draw the three conic sections (circle, ellipse and rectangle) where the cylinder and cross sections are colored:



documentclassstandalone
usepackagetikz
usepackageanimate
usepackagefilecontents

begindocument

beginfilecontentstime2.txt
::0x0
::1
::2
::3
endfilecontents

beginanimateinline[
begin=
begintikzpicture[line cap=round,line join=round,x=1.0cm,y=1.0cm,scale=0.6]
clip(-3,0) rectangle (6,6);
,
end=endtikzpicture,
controls,timeline=time2.txt]1


draw [rotate around=0.:(1.5,1.),line width=1.pt] (1.5,1.) ellipse (1.5897934007793624cm and 0.5267286371193529cm);
draw [rotate around=0.:(1.5,5.),line width=1.pt] (1.5,5.) ellipse (1.5897934007793588cm and 0.5267286371193518cm);
draw [line width=1.pt] (-0.089793400779358,5.)-- (-0.089793400779362,1.);
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);

newframe %elipse
draw [rotate around=-22.21759426951831:(1.5,3.14),line width=1.pt,color=blue,fill=blue,fill opacity=0.2] (1.5,3.14) ellipse (1.6601578476760366cm and 0.6350780103265238cm);

newframe %circunferencia
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=green,fill=green,fill opacity=0.2] (1.5,3) ellipse (1.57 and 0.6);

newframe %rectangulo
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=orange,fill=orange,fill opacity=0.2](0.4,5.38) -- (0.39,1.38) -- (2.63,0.63) -- (2.62,4.63) -- cycle;

endanimateinline


enddocument









share|improve this question





















  • I guess you might be better off if you use tikz-3dplot instead of these rotate around commands.
    – marmot
    3 hours ago










  • Do not use the command, the manuals that I have seen are not good, I'm trying to understand the construction that you helped me with the "Draw the four conic sections"
    – Samuel Diaz
    3 hours ago












up vote
2
down vote

favorite
1









up vote
2
down vote

favorite
1






1





I want to draw the three conic sections (circle, ellipse and rectangle) where the cylinder and cross sections are colored:



documentclassstandalone
usepackagetikz
usepackageanimate
usepackagefilecontents

begindocument

beginfilecontentstime2.txt
::0x0
::1
::2
::3
endfilecontents

beginanimateinline[
begin=
begintikzpicture[line cap=round,line join=round,x=1.0cm,y=1.0cm,scale=0.6]
clip(-3,0) rectangle (6,6);
,
end=endtikzpicture,
controls,timeline=time2.txt]1


draw [rotate around=0.:(1.5,1.),line width=1.pt] (1.5,1.) ellipse (1.5897934007793624cm and 0.5267286371193529cm);
draw [rotate around=0.:(1.5,5.),line width=1.pt] (1.5,5.) ellipse (1.5897934007793588cm and 0.5267286371193518cm);
draw [line width=1.pt] (-0.089793400779358,5.)-- (-0.089793400779362,1.);
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);

newframe %elipse
draw [rotate around=-22.21759426951831:(1.5,3.14),line width=1.pt,color=blue,fill=blue,fill opacity=0.2] (1.5,3.14) ellipse (1.6601578476760366cm and 0.6350780103265238cm);

newframe %circunferencia
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=green,fill=green,fill opacity=0.2] (1.5,3) ellipse (1.57 and 0.6);

newframe %rectangulo
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=orange,fill=orange,fill opacity=0.2](0.4,5.38) -- (0.39,1.38) -- (2.63,0.63) -- (2.62,4.63) -- cycle;

endanimateinline


enddocument









share|improve this question













I want to draw the three conic sections (circle, ellipse and rectangle) where the cylinder and cross sections are colored:



documentclassstandalone
usepackagetikz
usepackageanimate
usepackagefilecontents

begindocument

beginfilecontentstime2.txt
::0x0
::1
::2
::3
endfilecontents

beginanimateinline[
begin=
begintikzpicture[line cap=round,line join=round,x=1.0cm,y=1.0cm,scale=0.6]
clip(-3,0) rectangle (6,6);
,
end=endtikzpicture,
controls,timeline=time2.txt]1


draw [rotate around=0.:(1.5,1.),line width=1.pt] (1.5,1.) ellipse (1.5897934007793624cm and 0.5267286371193529cm);
draw [rotate around=0.:(1.5,5.),line width=1.pt] (1.5,5.) ellipse (1.5897934007793588cm and 0.5267286371193518cm);
draw [line width=1.pt] (-0.089793400779358,5.)-- (-0.089793400779362,1.);
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);

newframe %elipse
draw [rotate around=-22.21759426951831:(1.5,3.14),line width=1.pt,color=blue,fill=blue,fill opacity=0.2] (1.5,3.14) ellipse (1.6601578476760366cm and 0.6350780103265238cm);

newframe %circunferencia
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=green,fill=green,fill opacity=0.2] (1.5,3) ellipse (1.57 and 0.6);

newframe %rectangulo
draw [line width=1.pt] (3.089793400779359,5.)-- (3.0897934007793624,1.);
draw [line width=1.pt,color=orange,fill=orange,fill opacity=0.2](0.4,5.38) -- (0.39,1.38) -- (2.63,0.63) -- (2.62,4.63) -- cycle;

endanimateinline


enddocument






tikz-pgf draw






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked 3 hours ago









Samuel Diaz

424




424











  • I guess you might be better off if you use tikz-3dplot instead of these rotate around commands.
    – marmot
    3 hours ago










  • Do not use the command, the manuals that I have seen are not good, I'm trying to understand the construction that you helped me with the "Draw the four conic sections"
    – Samuel Diaz
    3 hours ago
















  • I guess you might be better off if you use tikz-3dplot instead of these rotate around commands.
    – marmot
    3 hours ago










  • Do not use the command, the manuals that I have seen are not good, I'm trying to understand the construction that you helped me with the "Draw the four conic sections"
    – Samuel Diaz
    3 hours ago















I guess you might be better off if you use tikz-3dplot instead of these rotate around commands.
– marmot
3 hours ago




I guess you might be better off if you use tikz-3dplot instead of these rotate around commands.
– marmot
3 hours ago












Do not use the command, the manuals that I have seen are not good, I'm trying to understand the construction that you helped me with the "Draw the four conic sections"
– Samuel Diaz
3 hours ago




Do not use the command, the manuals that I have seen are not good, I'm trying to understand the construction that you helped me with the "Draw the four conic sections"
– Samuel Diaz
3 hours ago










1 Answer
1






active

oldest

votes

















up vote
5
down vote



accepted










Here is some code based on tikz-3dplot, which is used to fix the view. This is done by the command tdplotsetmaincoords70X, and then beginscope[tdplot_main_coords]. In addition, the 3d library is used to switch in xy planes at various z values.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrary3d,backgrounds
% small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
makeatletter
tikzoptioncanvas is xy plane at z%
deftikz@plane@originpgfpointxyz00#1%
deftikz@plane@xpgfpointxyz10#1%
deftikz@plane@ypgfpointxyz01#1%
tikz@canvas@is@plane
makeatother
begindocument
foreach X in 5,15,...,355
tdplotsetmaincoords70X
begintikzpicture[declare function=h(x,y)=2+0.5*(y+y*cos(x));]
path[use as bounding box] (-4,-2) rectangle (18,10);
beginscope
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
beginscope[canvas is xy plane at z=4]
path[fill=blue,opacity=0.3] (0,0) circle (3);
endscope
endscope
endscope
beginscope[xshift=7cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[green!60!black,opacity=0.3] plot[variable=x,domain=-180:180,samples=90] (3*cos(x),3*sin(x),h(x,3));
endscope
endscope
beginscope[xshift=14cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[red,opacity=0.3] (rtl) -- (rtr) -- (rbr) -- (rbl);
endscope
endscope
endtikzpicture

enddocument


enter image description here






share|improve this answer






















  • Thank you, very useful construction, which documentation recommends me to learn how to use tikz-3dplot.
    – Samuel Diaz
    3 hours ago






  • 2




    @SamuelDiaz There is a manual. And you can learn from the examples on this site. The only feature of tikz-3dplot I am using here is to set the view with tdplotsetmaincoords70X, where 70 is the theta and X the phi angle. And then I use the 3d library to switch to the xy planes at different z values.
    – marmot
    3 hours ago










Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457571%2fdraw-the-three-cylindrical-sections%23new-answer', 'question_page');

);

Post as a guest






























1 Answer
1






active

oldest

votes








1 Answer
1






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
5
down vote



accepted










Here is some code based on tikz-3dplot, which is used to fix the view. This is done by the command tdplotsetmaincoords70X, and then beginscope[tdplot_main_coords]. In addition, the 3d library is used to switch in xy planes at various z values.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrary3d,backgrounds
% small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
makeatletter
tikzoptioncanvas is xy plane at z%
deftikz@plane@originpgfpointxyz00#1%
deftikz@plane@xpgfpointxyz10#1%
deftikz@plane@ypgfpointxyz01#1%
tikz@canvas@is@plane
makeatother
begindocument
foreach X in 5,15,...,355
tdplotsetmaincoords70X
begintikzpicture[declare function=h(x,y)=2+0.5*(y+y*cos(x));]
path[use as bounding box] (-4,-2) rectangle (18,10);
beginscope
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
beginscope[canvas is xy plane at z=4]
path[fill=blue,opacity=0.3] (0,0) circle (3);
endscope
endscope
endscope
beginscope[xshift=7cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[green!60!black,opacity=0.3] plot[variable=x,domain=-180:180,samples=90] (3*cos(x),3*sin(x),h(x,3));
endscope
endscope
beginscope[xshift=14cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[red,opacity=0.3] (rtl) -- (rtr) -- (rbr) -- (rbl);
endscope
endscope
endtikzpicture

enddocument


enter image description here






share|improve this answer






















  • Thank you, very useful construction, which documentation recommends me to learn how to use tikz-3dplot.
    – Samuel Diaz
    3 hours ago






  • 2




    @SamuelDiaz There is a manual. And you can learn from the examples on this site. The only feature of tikz-3dplot I am using here is to set the view with tdplotsetmaincoords70X, where 70 is the theta and X the phi angle. And then I use the 3d library to switch to the xy planes at different z values.
    – marmot
    3 hours ago














up vote
5
down vote



accepted










Here is some code based on tikz-3dplot, which is used to fix the view. This is done by the command tdplotsetmaincoords70X, and then beginscope[tdplot_main_coords]. In addition, the 3d library is used to switch in xy planes at various z values.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrary3d,backgrounds
% small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
makeatletter
tikzoptioncanvas is xy plane at z%
deftikz@plane@originpgfpointxyz00#1%
deftikz@plane@xpgfpointxyz10#1%
deftikz@plane@ypgfpointxyz01#1%
tikz@canvas@is@plane
makeatother
begindocument
foreach X in 5,15,...,355
tdplotsetmaincoords70X
begintikzpicture[declare function=h(x,y)=2+0.5*(y+y*cos(x));]
path[use as bounding box] (-4,-2) rectangle (18,10);
beginscope
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
beginscope[canvas is xy plane at z=4]
path[fill=blue,opacity=0.3] (0,0) circle (3);
endscope
endscope
endscope
beginscope[xshift=7cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[green!60!black,opacity=0.3] plot[variable=x,domain=-180:180,samples=90] (3*cos(x),3*sin(x),h(x,3));
endscope
endscope
beginscope[xshift=14cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[red,opacity=0.3] (rtl) -- (rtr) -- (rbr) -- (rbl);
endscope
endscope
endtikzpicture

enddocument


enter image description here






share|improve this answer






















  • Thank you, very useful construction, which documentation recommends me to learn how to use tikz-3dplot.
    – Samuel Diaz
    3 hours ago






  • 2




    @SamuelDiaz There is a manual. And you can learn from the examples on this site. The only feature of tikz-3dplot I am using here is to set the view with tdplotsetmaincoords70X, where 70 is the theta and X the phi angle. And then I use the 3d library to switch to the xy planes at different z values.
    – marmot
    3 hours ago












up vote
5
down vote



accepted







up vote
5
down vote



accepted






Here is some code based on tikz-3dplot, which is used to fix the view. This is done by the command tdplotsetmaincoords70X, and then beginscope[tdplot_main_coords]. In addition, the 3d library is used to switch in xy planes at various z values.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrary3d,backgrounds
% small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
makeatletter
tikzoptioncanvas is xy plane at z%
deftikz@plane@originpgfpointxyz00#1%
deftikz@plane@xpgfpointxyz10#1%
deftikz@plane@ypgfpointxyz01#1%
tikz@canvas@is@plane
makeatother
begindocument
foreach X in 5,15,...,355
tdplotsetmaincoords70X
begintikzpicture[declare function=h(x,y)=2+0.5*(y+y*cos(x));]
path[use as bounding box] (-4,-2) rectangle (18,10);
beginscope
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
beginscope[canvas is xy plane at z=4]
path[fill=blue,opacity=0.3] (0,0) circle (3);
endscope
endscope
endscope
beginscope[xshift=7cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[green!60!black,opacity=0.3] plot[variable=x,domain=-180:180,samples=90] (3*cos(x),3*sin(x),h(x,3));
endscope
endscope
beginscope[xshift=14cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[red,opacity=0.3] (rtl) -- (rtr) -- (rbr) -- (rbl);
endscope
endscope
endtikzpicture

enddocument


enter image description here






share|improve this answer














Here is some code based on tikz-3dplot, which is used to fix the view. This is done by the command tdplotsetmaincoords70X, and then beginscope[tdplot_main_coords]. In addition, the 3d library is used to switch in xy planes at various z values.



documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
usetikzlibrary3d,backgrounds
% small fix for canvas is xy plane at z % https://tex.stackexchange.com/a/48776/121799
makeatletter
tikzoptioncanvas is xy plane at z%
deftikz@plane@originpgfpointxyz00#1%
deftikz@plane@xpgfpointxyz10#1%
deftikz@plane@ypgfpointxyz01#1%
tikz@canvas@is@plane
makeatother
begindocument
foreach X in 5,15,...,355
tdplotsetmaincoords70X
begintikzpicture[declare function=h(x,y)=2+0.5*(y+y*cos(x));]
path[use as bounding box] (-4,-2) rectangle (18,10);
beginscope
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
beginscope[canvas is xy plane at z=4]
path[fill=blue,opacity=0.3] (0,0) circle (3);
endscope
endscope
endscope
beginscope[xshift=7cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[green!60!black,opacity=0.3] plot[variable=x,domain=-180:180,samples=90] (3*cos(x),3*sin(x),h(x,3));
endscope
endscope
beginscope[xshift=14cm]
beginscope[tdplot_main_coords]
beginscope[canvas is xy plane at z=0]
path[fill=orange!50] (0,0) circle (3);
coordinate (bl) at (0+tdplotmainphi:3);
coordinate (br) at (180+tdplotmainphi:3);
draw[dashed] (bl) arc(0+tdplotmainphi:180+tdplotmainphi:3);
draw[thick] (br) arc(180+tdplotmainphi:360+tdplotmainphi:3);
coordinate (rbl) at (0:3);
coordinate (rbr) at (180:3);
endscope
beginscope[canvas is xy plane at z=8]
draw[thick,fill=orange!30] (0,0) circle (3);
coordinate (tl) at (0+tdplotmainphi:3);
coordinate (tr) at (180+tdplotmainphi:3);
coordinate (rtl) at (0:3);
coordinate (rtr) at (180:3);
endscope
beginscope[on background layer]
fill[orange!20] (bl) rectangle (tr);
endscope
fill[red,opacity=0.3] (rtl) -- (rtr) -- (rbr) -- (rbl);
endscope
endscope
endtikzpicture

enddocument


enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 26 mins ago

























answered 3 hours ago









marmot

70k476149




70k476149











  • Thank you, very useful construction, which documentation recommends me to learn how to use tikz-3dplot.
    – Samuel Diaz
    3 hours ago






  • 2




    @SamuelDiaz There is a manual. And you can learn from the examples on this site. The only feature of tikz-3dplot I am using here is to set the view with tdplotsetmaincoords70X, where 70 is the theta and X the phi angle. And then I use the 3d library to switch to the xy planes at different z values.
    – marmot
    3 hours ago
















  • Thank you, very useful construction, which documentation recommends me to learn how to use tikz-3dplot.
    – Samuel Diaz
    3 hours ago






  • 2




    @SamuelDiaz There is a manual. And you can learn from the examples on this site. The only feature of tikz-3dplot I am using here is to set the view with tdplotsetmaincoords70X, where 70 is the theta and X the phi angle. And then I use the 3d library to switch to the xy planes at different z values.
    – marmot
    3 hours ago















Thank you, very useful construction, which documentation recommends me to learn how to use tikz-3dplot.
– Samuel Diaz
3 hours ago




Thank you, very useful construction, which documentation recommends me to learn how to use tikz-3dplot.
– Samuel Diaz
3 hours ago




2




2




@SamuelDiaz There is a manual. And you can learn from the examples on this site. The only feature of tikz-3dplot I am using here is to set the view with tdplotsetmaincoords70X, where 70 is the theta and X the phi angle. And then I use the 3d library to switch to the xy planes at different z values.
– marmot
3 hours ago




@SamuelDiaz There is a manual. And you can learn from the examples on this site. The only feature of tikz-3dplot I am using here is to set the view with tdplotsetmaincoords70X, where 70 is the theta and X the phi angle. And then I use the 3d library to switch to the xy planes at different z values.
– marmot
3 hours ago

















 

draft saved


draft discarded















































 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f457571%2fdraw-the-three-cylindrical-sections%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

How to check contact read email or not when send email to Individual?

Displaying single band from multi-band raster using QGIS

How many registers does an x86_64 CPU actually have?