How to anchor the origin (0,0,0) to the center of multiple generated images in tikz?TikZ: Cropping the Bounding BoxAlign edges with anchor other than centerHow to define the default vertical distance between nodes?Understanding TikZ border anchorEdge anchor in tikztikz and pgfdeclareshape why the text is not at the center anchor?small multiple images moving toward each other in beamertikz anchor unexpectedtikz-cd nested tikzpicture wrong center anchortikz: show 0 at the axis origin
How to find the positions of replaced elements in a list
How should I ask for a "pint" in countries that use metric?
Is it ok for parents to kiss and romance with each other while their 2- to 8-year-old child watches?
Why did Old English lose both thorn and eth?
How to anchor the origin (0,0,0) to the center of multiple generated images in tikz?
Are all diatonic chords in the diminished scale diminished?
Why is a mixture of two normally distributed variables only bimodal if their means differ by at least two times the common standard deviation?
Optimization models for portfolio optimization
How does one acquire an undead eyeball encased in a gem?
Party going through airport security at separate times?
Publishing papers seem natural to many, while I find it really hard to think novel stuff to pursue till publication. How to cope up with this?
Finding overlapping polygons in two shapefiles and deleting them in R?
Don't the events of "Forest of the Dead" contradict the fixed point in "The Wedding of River Song"?
What would +1/+2/+3 items be called in game?
This LM317 diagram doesn't make any sense to me
Four ships at the ocean with the same distance
What was this character's plan?
I make billions (#6)
Adjust the Table
What's it called when the bad guy gets eaten?
Who buys a weak currency?
First Entry Member State schengen visa
Write a function
My previous employer committed a severe violation of the law and is also being sued by me. How do I explain the situation to future employers?
How to anchor the origin (0,0,0) to the center of multiple generated images in tikz?
TikZ: Cropping the Bounding BoxAlign edges with anchor other than centerHow to define the default vertical distance between nodes?Understanding TikZ border anchorEdge anchor in tikztikz and pgfdeclareshape why the text is not at the center anchor?small multiple images moving toward each other in beamertikz anchor unexpectedtikz-cd nested tikzpicture wrong center anchortikz: show 0 at the axis origin
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;
I have the following file to generate an animation with a separate file
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endtikzpicture
enddocument
but my problem is that the point (0,0,0) changes place during rotation and I would like to have it in a single place throughout the entire animation. Is there a way to anchor it?
Thank you.
tikz-pgf animate
add a comment |
I have the following file to generate an animation with a separate file
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endtikzpicture
enddocument
but my problem is that the point (0,0,0) changes place during rotation and I would like to have it in a single place throughout the entire animation. Is there a way to anchor it?
Thank you.
tikz-pgf animate
add a comment |
I have the following file to generate an animation with a separate file
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endtikzpicture
enddocument
but my problem is that the point (0,0,0) changes place during rotation and I would like to have it in a single place throughout the entire animation. Is there a way to anchor it?
Thank you.
tikz-pgf animate
I have the following file to generate an animation with a separate file
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endtikzpicture
enddocument
but my problem is that the point (0,0,0) changes place during rotation and I would like to have it in a single place throughout the entire animation. Is there a way to anchor it?
Thank you.
tikz-pgf animate
tikz-pgf animate
asked 9 hours ago
Concept7Concept7
1237 bronze badges
1237 bronze badges
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
It is not the point (0,0,0)
that changes but the bounding box. To prevent this from happening, you can set a bounding box yourself, e.g. by saying
path[use as bounding box] (-4,-1.45) rectangle (4,4);
This yields
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
path[use as bounding box] (-4,-1.45) rectangle (4,4);
beginscope
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endscope
endtikzpicture
enddocument
However, I would recommend tikz-3dplot
for that. It allows you to do orthographic projections, and makes it more easy to distinguish hidden from foreground faces. I also use [a routine to determine the minimal bounding box that fits all frames.
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
newcounterx
newcountery
newcounterz
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
xy plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,pgfkeysvalueof/tikz/3d block/y length,0),
xz plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
yz plane/.style=plane=#1(0,pgfkeysvalueof/tikz/3d block/y length,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/3d block/.style=code=
tikzset3d block/.cd,#1
path[get projections];
ifnumzproj=-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumzproj>-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
,
3d block/.cd,
xy face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
xz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
yz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
every face/.style=draw,very thick,
x length/.initial=1,
y length/.initial=1,
z length/.initial=1,
/tikz/retrieve bounding box/.style=insert path=
let p1=(current bounding box.south west),
p2=(current bounding box.north east)
in pgfextra%
pgfmathsetmacroxminmin(x1,xmin)
pgfmathsetmacroxmaxmax(x2,xmax)
pgfmathsetmacroyminmin(y1,ymin)
pgfmathsetmacroymaxmax(y2,ymax)
xdefxminxmin pt
xdefxmaxxmax pt
xdefyminymin pt
xdefymaxymax pt
%typeoutxmin,xmax,ymin,ymax
pgfmathsetmacroxmin0
pgfmathsetmacroxmax0
pgfmathsetmacroymin0
pgfmathsetmacroymax0
begindocument
foreach vari in 0,5,10,15,...,360
tdplotsetmaincoords70vari % the first argument cannot be larger than 90
begintikzpicture[line join=round,tdplot_main_coords,>=stealth]
ifdefinedfigbbrelax
path figbb;
fi
coordinate (A) at (3,-3,-1.5);
coordinate (B) at (3,3,-1.5);
coordinate (C) at (-3,3,-1.5);
coordinate (D) at (-3,-3,-1.5);
coordinate (E) at (3,-3,1.5);
coordinate (F) at (3,3,1.5);
coordinate (G) at (-3,3,1.5);
coordinate (H) at (-3,-3,1.5);
foreach X in A,B,C,D
path (X) node[below]X;
draw[dashed] (3,0,-1.5) -- (0,0,-1.5) -- (0,3,-1.5)
(0,0,-1.5) -- (0,0,1.5);
draw[thick,->] (3,0,-1.5) -- (5,0,-1.5);
draw[thick,->] (0,3,-1.5) -- (0,5,-1.5);
pic3d block=x length=6,y length=6,z length=3;
draw[thick,->] (0,0,1.5) -- (0,0,4);
foreach X in E,F,G,H
path (X) node[above]X;
path[retrieve bounding box];
endtikzpicture
makeatletter
edeffigbb(xmin,ymin) rectangle (xmax,ymax)
immediatewrite@mainauxxdefstringfigbbfigbbrelax
makeatother
enddocument
Do you mean loadtikz-3dplot
instead oftikz
package? Is there a possible significant reduction in code complexity? I haven't looked intotikz-3dplot
package so I don't know the commands available in it.
– Concept7
8 hours ago
2
@Concept7 Thetikz-3dplot
package loadstikz
and allows you to set the view angles and then does an orthographic projection. That is, it will replace ` x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),` by something entirely fixed by the view angles.
– marmot
8 hours ago
1
@Concept7 I added atikz-3dplot
version. True, one needs more preparations, but you can adjust the view more easily and can also more easily distinguish between foreground and background faces.
– marmot
8 hours ago
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%2f499021%2fhow-to-anchor-the-origin-0-0-0-to-the-center-of-multiple-generated-images-in-t%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
It is not the point (0,0,0)
that changes but the bounding box. To prevent this from happening, you can set a bounding box yourself, e.g. by saying
path[use as bounding box] (-4,-1.45) rectangle (4,4);
This yields
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
path[use as bounding box] (-4,-1.45) rectangle (4,4);
beginscope
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endscope
endtikzpicture
enddocument
However, I would recommend tikz-3dplot
for that. It allows you to do orthographic projections, and makes it more easy to distinguish hidden from foreground faces. I also use [a routine to determine the minimal bounding box that fits all frames.
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
newcounterx
newcountery
newcounterz
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
xy plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,pgfkeysvalueof/tikz/3d block/y length,0),
xz plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
yz plane/.style=plane=#1(0,pgfkeysvalueof/tikz/3d block/y length,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/3d block/.style=code=
tikzset3d block/.cd,#1
path[get projections];
ifnumzproj=-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumzproj>-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
,
3d block/.cd,
xy face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
xz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
yz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
every face/.style=draw,very thick,
x length/.initial=1,
y length/.initial=1,
z length/.initial=1,
/tikz/retrieve bounding box/.style=insert path=
let p1=(current bounding box.south west),
p2=(current bounding box.north east)
in pgfextra%
pgfmathsetmacroxminmin(x1,xmin)
pgfmathsetmacroxmaxmax(x2,xmax)
pgfmathsetmacroyminmin(y1,ymin)
pgfmathsetmacroymaxmax(y2,ymax)
xdefxminxmin pt
xdefxmaxxmax pt
xdefyminymin pt
xdefymaxymax pt
%typeoutxmin,xmax,ymin,ymax
pgfmathsetmacroxmin0
pgfmathsetmacroxmax0
pgfmathsetmacroymin0
pgfmathsetmacroymax0
begindocument
foreach vari in 0,5,10,15,...,360
tdplotsetmaincoords70vari % the first argument cannot be larger than 90
begintikzpicture[line join=round,tdplot_main_coords,>=stealth]
ifdefinedfigbbrelax
path figbb;
fi
coordinate (A) at (3,-3,-1.5);
coordinate (B) at (3,3,-1.5);
coordinate (C) at (-3,3,-1.5);
coordinate (D) at (-3,-3,-1.5);
coordinate (E) at (3,-3,1.5);
coordinate (F) at (3,3,1.5);
coordinate (G) at (-3,3,1.5);
coordinate (H) at (-3,-3,1.5);
foreach X in A,B,C,D
path (X) node[below]X;
draw[dashed] (3,0,-1.5) -- (0,0,-1.5) -- (0,3,-1.5)
(0,0,-1.5) -- (0,0,1.5);
draw[thick,->] (3,0,-1.5) -- (5,0,-1.5);
draw[thick,->] (0,3,-1.5) -- (0,5,-1.5);
pic3d block=x length=6,y length=6,z length=3;
draw[thick,->] (0,0,1.5) -- (0,0,4);
foreach X in E,F,G,H
path (X) node[above]X;
path[retrieve bounding box];
endtikzpicture
makeatletter
edeffigbb(xmin,ymin) rectangle (xmax,ymax)
immediatewrite@mainauxxdefstringfigbbfigbbrelax
makeatother
enddocument
Do you mean loadtikz-3dplot
instead oftikz
package? Is there a possible significant reduction in code complexity? I haven't looked intotikz-3dplot
package so I don't know the commands available in it.
– Concept7
8 hours ago
2
@Concept7 Thetikz-3dplot
package loadstikz
and allows you to set the view angles and then does an orthographic projection. That is, it will replace ` x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),` by something entirely fixed by the view angles.
– marmot
8 hours ago
1
@Concept7 I added atikz-3dplot
version. True, one needs more preparations, but you can adjust the view more easily and can also more easily distinguish between foreground and background faces.
– marmot
8 hours ago
add a comment |
It is not the point (0,0,0)
that changes but the bounding box. To prevent this from happening, you can set a bounding box yourself, e.g. by saying
path[use as bounding box] (-4,-1.45) rectangle (4,4);
This yields
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
path[use as bounding box] (-4,-1.45) rectangle (4,4);
beginscope
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endscope
endtikzpicture
enddocument
However, I would recommend tikz-3dplot
for that. It allows you to do orthographic projections, and makes it more easy to distinguish hidden from foreground faces. I also use [a routine to determine the minimal bounding box that fits all frames.
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
newcounterx
newcountery
newcounterz
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
xy plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,pgfkeysvalueof/tikz/3d block/y length,0),
xz plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
yz plane/.style=plane=#1(0,pgfkeysvalueof/tikz/3d block/y length,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/3d block/.style=code=
tikzset3d block/.cd,#1
path[get projections];
ifnumzproj=-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumzproj>-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
,
3d block/.cd,
xy face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
xz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
yz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
every face/.style=draw,very thick,
x length/.initial=1,
y length/.initial=1,
z length/.initial=1,
/tikz/retrieve bounding box/.style=insert path=
let p1=(current bounding box.south west),
p2=(current bounding box.north east)
in pgfextra%
pgfmathsetmacroxminmin(x1,xmin)
pgfmathsetmacroxmaxmax(x2,xmax)
pgfmathsetmacroyminmin(y1,ymin)
pgfmathsetmacroymaxmax(y2,ymax)
xdefxminxmin pt
xdefxmaxxmax pt
xdefyminymin pt
xdefymaxymax pt
%typeoutxmin,xmax,ymin,ymax
pgfmathsetmacroxmin0
pgfmathsetmacroxmax0
pgfmathsetmacroymin0
pgfmathsetmacroymax0
begindocument
foreach vari in 0,5,10,15,...,360
tdplotsetmaincoords70vari % the first argument cannot be larger than 90
begintikzpicture[line join=round,tdplot_main_coords,>=stealth]
ifdefinedfigbbrelax
path figbb;
fi
coordinate (A) at (3,-3,-1.5);
coordinate (B) at (3,3,-1.5);
coordinate (C) at (-3,3,-1.5);
coordinate (D) at (-3,-3,-1.5);
coordinate (E) at (3,-3,1.5);
coordinate (F) at (3,3,1.5);
coordinate (G) at (-3,3,1.5);
coordinate (H) at (-3,-3,1.5);
foreach X in A,B,C,D
path (X) node[below]X;
draw[dashed] (3,0,-1.5) -- (0,0,-1.5) -- (0,3,-1.5)
(0,0,-1.5) -- (0,0,1.5);
draw[thick,->] (3,0,-1.5) -- (5,0,-1.5);
draw[thick,->] (0,3,-1.5) -- (0,5,-1.5);
pic3d block=x length=6,y length=6,z length=3;
draw[thick,->] (0,0,1.5) -- (0,0,4);
foreach X in E,F,G,H
path (X) node[above]X;
path[retrieve bounding box];
endtikzpicture
makeatletter
edeffigbb(xmin,ymin) rectangle (xmax,ymax)
immediatewrite@mainauxxdefstringfigbbfigbbrelax
makeatother
enddocument
Do you mean loadtikz-3dplot
instead oftikz
package? Is there a possible significant reduction in code complexity? I haven't looked intotikz-3dplot
package so I don't know the commands available in it.
– Concept7
8 hours ago
2
@Concept7 Thetikz-3dplot
package loadstikz
and allows you to set the view angles and then does an orthographic projection. That is, it will replace ` x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),` by something entirely fixed by the view angles.
– marmot
8 hours ago
1
@Concept7 I added atikz-3dplot
version. True, one needs more preparations, but you can adjust the view more easily and can also more easily distinguish between foreground and background faces.
– marmot
8 hours ago
add a comment |
It is not the point (0,0,0)
that changes but the bounding box. To prevent this from happening, you can set a bounding box yourself, e.g. by saying
path[use as bounding box] (-4,-1.45) rectangle (4,4);
This yields
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
path[use as bounding box] (-4,-1.45) rectangle (4,4);
beginscope
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endscope
endtikzpicture
enddocument
However, I would recommend tikz-3dplot
for that. It allows you to do orthographic projections, and makes it more easy to distinguish hidden from foreground faces. I also use [a routine to determine the minimal bounding box that fits all frames.
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
newcounterx
newcountery
newcounterz
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
xy plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,pgfkeysvalueof/tikz/3d block/y length,0),
xz plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
yz plane/.style=plane=#1(0,pgfkeysvalueof/tikz/3d block/y length,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/3d block/.style=code=
tikzset3d block/.cd,#1
path[get projections];
ifnumzproj=-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumzproj>-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
,
3d block/.cd,
xy face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
xz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
yz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
every face/.style=draw,very thick,
x length/.initial=1,
y length/.initial=1,
z length/.initial=1,
/tikz/retrieve bounding box/.style=insert path=
let p1=(current bounding box.south west),
p2=(current bounding box.north east)
in pgfextra%
pgfmathsetmacroxminmin(x1,xmin)
pgfmathsetmacroxmaxmax(x2,xmax)
pgfmathsetmacroyminmin(y1,ymin)
pgfmathsetmacroymaxmax(y2,ymax)
xdefxminxmin pt
xdefxmaxxmax pt
xdefyminymin pt
xdefymaxymax pt
%typeoutxmin,xmax,ymin,ymax
pgfmathsetmacroxmin0
pgfmathsetmacroxmax0
pgfmathsetmacroymin0
pgfmathsetmacroymax0
begindocument
foreach vari in 0,5,10,15,...,360
tdplotsetmaincoords70vari % the first argument cannot be larger than 90
begintikzpicture[line join=round,tdplot_main_coords,>=stealth]
ifdefinedfigbbrelax
path figbb;
fi
coordinate (A) at (3,-3,-1.5);
coordinate (B) at (3,3,-1.5);
coordinate (C) at (-3,3,-1.5);
coordinate (D) at (-3,-3,-1.5);
coordinate (E) at (3,-3,1.5);
coordinate (F) at (3,3,1.5);
coordinate (G) at (-3,3,1.5);
coordinate (H) at (-3,-3,1.5);
foreach X in A,B,C,D
path (X) node[below]X;
draw[dashed] (3,0,-1.5) -- (0,0,-1.5) -- (0,3,-1.5)
(0,0,-1.5) -- (0,0,1.5);
draw[thick,->] (3,0,-1.5) -- (5,0,-1.5);
draw[thick,->] (0,3,-1.5) -- (0,5,-1.5);
pic3d block=x length=6,y length=6,z length=3;
draw[thick,->] (0,0,1.5) -- (0,0,4);
foreach X in E,F,G,H
path (X) node[above]X;
path[retrieve bounding box];
endtikzpicture
makeatletter
edeffigbb(xmin,ymin) rectangle (xmax,ymax)
immediatewrite@mainauxxdefstringfigbbfigbbrelax
makeatother
enddocument
It is not the point (0,0,0)
that changes but the bounding box. To prevent this from happening, you can set a bounding box yourself, e.g. by saying
path[use as bounding box] (-4,-1.45) rectangle (4,4);
This yields
documentclass[tikz, border=1cm]standalone
usepackagetkz-euclide
usetkzobjall
begindocument
foreach vari in 0,5,10,15,...,360
begintikzpicture
path[use as bounding box] (-4,-1.45) rectangle (4,4);
beginscope
[
scale=.5,
x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),
rotate around z=vari
]
% coordinates
coordinate (A) at (3,-3,0);
coordinate (B) at (3,3,0);
coordinate (C) at (-3,3,0);
coordinate (D) at (-3,-3,0);
coordinate (E) at (3,-3,3);
coordinate (F) at (3,3,3);
coordinate (G) at (-3,3,3);
coordinate (H) at (-3,-3,3);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](C,D,H,G)
% Axes 3d
draw[->,>=stealth] (3,0,0) -- (5,0,0);
draw[->,>=stealth] (0,3,0) -- (0,5,0);
draw[dashed] (0,0,0) -- (0,0,4);
draw[dashed] (0,0,0) -- (0,3,0);
draw[dashed] (0,0,0) -- (3,0,0);
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,C,D)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](B,C,G,F)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,D,H,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](A,B,F,E)
tkzDrawPolygon[fill=blue!20,opacity=.5,rounded corners=.1pt](G,H,E,F)
tkzDrawSegments[ultra thick](A,B B,C C,G G,H H,E E,F E,A F,B F,G)
tkzLabelPoints[above](E,F,G,H)
tkzLabelPoints[below](A,B,C,D)
draw[->,>=stealth] (0,0,4) -- (0,0,7);
endscope
endtikzpicture
enddocument
However, I would recommend tikz-3dplot
for that. It allows you to do orthographic projections, and makes it more easy to distinguish hidden from foreground faces. I also use [a routine to determine the minimal bounding box that fits all frames.
documentclass[tikz,border=3.14mm]standalone
usepackagetikz-3dplot
newcounterx
newcountery
newcounterz
tikzsetplane/.style n args=3insert path=%
#1 -- ++ #2 -- ++ #3 -- ++ ($-1*#2$) -- cycle,
xy plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,pgfkeysvalueof/tikz/3d block/y length,0),
xz plane/.style=plane=#1(pgfkeysvalueof/tikz/3d block/x length,0,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
yz plane/.style=plane=#1(0,pgfkeysvalueof/tikz/3d block/y length,0)(0,0,pgfkeysvalueof/tikz/3d block/z length),
get projections/.style=insert path=%
let p1=(1,0,0),p2=(0,1,0) in
[/utils/exec=pgfmathtruncatemacroxprojsign(x1)xdefxprojxproj
pgfmathtruncatemacroyprojsign(x2)xdefyprojyproj
pgfmathtruncatemacrozprojsign(cos(tdplotmaintheta))xdefzprojzproj],
pics/3d block/.style=code=
tikzset3d block/.cd,#1
path[get projections];
ifnumzproj=-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumyproj=1
path[3d block/every face,3d block/yz face,yz plane=
(pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/yz face,yz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumxproj=1
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xz face,xz plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
ifnumzproj>-1
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
pgfkeysvalueof/tikz/3d block/z length/2)];
else
path[3d block/every face,3d block/xy face,xy plane=
(-pgfkeysvalueof/tikz/3d block/x length/2,
-pgfkeysvalueof/tikz/3d block/y length/2,
-pgfkeysvalueof/tikz/3d block/z length/2)];
fi
,
3d block/.cd,
xy face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
xz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
yz face/.style=fill=blue!20,opacity=.5,rounded corners=.1pt,
every face/.style=draw,very thick,
x length/.initial=1,
y length/.initial=1,
z length/.initial=1,
/tikz/retrieve bounding box/.style=insert path=
let p1=(current bounding box.south west),
p2=(current bounding box.north east)
in pgfextra%
pgfmathsetmacroxminmin(x1,xmin)
pgfmathsetmacroxmaxmax(x2,xmax)
pgfmathsetmacroyminmin(y1,ymin)
pgfmathsetmacroymaxmax(y2,ymax)
xdefxminxmin pt
xdefxmaxxmax pt
xdefyminymin pt
xdefymaxymax pt
%typeoutxmin,xmax,ymin,ymax
pgfmathsetmacroxmin0
pgfmathsetmacroxmax0
pgfmathsetmacroymin0
pgfmathsetmacroymax0
begindocument
foreach vari in 0,5,10,15,...,360
tdplotsetmaincoords70vari % the first argument cannot be larger than 90
begintikzpicture[line join=round,tdplot_main_coords,>=stealth]
ifdefinedfigbbrelax
path figbb;
fi
coordinate (A) at (3,-3,-1.5);
coordinate (B) at (3,3,-1.5);
coordinate (C) at (-3,3,-1.5);
coordinate (D) at (-3,-3,-1.5);
coordinate (E) at (3,-3,1.5);
coordinate (F) at (3,3,1.5);
coordinate (G) at (-3,3,1.5);
coordinate (H) at (-3,-3,1.5);
foreach X in A,B,C,D
path (X) node[below]X;
draw[dashed] (3,0,-1.5) -- (0,0,-1.5) -- (0,3,-1.5)
(0,0,-1.5) -- (0,0,1.5);
draw[thick,->] (3,0,-1.5) -- (5,0,-1.5);
draw[thick,->] (0,3,-1.5) -- (0,5,-1.5);
pic3d block=x length=6,y length=6,z length=3;
draw[thick,->] (0,0,1.5) -- (0,0,4);
foreach X in E,F,G,H
path (X) node[above]X;
path[retrieve bounding box];
endtikzpicture
makeatletter
edeffigbb(xmin,ymin) rectangle (xmax,ymax)
immediatewrite@mainauxxdefstringfigbbfigbbrelax
makeatother
enddocument
edited 8 hours ago
answered 8 hours ago
marmotmarmot
143k6 gold badges187 silver badges345 bronze badges
143k6 gold badges187 silver badges345 bronze badges
Do you mean loadtikz-3dplot
instead oftikz
package? Is there a possible significant reduction in code complexity? I haven't looked intotikz-3dplot
package so I don't know the commands available in it.
– Concept7
8 hours ago
2
@Concept7 Thetikz-3dplot
package loadstikz
and allows you to set the view angles and then does an orthographic projection. That is, it will replace ` x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),` by something entirely fixed by the view angles.
– marmot
8 hours ago
1
@Concept7 I added atikz-3dplot
version. True, one needs more preparations, but you can adjust the view more easily and can also more easily distinguish between foreground and background faces.
– marmot
8 hours ago
add a comment |
Do you mean loadtikz-3dplot
instead oftikz
package? Is there a possible significant reduction in code complexity? I haven't looked intotikz-3dplot
package so I don't know the commands available in it.
– Concept7
8 hours ago
2
@Concept7 Thetikz-3dplot
package loadstikz
and allows you to set the view angles and then does an orthographic projection. That is, it will replace ` x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),` by something entirely fixed by the view angles.
– marmot
8 hours ago
1
@Concept7 I added atikz-3dplot
version. True, one needs more preparations, but you can adjust the view more easily and can also more easily distinguish between foreground and background faces.
– marmot
8 hours ago
Do you mean load
tikz-3dplot
instead of tikz
package? Is there a possible significant reduction in code complexity? I haven't looked into tikz-3dplot
package so I don't know the commands available in it.– Concept7
8 hours ago
Do you mean load
tikz-3dplot
instead of tikz
package? Is there a possible significant reduction in code complexity? I haven't looked into tikz-3dplot
package so I don't know the commands available in it.– Concept7
8 hours ago
2
2
@Concept7 The
tikz-3dplot
package loads tikz
and allows you to set the view angles and then does an orthographic projection. That is, it will replace ` x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),` by something entirely fixed by the view angles.– marmot
8 hours ago
@Concept7 The
tikz-3dplot
package loads tikz
and allows you to set the view angles and then does an orthographic projection. That is, it will replace ` x=(-1cm,-.25cm),y=(1cm,-.25cm),z=(0cm,1cm),` by something entirely fixed by the view angles.– marmot
8 hours ago
1
1
@Concept7 I added a
tikz-3dplot
version. True, one needs more preparations, but you can adjust the view more easily and can also more easily distinguish between foreground and background faces.– marmot
8 hours ago
@Concept7 I added a
tikz-3dplot
version. True, one needs more preparations, but you can adjust the view more easily and can also more easily distinguish between foreground and background faces.– marmot
8 hours ago
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%2f499021%2fhow-to-anchor-the-origin-0-0-0-to-the-center-of-multiple-generated-images-in-t%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