parallelepiped inscribed in cylinder
I 'm trying to draw a simple 3D shape (like parallelepiped or cylinder) with tikz, but I fund too complicated codes.
I want to draw something like this
Is it possible with a simple code?
Thank's in advanced!
Edit
What I mean by "simple code"? Something like this:
documentclass[tikz]{standalone}
usetikzlibrary{shapes}
begin{document}
begin{tikzpicture}[>=latex,shorten >=2pt,shorten <=2pt,shape aspect=1]
node (A) [cylinder, shape border rotate=90, draw,minimum height=3cm,minimum width=2cm]
{};
draw [<->] (A.before top) -- (A.after top) node [midway, above,fill=white] {$A_0$};
end{tikzpicture}
end{document}
Is it possible to inscribe a parallelepiped in the code's cylinder?
3d tikz-3d
add a comment |
I 'm trying to draw a simple 3D shape (like parallelepiped or cylinder) with tikz, but I fund too complicated codes.
I want to draw something like this
Is it possible with a simple code?
Thank's in advanced!
Edit
What I mean by "simple code"? Something like this:
documentclass[tikz]{standalone}
usetikzlibrary{shapes}
begin{document}
begin{tikzpicture}[>=latex,shorten >=2pt,shorten <=2pt,shape aspect=1]
node (A) [cylinder, shape border rotate=90, draw,minimum height=3cm,minimum width=2cm]
{};
draw [<->] (A.before top) -- (A.after top) node [midway, above,fill=white] {$A_0$};
end{tikzpicture}
end{document}
Is it possible to inscribe a parallelepiped in the code's cylinder?
3d tikz-3d
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Kurt
Jan 10 at 0:00
I 'm sorry, you are right. I found some solutions for my question by searching, but there was to many and complicated (for me of course) to post them. I thought that I will confuse the reader if I post them, so I decide to ask about a simple code (if there is one).
– Kώστας Κούδας
Jan 10 at 5:55
add a comment |
I 'm trying to draw a simple 3D shape (like parallelepiped or cylinder) with tikz, but I fund too complicated codes.
I want to draw something like this
Is it possible with a simple code?
Thank's in advanced!
Edit
What I mean by "simple code"? Something like this:
documentclass[tikz]{standalone}
usetikzlibrary{shapes}
begin{document}
begin{tikzpicture}[>=latex,shorten >=2pt,shorten <=2pt,shape aspect=1]
node (A) [cylinder, shape border rotate=90, draw,minimum height=3cm,minimum width=2cm]
{};
draw [<->] (A.before top) -- (A.after top) node [midway, above,fill=white] {$A_0$};
end{tikzpicture}
end{document}
Is it possible to inscribe a parallelepiped in the code's cylinder?
3d tikz-3d
I 'm trying to draw a simple 3D shape (like parallelepiped or cylinder) with tikz, but I fund too complicated codes.
I want to draw something like this
Is it possible with a simple code?
Thank's in advanced!
Edit
What I mean by "simple code"? Something like this:
documentclass[tikz]{standalone}
usetikzlibrary{shapes}
begin{document}
begin{tikzpicture}[>=latex,shorten >=2pt,shorten <=2pt,shape aspect=1]
node (A) [cylinder, shape border rotate=90, draw,minimum height=3cm,minimum width=2cm]
{};
draw [<->] (A.before top) -- (A.after top) node [midway, above,fill=white] {$A_0$};
end{tikzpicture}
end{document}
Is it possible to inscribe a parallelepiped in the code's cylinder?
3d tikz-3d
3d tikz-3d
edited Jan 10 at 6:27
Kώστας Κούδας
asked Jan 9 at 10:56
Kώστας ΚούδαςKώστας Κούδας
1477
1477
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Kurt
Jan 10 at 0:00
I 'm sorry, you are right. I found some solutions for my question by searching, but there was to many and complicated (for me of course) to post them. I thought that I will confuse the reader if I post them, so I decide to ask about a simple code (if there is one).
– Kώστας Κούδας
Jan 10 at 5:55
add a comment |
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Kurt
Jan 10 at 0:00
I 'm sorry, you are right. I found some solutions for my question by searching, but there was to many and complicated (for me of course) to post them. I thought that I will confuse the reader if I post them, so I decide to ask about a simple code (if there is one).
– Kώστας Κούδας
Jan 10 at 5:55
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Kurt
Jan 10 at 0:00
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Kurt
Jan 10 at 0:00
I 'm sorry, you are right. I found some solutions for my question by searching, but there was to many and complicated (for me of course) to post them. I thought that I will confuse the reader if I post them, so I decide to ask about a simple code (if there is one).
– Kώστας Κούδας
Jan 10 at 5:55
I 'm sorry, you are right. I found some solutions for my question by searching, but there was to many and complicated (for me of course) to post them. I thought that I will confuse the reader if I post them, so I decide to ask about a simple code (if there is one).
– Kώστας Κούδας
Jan 10 at 5:55
add a comment |
3 Answers
3
active
oldest
votes
I don't know if the following is too complicated.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
begin{document}
tdplotsetmaincoords{70}{50}
pgfmathsetmacro{Radius}{3}
pgfmathsetmacro{Height}{4}
begin{tikzpicture}[tdplot_main_coords]
fill[orange,opacity=0.5] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick,densely dashed] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick] plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[blue,thick,densely dashed,fill=blue,fill opacity=0.1] ({Radius*cos(0)},{Radius*sin(0)},0) --
({Radius*cos(90)},{Radius*sin(90)},0)
-- ({Radius*cos(180)},{Radius*sin(180)},0) --
({Radius*cos(270)},{Radius*sin(270)},0) -- cycle;
draw[blue,thick] ({Radius*cos(0)},{Radius*sin(0)},0) -- ({Radius*cos(0)},{Radius*sin(0)},Height);
draw[blue,thick] ({Radius*cos(-90)},{Radius*sin(-90)},0) -- ({Radius*cos(-90)},{Radius*sin(-90)},Height);
draw[blue,thick,dashed] ({Radius*cos(180)},{Radius*sin(180)},0) -- ({Radius*cos(180)},{Radius*sin(180)},Height);
draw[blue,thick,dashed] ({Radius*cos(90)},{Radius*sin(90)},0) -- ({Radius*cos(90)},{Radius*sin(90)},Height);
draw[blue,thick,fill=blue,fill opacity=0.2] ({Radius*cos(0)},{Radius*sin(0)},Height) --
({Radius*cos(90)},{Radius*sin(90)},Height)
-- ({Radius*cos(180)},{Radius*sin(180)},Height) --
({Radius*cos(270)},{Radius*sin(270)},Height) -- cycle;
shade[top color=orange!70!black,bottom color=orange!40!black,
middle color=orange!70,opacity=0.4,shading angle=90]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0) --
plot[variable=x,domain=tdplotmainphi-180:tdplotmainphi,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
draw[orange!80!black,thick,fill=orange!80,fill opacity=0.4]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
end{tikzpicture}
end{document}
I don't know if code indentation would help here.
– Werner
Jan 9 at 19:07
@marmot this is very good solution. I will be a liar, if I tell you that I found simple your solution, but I 'll try to understand it.Thank's a lot!!!
– Kώστας Κούδας
Jan 10 at 6:33
add a comment |
Run with xelatex
:
documentclass[pstricks]{standalone}
usepackage{pst-solides3d}
begin{document}
begin{pspicture}[solidmemory](-2.5,-2.5)(2.5,2.5)
psset{viewpoint=50 30 20 rtp2xyz,lightsrc=viewpoint,
linewidth=0.1pt,linecolor=red!50}
psSolid[object=cylindrecreux,h=2.82,r=2,fillcolor=red!50,ngrid=4
72,name=cy](0,0,-1.41)
psSolid[object=cube,a=2.80,fillcolor=blue!50,name=cu]
psSolid[object=fusion,base=cy cu,opacity=0.5]
end{pspicture}
end{document}
and as gif animation:
add a comment |
You can reduce @marmot's code using foreach
and a yscale
to draw ellipses:
documentclass[tikz,margin=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}[yscale=.4]
defangle{30}
%% Bottom of the cylinder
fill[orange!20] (0,-2) circle (1);
draw[dashed,orange] (1,-2) arc (0:180:1);
%% Top and bottom of the cube
foreach a in {0,90,180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,1)+(a+angle+90:1)$);
draw[dashed] ($(0,-2)+(a+angle:1)$) -- ($(0,-2)+(a+angle+90:1)$);
}
%% Side of the cube
foreach a in {0,90}{
draw[dashed] ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
foreach a in {180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
%% Top of the cylinder and shading
draw[orange,fill=orange,fill opacity=.2] (0,1) circle (1);
draw[orange] (1,-2) arc (0:-180:1);
shade [ left color=orange!70!black, right color=orange!40!black, middle color=orange!70,opacity=0.4 ] (1,1) arc (0:-180:1) -- (-1,-2) arc (180:360:1);
end{tikzpicture}
end{document}
which gives
@Herbert that's what I meant by "simple solution"! Great! Thank's! The only problem is that I 'm writing a book in pdflatex...
– Kώστας Κούδας
Jan 11 at 10:55
thank's a lot! I 'll study your answer! You were very helpful!
– Kώστας Κούδας
Jan 11 at 10:57
add a comment |
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',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469325%2fparallelepiped-inscribed-in-cylinder%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
I don't know if the following is too complicated.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
begin{document}
tdplotsetmaincoords{70}{50}
pgfmathsetmacro{Radius}{3}
pgfmathsetmacro{Height}{4}
begin{tikzpicture}[tdplot_main_coords]
fill[orange,opacity=0.5] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick,densely dashed] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick] plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[blue,thick,densely dashed,fill=blue,fill opacity=0.1] ({Radius*cos(0)},{Radius*sin(0)},0) --
({Radius*cos(90)},{Radius*sin(90)},0)
-- ({Radius*cos(180)},{Radius*sin(180)},0) --
({Radius*cos(270)},{Radius*sin(270)},0) -- cycle;
draw[blue,thick] ({Radius*cos(0)},{Radius*sin(0)},0) -- ({Radius*cos(0)},{Radius*sin(0)},Height);
draw[blue,thick] ({Radius*cos(-90)},{Radius*sin(-90)},0) -- ({Radius*cos(-90)},{Radius*sin(-90)},Height);
draw[blue,thick,dashed] ({Radius*cos(180)},{Radius*sin(180)},0) -- ({Radius*cos(180)},{Radius*sin(180)},Height);
draw[blue,thick,dashed] ({Radius*cos(90)},{Radius*sin(90)},0) -- ({Radius*cos(90)},{Radius*sin(90)},Height);
draw[blue,thick,fill=blue,fill opacity=0.2] ({Radius*cos(0)},{Radius*sin(0)},Height) --
({Radius*cos(90)},{Radius*sin(90)},Height)
-- ({Radius*cos(180)},{Radius*sin(180)},Height) --
({Radius*cos(270)},{Radius*sin(270)},Height) -- cycle;
shade[top color=orange!70!black,bottom color=orange!40!black,
middle color=orange!70,opacity=0.4,shading angle=90]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0) --
plot[variable=x,domain=tdplotmainphi-180:tdplotmainphi,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
draw[orange!80!black,thick,fill=orange!80,fill opacity=0.4]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
end{tikzpicture}
end{document}
I don't know if code indentation would help here.
– Werner
Jan 9 at 19:07
@marmot this is very good solution. I will be a liar, if I tell you that I found simple your solution, but I 'll try to understand it.Thank's a lot!!!
– Kώστας Κούδας
Jan 10 at 6:33
add a comment |
I don't know if the following is too complicated.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
begin{document}
tdplotsetmaincoords{70}{50}
pgfmathsetmacro{Radius}{3}
pgfmathsetmacro{Height}{4}
begin{tikzpicture}[tdplot_main_coords]
fill[orange,opacity=0.5] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick,densely dashed] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick] plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[blue,thick,densely dashed,fill=blue,fill opacity=0.1] ({Radius*cos(0)},{Radius*sin(0)},0) --
({Radius*cos(90)},{Radius*sin(90)},0)
-- ({Radius*cos(180)},{Radius*sin(180)},0) --
({Radius*cos(270)},{Radius*sin(270)},0) -- cycle;
draw[blue,thick] ({Radius*cos(0)},{Radius*sin(0)},0) -- ({Radius*cos(0)},{Radius*sin(0)},Height);
draw[blue,thick] ({Radius*cos(-90)},{Radius*sin(-90)},0) -- ({Radius*cos(-90)},{Radius*sin(-90)},Height);
draw[blue,thick,dashed] ({Radius*cos(180)},{Radius*sin(180)},0) -- ({Radius*cos(180)},{Radius*sin(180)},Height);
draw[blue,thick,dashed] ({Radius*cos(90)},{Radius*sin(90)},0) -- ({Radius*cos(90)},{Radius*sin(90)},Height);
draw[blue,thick,fill=blue,fill opacity=0.2] ({Radius*cos(0)},{Radius*sin(0)},Height) --
({Radius*cos(90)},{Radius*sin(90)},Height)
-- ({Radius*cos(180)},{Radius*sin(180)},Height) --
({Radius*cos(270)},{Radius*sin(270)},Height) -- cycle;
shade[top color=orange!70!black,bottom color=orange!40!black,
middle color=orange!70,opacity=0.4,shading angle=90]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0) --
plot[variable=x,domain=tdplotmainphi-180:tdplotmainphi,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
draw[orange!80!black,thick,fill=orange!80,fill opacity=0.4]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
end{tikzpicture}
end{document}
I don't know if code indentation would help here.
– Werner
Jan 9 at 19:07
@marmot this is very good solution. I will be a liar, if I tell you that I found simple your solution, but I 'll try to understand it.Thank's a lot!!!
– Kώστας Κούδας
Jan 10 at 6:33
add a comment |
I don't know if the following is too complicated.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
begin{document}
tdplotsetmaincoords{70}{50}
pgfmathsetmacro{Radius}{3}
pgfmathsetmacro{Height}{4}
begin{tikzpicture}[tdplot_main_coords]
fill[orange,opacity=0.5] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick,densely dashed] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick] plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[blue,thick,densely dashed,fill=blue,fill opacity=0.1] ({Radius*cos(0)},{Radius*sin(0)},0) --
({Radius*cos(90)},{Radius*sin(90)},0)
-- ({Radius*cos(180)},{Radius*sin(180)},0) --
({Radius*cos(270)},{Radius*sin(270)},0) -- cycle;
draw[blue,thick] ({Radius*cos(0)},{Radius*sin(0)},0) -- ({Radius*cos(0)},{Radius*sin(0)},Height);
draw[blue,thick] ({Radius*cos(-90)},{Radius*sin(-90)},0) -- ({Radius*cos(-90)},{Radius*sin(-90)},Height);
draw[blue,thick,dashed] ({Radius*cos(180)},{Radius*sin(180)},0) -- ({Radius*cos(180)},{Radius*sin(180)},Height);
draw[blue,thick,dashed] ({Radius*cos(90)},{Radius*sin(90)},0) -- ({Radius*cos(90)},{Radius*sin(90)},Height);
draw[blue,thick,fill=blue,fill opacity=0.2] ({Radius*cos(0)},{Radius*sin(0)},Height) --
({Radius*cos(90)},{Radius*sin(90)},Height)
-- ({Radius*cos(180)},{Radius*sin(180)},Height) --
({Radius*cos(270)},{Radius*sin(270)},Height) -- cycle;
shade[top color=orange!70!black,bottom color=orange!40!black,
middle color=orange!70,opacity=0.4,shading angle=90]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0) --
plot[variable=x,domain=tdplotmainphi-180:tdplotmainphi,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
draw[orange!80!black,thick,fill=orange!80,fill opacity=0.4]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
end{tikzpicture}
end{document}
I don't know if the following is too complicated.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
begin{document}
tdplotsetmaincoords{70}{50}
pgfmathsetmacro{Radius}{3}
pgfmathsetmacro{Height}{4}
begin{tikzpicture}[tdplot_main_coords]
fill[orange,opacity=0.5] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick,densely dashed] plot[variable=x,domain=tdplotmainphi:tdplotmainphi+180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[orange!80!black,thick] plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0);
draw[blue,thick,densely dashed,fill=blue,fill opacity=0.1] ({Radius*cos(0)},{Radius*sin(0)},0) --
({Radius*cos(90)},{Radius*sin(90)},0)
-- ({Radius*cos(180)},{Radius*sin(180)},0) --
({Radius*cos(270)},{Radius*sin(270)},0) -- cycle;
draw[blue,thick] ({Radius*cos(0)},{Radius*sin(0)},0) -- ({Radius*cos(0)},{Radius*sin(0)},Height);
draw[blue,thick] ({Radius*cos(-90)},{Radius*sin(-90)},0) -- ({Radius*cos(-90)},{Radius*sin(-90)},Height);
draw[blue,thick,dashed] ({Radius*cos(180)},{Radius*sin(180)},0) -- ({Radius*cos(180)},{Radius*sin(180)},Height);
draw[blue,thick,dashed] ({Radius*cos(90)},{Radius*sin(90)},0) -- ({Radius*cos(90)},{Radius*sin(90)},Height);
draw[blue,thick,fill=blue,fill opacity=0.2] ({Radius*cos(0)},{Radius*sin(0)},Height) --
({Radius*cos(90)},{Radius*sin(90)},Height)
-- ({Radius*cos(180)},{Radius*sin(180)},Height) --
({Radius*cos(270)},{Radius*sin(270)},Height) -- cycle;
shade[top color=orange!70!black,bottom color=orange!40!black,
middle color=orange!70,opacity=0.4,shading angle=90]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi-180,smooth]
({Radius*cos(x)},{Radius*sin(x)},0) --
plot[variable=x,domain=tdplotmainphi-180:tdplotmainphi,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
draw[orange!80!black,thick,fill=orange!80,fill opacity=0.4]
plot[variable=x,domain=tdplotmainphi:tdplotmainphi+360,smooth]
({Radius*cos(x)},{Radius*sin(x)},Height);
end{tikzpicture}
end{document}
answered Jan 9 at 16:09
marmotmarmot
91.9k4107200
91.9k4107200
I don't know if code indentation would help here.
– Werner
Jan 9 at 19:07
@marmot this is very good solution. I will be a liar, if I tell you that I found simple your solution, but I 'll try to understand it.Thank's a lot!!!
– Kώστας Κούδας
Jan 10 at 6:33
add a comment |
I don't know if code indentation would help here.
– Werner
Jan 9 at 19:07
@marmot this is very good solution. I will be a liar, if I tell you that I found simple your solution, but I 'll try to understand it.Thank's a lot!!!
– Kώστας Κούδας
Jan 10 at 6:33
I don't know if code indentation would help here.
– Werner
Jan 9 at 19:07
I don't know if code indentation would help here.
– Werner
Jan 9 at 19:07
@marmot this is very good solution. I will be a liar, if I tell you that I found simple your solution, but I 'll try to understand it.Thank's a lot!!!
– Kώστας Κούδας
Jan 10 at 6:33
@marmot this is very good solution. I will be a liar, if I tell you that I found simple your solution, but I 'll try to understand it.Thank's a lot!!!
– Kώστας Κούδας
Jan 10 at 6:33
add a comment |
Run with xelatex
:
documentclass[pstricks]{standalone}
usepackage{pst-solides3d}
begin{document}
begin{pspicture}[solidmemory](-2.5,-2.5)(2.5,2.5)
psset{viewpoint=50 30 20 rtp2xyz,lightsrc=viewpoint,
linewidth=0.1pt,linecolor=red!50}
psSolid[object=cylindrecreux,h=2.82,r=2,fillcolor=red!50,ngrid=4
72,name=cy](0,0,-1.41)
psSolid[object=cube,a=2.80,fillcolor=blue!50,name=cu]
psSolid[object=fusion,base=cy cu,opacity=0.5]
end{pspicture}
end{document}
and as gif animation:
add a comment |
Run with xelatex
:
documentclass[pstricks]{standalone}
usepackage{pst-solides3d}
begin{document}
begin{pspicture}[solidmemory](-2.5,-2.5)(2.5,2.5)
psset{viewpoint=50 30 20 rtp2xyz,lightsrc=viewpoint,
linewidth=0.1pt,linecolor=red!50}
psSolid[object=cylindrecreux,h=2.82,r=2,fillcolor=red!50,ngrid=4
72,name=cy](0,0,-1.41)
psSolid[object=cube,a=2.80,fillcolor=blue!50,name=cu]
psSolid[object=fusion,base=cy cu,opacity=0.5]
end{pspicture}
end{document}
and as gif animation:
add a comment |
Run with xelatex
:
documentclass[pstricks]{standalone}
usepackage{pst-solides3d}
begin{document}
begin{pspicture}[solidmemory](-2.5,-2.5)(2.5,2.5)
psset{viewpoint=50 30 20 rtp2xyz,lightsrc=viewpoint,
linewidth=0.1pt,linecolor=red!50}
psSolid[object=cylindrecreux,h=2.82,r=2,fillcolor=red!50,ngrid=4
72,name=cy](0,0,-1.41)
psSolid[object=cube,a=2.80,fillcolor=blue!50,name=cu]
psSolid[object=fusion,base=cy cu,opacity=0.5]
end{pspicture}
end{document}
and as gif animation:
Run with xelatex
:
documentclass[pstricks]{standalone}
usepackage{pst-solides3d}
begin{document}
begin{pspicture}[solidmemory](-2.5,-2.5)(2.5,2.5)
psset{viewpoint=50 30 20 rtp2xyz,lightsrc=viewpoint,
linewidth=0.1pt,linecolor=red!50}
psSolid[object=cylindrecreux,h=2.82,r=2,fillcolor=red!50,ngrid=4
72,name=cy](0,0,-1.41)
psSolid[object=cube,a=2.80,fillcolor=blue!50,name=cu]
psSolid[object=fusion,base=cy cu,opacity=0.5]
end{pspicture}
end{document}
and as gif animation:
answered Jan 10 at 9:48
HerbertHerbert
271k24409719
271k24409719
add a comment |
add a comment |
You can reduce @marmot's code using foreach
and a yscale
to draw ellipses:
documentclass[tikz,margin=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}[yscale=.4]
defangle{30}
%% Bottom of the cylinder
fill[orange!20] (0,-2) circle (1);
draw[dashed,orange] (1,-2) arc (0:180:1);
%% Top and bottom of the cube
foreach a in {0,90,180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,1)+(a+angle+90:1)$);
draw[dashed] ($(0,-2)+(a+angle:1)$) -- ($(0,-2)+(a+angle+90:1)$);
}
%% Side of the cube
foreach a in {0,90}{
draw[dashed] ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
foreach a in {180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
%% Top of the cylinder and shading
draw[orange,fill=orange,fill opacity=.2] (0,1) circle (1);
draw[orange] (1,-2) arc (0:-180:1);
shade [ left color=orange!70!black, right color=orange!40!black, middle color=orange!70,opacity=0.4 ] (1,1) arc (0:-180:1) -- (-1,-2) arc (180:360:1);
end{tikzpicture}
end{document}
which gives
@Herbert that's what I meant by "simple solution"! Great! Thank's! The only problem is that I 'm writing a book in pdflatex...
– Kώστας Κούδας
Jan 11 at 10:55
thank's a lot! I 'll study your answer! You were very helpful!
– Kώστας Κούδας
Jan 11 at 10:57
add a comment |
You can reduce @marmot's code using foreach
and a yscale
to draw ellipses:
documentclass[tikz,margin=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}[yscale=.4]
defangle{30}
%% Bottom of the cylinder
fill[orange!20] (0,-2) circle (1);
draw[dashed,orange] (1,-2) arc (0:180:1);
%% Top and bottom of the cube
foreach a in {0,90,180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,1)+(a+angle+90:1)$);
draw[dashed] ($(0,-2)+(a+angle:1)$) -- ($(0,-2)+(a+angle+90:1)$);
}
%% Side of the cube
foreach a in {0,90}{
draw[dashed] ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
foreach a in {180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
%% Top of the cylinder and shading
draw[orange,fill=orange,fill opacity=.2] (0,1) circle (1);
draw[orange] (1,-2) arc (0:-180:1);
shade [ left color=orange!70!black, right color=orange!40!black, middle color=orange!70,opacity=0.4 ] (1,1) arc (0:-180:1) -- (-1,-2) arc (180:360:1);
end{tikzpicture}
end{document}
which gives
@Herbert that's what I meant by "simple solution"! Great! Thank's! The only problem is that I 'm writing a book in pdflatex...
– Kώστας Κούδας
Jan 11 at 10:55
thank's a lot! I 'll study your answer! You were very helpful!
– Kώστας Κούδας
Jan 11 at 10:57
add a comment |
You can reduce @marmot's code using foreach
and a yscale
to draw ellipses:
documentclass[tikz,margin=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}[yscale=.4]
defangle{30}
%% Bottom of the cylinder
fill[orange!20] (0,-2) circle (1);
draw[dashed,orange] (1,-2) arc (0:180:1);
%% Top and bottom of the cube
foreach a in {0,90,180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,1)+(a+angle+90:1)$);
draw[dashed] ($(0,-2)+(a+angle:1)$) -- ($(0,-2)+(a+angle+90:1)$);
}
%% Side of the cube
foreach a in {0,90}{
draw[dashed] ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
foreach a in {180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
%% Top of the cylinder and shading
draw[orange,fill=orange,fill opacity=.2] (0,1) circle (1);
draw[orange] (1,-2) arc (0:-180:1);
shade [ left color=orange!70!black, right color=orange!40!black, middle color=orange!70,opacity=0.4 ] (1,1) arc (0:-180:1) -- (-1,-2) arc (180:360:1);
end{tikzpicture}
end{document}
which gives
You can reduce @marmot's code using foreach
and a yscale
to draw ellipses:
documentclass[tikz,margin=10pt]{standalone}
usetikzlibrary{calc}
begin{document}
begin{tikzpicture}[yscale=.4]
defangle{30}
%% Bottom of the cylinder
fill[orange!20] (0,-2) circle (1);
draw[dashed,orange] (1,-2) arc (0:180:1);
%% Top and bottom of the cube
foreach a in {0,90,180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,1)+(a+angle+90:1)$);
draw[dashed] ($(0,-2)+(a+angle:1)$) -- ($(0,-2)+(a+angle+90:1)$);
}
%% Side of the cube
foreach a in {0,90}{
draw[dashed] ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
foreach a in {180,270}{
draw ($(0,1)+(a+angle:1)$) -- ($(0,-2)+(a+angle:1)$);
}
%% Top of the cylinder and shading
draw[orange,fill=orange,fill opacity=.2] (0,1) circle (1);
draw[orange] (1,-2) arc (0:-180:1);
shade [ left color=orange!70!black, right color=orange!40!black, middle color=orange!70,opacity=0.4 ] (1,1) arc (0:-180:1) -- (-1,-2) arc (180:360:1);
end{tikzpicture}
end{document}
which gives
answered Jan 10 at 10:08
VinzzaVinzza
30019
30019
@Herbert that's what I meant by "simple solution"! Great! Thank's! The only problem is that I 'm writing a book in pdflatex...
– Kώστας Κούδας
Jan 11 at 10:55
thank's a lot! I 'll study your answer! You were very helpful!
– Kώστας Κούδας
Jan 11 at 10:57
add a comment |
@Herbert that's what I meant by "simple solution"! Great! Thank's! The only problem is that I 'm writing a book in pdflatex...
– Kώστας Κούδας
Jan 11 at 10:55
thank's a lot! I 'll study your answer! You were very helpful!
– Kώστας Κούδας
Jan 11 at 10:57
@Herbert that's what I meant by "simple solution"! Great! Thank's! The only problem is that I 'm writing a book in pdflatex...
– Kώστας Κούδας
Jan 11 at 10:55
@Herbert that's what I meant by "simple solution"! Great! Thank's! The only problem is that I 'm writing a book in pdflatex...
– Kώστας Κούδας
Jan 11 at 10:55
thank's a lot! I 'll study your answer! You were very helpful!
– Kώστας Κούδας
Jan 11 at 10:57
thank's a lot! I 'll study your answer! You were very helpful!
– Kώστας Κούδας
Jan 11 at 10:57
add a comment |
Thanks for contributing an answer to TeX - LaTeX Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f469325%2fparallelepiped-inscribed-in-cylinder%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Welcome to TeX.SX. Questions about how to draw specific graphics that just post an image of the desired result are really not reasonable questions to ask on the site. Please post a minimal compilable document showing that you've tried to produce the image and then people will be happy to help you with any specific problems you may have. See minimal working example (MWE) for what needs to go into such a document.
– Kurt
Jan 10 at 0:00
I 'm sorry, you are right. I found some solutions for my question by searching, but there was to many and complicated (for me of course) to post them. I thought that I will confuse the reader if I post them, so I decide to ask about a simple code (if there is one).
– Kώστας Κούδας
Jan 10 at 5:55