Draw a truncated pyramid with a square base
I want to draw a truncated pyramid that is suspended on a rope, and submersed inside water in a cylinder.
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{patterns}
begin{document}
begin{tikzpicture}
draw[gray!66](0,1) ellipse (2cm and 1cm);
draw(0,2) ellipse (2cm and 1cm);
draw(0,-3) ellipse (2cm and 1cm);
draw(2,-3)--(2,2);
draw(-2,-3)--(-2,2);
fill[pattern=north west lines](-1,4.4) rectangle (1,4.75);
draw(-1,4.4)--(1,4.4);
draw(0,4.4)--(0,-1);
end{tikzpicture}
end{document}
tikz-pgf
add a comment |
I want to draw a truncated pyramid that is suspended on a rope, and submersed inside water in a cylinder.
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{patterns}
begin{document}
begin{tikzpicture}
draw[gray!66](0,1) ellipse (2cm and 1cm);
draw(0,2) ellipse (2cm and 1cm);
draw(0,-3) ellipse (2cm and 1cm);
draw(2,-3)--(2,2);
draw(-2,-3)--(-2,2);
fill[pattern=north west lines](-1,4.4) rectangle (1,4.75);
draw(-1,4.4)--(1,4.4);
draw(0,4.4)--(0,-1);
end{tikzpicture}
end{document}
tikz-pgf
add a comment |
I want to draw a truncated pyramid that is suspended on a rope, and submersed inside water in a cylinder.
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{patterns}
begin{document}
begin{tikzpicture}
draw[gray!66](0,1) ellipse (2cm and 1cm);
draw(0,2) ellipse (2cm and 1cm);
draw(0,-3) ellipse (2cm and 1cm);
draw(2,-3)--(2,2);
draw(-2,-3)--(-2,2);
fill[pattern=north west lines](-1,4.4) rectangle (1,4.75);
draw(-1,4.4)--(1,4.4);
draw(0,4.4)--(0,-1);
end{tikzpicture}
end{document}
tikz-pgf
I want to draw a truncated pyramid that is suspended on a rope, and submersed inside water in a cylinder.
documentclass{standalone}
usepackage{tikz}
usetikzlibrary{patterns}
begin{document}
begin{tikzpicture}
draw[gray!66](0,1) ellipse (2cm and 1cm);
draw(0,2) ellipse (2cm and 1cm);
draw(0,-3) ellipse (2cm and 1cm);
draw(2,-3)--(2,2);
draw(-2,-3)--(-2,2);
fill[pattern=north west lines](-1,4.4) rectangle (1,4.75);
draw(-1,4.4)--(1,4.4);
draw(0,4.4)--(0,-1);
end{tikzpicture}
end{document}
tikz-pgf
tikz-pgf
edited Feb 4 at 14:46
Peter Mortensen
55037
55037
asked Feb 4 at 5:41
ThumboltThumbolt
1,509821
1,509821
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
I'd use 3d coordinates for that.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{0.5}
pgfmathsetmacro{zpyr}{3.5}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{whpyr}{wpyr-(hwater-zpyr)*wpyr/hpyr} % width of pyramid at water level
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
begin{scope}
clip (-whpyr/2,-whpyr/2,hwater)
-- (whpyr/2,-whpyr/2,hwater) -- (whpyr/2,whpyr/2,hwater)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,hwater)
[reverseclip];
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},hwater);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},hwater)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
end{tikzpicture}
end{document}
And this is an animation for Christian Hupfer with corrections due to @circumscribe.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
foreach Z in {0,10,...,350}
{tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{1.2}
pgfmathsetmacro{zpyr}{2.8+0.8*cos(Z)}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{deltahmax}{(wpyr^2/(pi*rcyl^2))*(hpyr-hremoved^3/hpyr^2)/3}
pgfmathsetmacro{waterlevel}{hwater+ifthenelse(zpyr<hwater,1,0)*deltahmax*
ifthenelse(zpyr>hwater-hpyr+hremoved,
1-((zpyr-hwater+hpyr-hremoved)/(hpyr-hremoved))^3,1)}
%typeout{deltahmax=deltahmax,waterlevel=waterlevel,zpyr=zpyr,hwater=hwater}
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
pgfmathsetmacro{whpyr}{wpyr-(waterlevel-zpyr)*wpyr/hpyr} % width of pyramid at water level
begin{scope}
pgfmathtruncatemacro{itest}{sign(-(waterlevel-zpyr)+(hpyr-hremoved))}
ifnumitest=1
clip (-whpyr/2,-whpyr/2,waterlevel)
-- (whpyr/2,-whpyr/2,waterlevel) -- (whpyr/2,whpyr/2,waterlevel)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,waterlevel)
[reverseclip];
fi
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},waterlevel);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},waterlevel)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
% node[anchor=north west,tdplot_screen_coords,align=right]
% at (1,7.75){waterlevel\ zpyr};
end{tikzpicture}}
end{document}
The top of the pyramid should be removed so that the resulting cross-section is a square. The rope is attached to the center of that square.
– Thumbolt
Feb 4 at 6:28
3
Well, the pyramid is apparently full of holes -- the water level does not rise during the lowering of the pyramid. ;-)
– user31729
Feb 4 at 9:28
1
@ChristianHupfer Perhaps the dotted line at the bottom suggests an infinitely long cilinder?
– Servaes
Feb 4 at 12:09
2
@ChristianHupfer That's a so-called well-tempered pyramid, which changes the water temperature in such a way that the water level remains constant. ;-)
– marmot
Feb 4 at 15:31
1
@marmot: Yeah, that's probably wise, since it'd be hard to notice the difference. The change in water level looks more realistic now, but also less impressive somehow :).
– Circumscribe
Feb 6 at 15:31
|
show 5 more comments
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%2f473280%2fdraw-a-truncated-pyramid-with-a-square-base%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I'd use 3d coordinates for that.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{0.5}
pgfmathsetmacro{zpyr}{3.5}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{whpyr}{wpyr-(hwater-zpyr)*wpyr/hpyr} % width of pyramid at water level
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
begin{scope}
clip (-whpyr/2,-whpyr/2,hwater)
-- (whpyr/2,-whpyr/2,hwater) -- (whpyr/2,whpyr/2,hwater)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,hwater)
[reverseclip];
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},hwater);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},hwater)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
end{tikzpicture}
end{document}
And this is an animation for Christian Hupfer with corrections due to @circumscribe.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
foreach Z in {0,10,...,350}
{tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{1.2}
pgfmathsetmacro{zpyr}{2.8+0.8*cos(Z)}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{deltahmax}{(wpyr^2/(pi*rcyl^2))*(hpyr-hremoved^3/hpyr^2)/3}
pgfmathsetmacro{waterlevel}{hwater+ifthenelse(zpyr<hwater,1,0)*deltahmax*
ifthenelse(zpyr>hwater-hpyr+hremoved,
1-((zpyr-hwater+hpyr-hremoved)/(hpyr-hremoved))^3,1)}
%typeout{deltahmax=deltahmax,waterlevel=waterlevel,zpyr=zpyr,hwater=hwater}
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
pgfmathsetmacro{whpyr}{wpyr-(waterlevel-zpyr)*wpyr/hpyr} % width of pyramid at water level
begin{scope}
pgfmathtruncatemacro{itest}{sign(-(waterlevel-zpyr)+(hpyr-hremoved))}
ifnumitest=1
clip (-whpyr/2,-whpyr/2,waterlevel)
-- (whpyr/2,-whpyr/2,waterlevel) -- (whpyr/2,whpyr/2,waterlevel)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,waterlevel)
[reverseclip];
fi
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},waterlevel);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},waterlevel)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
% node[anchor=north west,tdplot_screen_coords,align=right]
% at (1,7.75){waterlevel\ zpyr};
end{tikzpicture}}
end{document}
The top of the pyramid should be removed so that the resulting cross-section is a square. The rope is attached to the center of that square.
– Thumbolt
Feb 4 at 6:28
3
Well, the pyramid is apparently full of holes -- the water level does not rise during the lowering of the pyramid. ;-)
– user31729
Feb 4 at 9:28
1
@ChristianHupfer Perhaps the dotted line at the bottom suggests an infinitely long cilinder?
– Servaes
Feb 4 at 12:09
2
@ChristianHupfer That's a so-called well-tempered pyramid, which changes the water temperature in such a way that the water level remains constant. ;-)
– marmot
Feb 4 at 15:31
1
@marmot: Yeah, that's probably wise, since it'd be hard to notice the difference. The change in water level looks more realistic now, but also less impressive somehow :).
– Circumscribe
Feb 6 at 15:31
|
show 5 more comments
I'd use 3d coordinates for that.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{0.5}
pgfmathsetmacro{zpyr}{3.5}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{whpyr}{wpyr-(hwater-zpyr)*wpyr/hpyr} % width of pyramid at water level
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
begin{scope}
clip (-whpyr/2,-whpyr/2,hwater)
-- (whpyr/2,-whpyr/2,hwater) -- (whpyr/2,whpyr/2,hwater)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,hwater)
[reverseclip];
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},hwater);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},hwater)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
end{tikzpicture}
end{document}
And this is an animation for Christian Hupfer with corrections due to @circumscribe.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
foreach Z in {0,10,...,350}
{tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{1.2}
pgfmathsetmacro{zpyr}{2.8+0.8*cos(Z)}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{deltahmax}{(wpyr^2/(pi*rcyl^2))*(hpyr-hremoved^3/hpyr^2)/3}
pgfmathsetmacro{waterlevel}{hwater+ifthenelse(zpyr<hwater,1,0)*deltahmax*
ifthenelse(zpyr>hwater-hpyr+hremoved,
1-((zpyr-hwater+hpyr-hremoved)/(hpyr-hremoved))^3,1)}
%typeout{deltahmax=deltahmax,waterlevel=waterlevel,zpyr=zpyr,hwater=hwater}
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
pgfmathsetmacro{whpyr}{wpyr-(waterlevel-zpyr)*wpyr/hpyr} % width of pyramid at water level
begin{scope}
pgfmathtruncatemacro{itest}{sign(-(waterlevel-zpyr)+(hpyr-hremoved))}
ifnumitest=1
clip (-whpyr/2,-whpyr/2,waterlevel)
-- (whpyr/2,-whpyr/2,waterlevel) -- (whpyr/2,whpyr/2,waterlevel)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,waterlevel)
[reverseclip];
fi
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},waterlevel);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},waterlevel)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
% node[anchor=north west,tdplot_screen_coords,align=right]
% at (1,7.75){waterlevel\ zpyr};
end{tikzpicture}}
end{document}
The top of the pyramid should be removed so that the resulting cross-section is a square. The rope is attached to the center of that square.
– Thumbolt
Feb 4 at 6:28
3
Well, the pyramid is apparently full of holes -- the water level does not rise during the lowering of the pyramid. ;-)
– user31729
Feb 4 at 9:28
1
@ChristianHupfer Perhaps the dotted line at the bottom suggests an infinitely long cilinder?
– Servaes
Feb 4 at 12:09
2
@ChristianHupfer That's a so-called well-tempered pyramid, which changes the water temperature in such a way that the water level remains constant. ;-)
– marmot
Feb 4 at 15:31
1
@marmot: Yeah, that's probably wise, since it'd be hard to notice the difference. The change in water level looks more realistic now, but also less impressive somehow :).
– Circumscribe
Feb 6 at 15:31
|
show 5 more comments
I'd use 3d coordinates for that.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{0.5}
pgfmathsetmacro{zpyr}{3.5}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{whpyr}{wpyr-(hwater-zpyr)*wpyr/hpyr} % width of pyramid at water level
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
begin{scope}
clip (-whpyr/2,-whpyr/2,hwater)
-- (whpyr/2,-whpyr/2,hwater) -- (whpyr/2,whpyr/2,hwater)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,hwater)
[reverseclip];
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},hwater);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},hwater)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
end{tikzpicture}
end{document}
And this is an animation for Christian Hupfer with corrections due to @circumscribe.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
foreach Z in {0,10,...,350}
{tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{1.2}
pgfmathsetmacro{zpyr}{2.8+0.8*cos(Z)}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{deltahmax}{(wpyr^2/(pi*rcyl^2))*(hpyr-hremoved^3/hpyr^2)/3}
pgfmathsetmacro{waterlevel}{hwater+ifthenelse(zpyr<hwater,1,0)*deltahmax*
ifthenelse(zpyr>hwater-hpyr+hremoved,
1-((zpyr-hwater+hpyr-hremoved)/(hpyr-hremoved))^3,1)}
%typeout{deltahmax=deltahmax,waterlevel=waterlevel,zpyr=zpyr,hwater=hwater}
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
pgfmathsetmacro{whpyr}{wpyr-(waterlevel-zpyr)*wpyr/hpyr} % width of pyramid at water level
begin{scope}
pgfmathtruncatemacro{itest}{sign(-(waterlevel-zpyr)+(hpyr-hremoved))}
ifnumitest=1
clip (-whpyr/2,-whpyr/2,waterlevel)
-- (whpyr/2,-whpyr/2,waterlevel) -- (whpyr/2,whpyr/2,waterlevel)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,waterlevel)
[reverseclip];
fi
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},waterlevel);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},waterlevel)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
% node[anchor=north west,tdplot_screen_coords,align=right]
% at (1,7.75){waterlevel\ zpyr};
end{tikzpicture}}
end{document}
I'd use 3d coordinates for that.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{0.5}
pgfmathsetmacro{zpyr}{3.5}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{whpyr}{wpyr-(hwater-zpyr)*wpyr/hpyr} % width of pyramid at water level
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
begin{scope}
clip (-whpyr/2,-whpyr/2,hwater)
-- (whpyr/2,-whpyr/2,hwater) -- (whpyr/2,whpyr/2,hwater)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,hwater)
[reverseclip];
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},hwater);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},hwater)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
end{tikzpicture}
end{document}
And this is an animation for Christian Hupfer with corrections due to @circumscribe.
documentclass[tikz,border=3.14mm]{standalone}
usepackage{tikz-3dplot}
usetikzlibrary{patterns}
% https://tex.stackexchange.com/a/12033/121799
tikzset{reverseclip/.style={insert path={(current bounding box.north
east) rectangle (current bounding box.south west)}}}
begin{document}
foreach Z in {0,10,...,350}
{tdplotsetmaincoords{70}{30}
begin{tikzpicture}[tdplot_main_coords,font=sffamily,line join=bevel]
pgfmathsetmacro{rcyl}{2}
pgfmathsetmacro{hcyl}{5}
pgfmathsetmacro{hpyr}{2.5}
pgfmathsetmacro{hremoved}{1.2}
pgfmathsetmacro{zpyr}{2.8+0.8*cos(Z)}
pgfmathsetmacro{wpyr}{1.5}
pgfmathsetmacro{wtop}{hremoved*wpyr/hpyr}
pgfmathsetmacro{hwater}{4}
pgfmathsetmacro{deltahmax}{(wpyr^2/(pi*rcyl^2))*(hpyr-hremoved^3/hpyr^2)/3}
pgfmathsetmacro{waterlevel}{hwater+ifthenelse(zpyr<hwater,1,0)*deltahmax*
ifthenelse(zpyr>hwater-hpyr+hremoved,
1-((zpyr-hwater+hpyr-hremoved)/(hpyr-hremoved))^3,1)}
%typeout{deltahmax=deltahmax,waterlevel=waterlevel,zpyr=zpyr,hwater=hwater}
fill[tdplot_screen_coords,pattern=north west lines] (-1,7.4) rectangle (1,7.75);
draw[tdplot_screen_coords] (-1,7.4) -- (1,7.4) coordinate[midway] (hang);
%
draw[dashed] plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},0);
draw[dashed] (wpyr/2,wpyr/2,zpyr)
-- (-wpyr/2,wpyr/2,zpyr) -- (-wpyr/2,-wpyr/2,zpyr)
(-wpyr/2,wpyr/2,zpyr) -- (-wtop/2,wtop/2,zpyr+hpyr-hremoved);
draw[fill=gray!30,fill opacity=0.5]
(-wpyr/2,-wpyr/2,zpyr) -- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (wpyr/2,-wpyr/2,zpyr)
-- cycle;
draw[fill=gray!50,fill opacity=0.5] (wpyr/2,-wpyr/2,zpyr)
-- (wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (wpyr/2,wpyr/2,zpyr)
-- cycle;
draw[fill=gray!20,fill opacity=0.5]
(wtop/2,-wtop/2,zpyr+hpyr-hremoved)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- cycle;
pgfmathsetmacro{whpyr}{wpyr-(waterlevel-zpyr)*wpyr/hpyr} % width of pyramid at water level
begin{scope}
pgfmathtruncatemacro{itest}{sign(-(waterlevel-zpyr)+(hpyr-hremoved))}
ifnumitest=1
clip (-whpyr/2,-whpyr/2,waterlevel)
-- (whpyr/2,-whpyr/2,waterlevel) -- (whpyr/2,whpyr/2,waterlevel)
-- (wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,wtop/2,zpyr+hpyr-hremoved)
-- (-wtop/2,-wtop/2,zpyr+hpyr-hremoved) -- (-whpyr/2,-whpyr/2,waterlevel)
[reverseclip];
fi
fill[blue,opacity=0.2]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi+360] ({rcyl*cos(t)},{rcyl*sin(t)},waterlevel);
end{scope}
fill[blue,opacity=0.4]
plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},waterlevel)
--
plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi]
({rcyl*cos(t)},{rcyl*sin(t)},0);
draw plot[smooth,variable=t,domain=tdplotmainphi:tdplotmainphi-180]
({rcyl*cos(t)},{rcyl*sin(t)},0)
-- plot[smooth,variable=t,domain=tdplotmainphi-180:tdplotmainphi+180] ({rcyl*cos(t)},{rcyl*sin(t)},hcyl)
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},0) --
({rcyl*cos(tdplotmainphi)},{rcyl*sin(tdplotmainphi)},hcyl);
draw (hang) -- (0,0,zpyr+hpyr-hremoved);
% node[anchor=north west,tdplot_screen_coords,align=right]
% at (1,7.75){waterlevel\ zpyr};
end{tikzpicture}}
end{document}
edited Feb 6 at 15:22
answered Feb 4 at 6:22
marmotmarmot
118k6151284
118k6151284
The top of the pyramid should be removed so that the resulting cross-section is a square. The rope is attached to the center of that square.
– Thumbolt
Feb 4 at 6:28
3
Well, the pyramid is apparently full of holes -- the water level does not rise during the lowering of the pyramid. ;-)
– user31729
Feb 4 at 9:28
1
@ChristianHupfer Perhaps the dotted line at the bottom suggests an infinitely long cilinder?
– Servaes
Feb 4 at 12:09
2
@ChristianHupfer That's a so-called well-tempered pyramid, which changes the water temperature in such a way that the water level remains constant. ;-)
– marmot
Feb 4 at 15:31
1
@marmot: Yeah, that's probably wise, since it'd be hard to notice the difference. The change in water level looks more realistic now, but also less impressive somehow :).
– Circumscribe
Feb 6 at 15:31
|
show 5 more comments
The top of the pyramid should be removed so that the resulting cross-section is a square. The rope is attached to the center of that square.
– Thumbolt
Feb 4 at 6:28
3
Well, the pyramid is apparently full of holes -- the water level does not rise during the lowering of the pyramid. ;-)
– user31729
Feb 4 at 9:28
1
@ChristianHupfer Perhaps the dotted line at the bottom suggests an infinitely long cilinder?
– Servaes
Feb 4 at 12:09
2
@ChristianHupfer That's a so-called well-tempered pyramid, which changes the water temperature in such a way that the water level remains constant. ;-)
– marmot
Feb 4 at 15:31
1
@marmot: Yeah, that's probably wise, since it'd be hard to notice the difference. The change in water level looks more realistic now, but also less impressive somehow :).
– Circumscribe
Feb 6 at 15:31
The top of the pyramid should be removed so that the resulting cross-section is a square. The rope is attached to the center of that square.
– Thumbolt
Feb 4 at 6:28
The top of the pyramid should be removed so that the resulting cross-section is a square. The rope is attached to the center of that square.
– Thumbolt
Feb 4 at 6:28
3
3
Well, the pyramid is apparently full of holes -- the water level does not rise during the lowering of the pyramid. ;-)
– user31729
Feb 4 at 9:28
Well, the pyramid is apparently full of holes -- the water level does not rise during the lowering of the pyramid. ;-)
– user31729
Feb 4 at 9:28
1
1
@ChristianHupfer Perhaps the dotted line at the bottom suggests an infinitely long cilinder?
– Servaes
Feb 4 at 12:09
@ChristianHupfer Perhaps the dotted line at the bottom suggests an infinitely long cilinder?
– Servaes
Feb 4 at 12:09
2
2
@ChristianHupfer That's a so-called well-tempered pyramid, which changes the water temperature in such a way that the water level remains constant. ;-)
– marmot
Feb 4 at 15:31
@ChristianHupfer That's a so-called well-tempered pyramid, which changes the water temperature in such a way that the water level remains constant. ;-)
– marmot
Feb 4 at 15:31
1
1
@marmot: Yeah, that's probably wise, since it'd be hard to notice the difference. The change in water level looks more realistic now, but also less impressive somehow :).
– Circumscribe
Feb 6 at 15:31
@marmot: Yeah, that's probably wise, since it'd be hard to notice the difference. The change in water level looks more realistic now, but also less impressive somehow :).
– Circumscribe
Feb 6 at 15:31
|
show 5 more comments
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%2f473280%2fdraw-a-truncated-pyramid-with-a-square-base%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