3D buried view in TikzAligning a text in 3d diagramTikZ: Cropping the Bounding BoxChanging view angle...
What happens if both players misunderstand the game state until it's too late?
How do I handle a blinded enemy which wants to attack someone it's sure is there?
Exploding Numbers
Sets which are both Sum-free and Product-free.
Badly designed reimbursement form. What does that say about the company?
Buying a "Used" Router
How can guns be countered by melee combat without raw-ability or exceptional explanations?
What if you do not believe in the project benefits?
bash aliases do not expand even with shopt expand_aliases
How do I add a strong "onion flavor" to the biryani (in restaurant style)?
Why do we interpret the accelerated expansion of the universe as the proof for the existence of dark energy?
Identical projects by students at two different colleges: still plagiarism?
A cancellation property for permutations?
What does @ mean in a hostname in DNS configuration?
How can changes in personality/values of a person who turned into a vampire be explained?
How can I make my enemies feel real and make combat more engaging?
What does an unprocessed RAW file look like?
Why would you use 2 alternate layout buttons instead of 1, when only one can be selected at once
Why are "square law" devices important?
Is there any danger of my neighbor having my wife's signature?
Why is quixotic not Quixotic (a proper adjective)?
Why write a book when there's a movie in my head?
Found a major flaw in paper from home university – to which I would like to return
What's the function of the word "ли" in the following contexts?
3D buried view in Tikz
Aligning a text in 3d diagramTikZ: Cropping the Bounding BoxChanging view angle distorts sphere with pgfplotsNumerical conditional within tikz keys?Setting camera view within SketchTikz 3d trimetric view coordinate calculation bugChanging the view angle distort 3D tube imageLine up nested tikz enviroments or how to get rid of themBlockdiagramm “Zoom”/“Detail-View” in Tikz/PGFHow is a PGF shading applied?Rotate 3D plot to top down view
I want to achieve 3D effect in my picture. This is to show Electron beam lithography followed by lift-off process. I want to make a cross shaped hole in the top layer and fill it with a gray color material till half. How to achieve this with opacity and shading?
Thanks
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
end{scope}
end{tikzpicture}
end{frame}
end{document}
tikz-pgf 3d
add a comment |
I want to achieve 3D effect in my picture. This is to show Electron beam lithography followed by lift-off process. I want to make a cross shaped hole in the top layer and fill it with a gray color material till half. How to achieve this with opacity and shading?
Thanks
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
end{scope}
end{tikzpicture}
end{frame}
end{document}
tikz-pgf 3d
You only want to change the last frame, right?
– marmot
4 hours ago
add a comment |
I want to achieve 3D effect in my picture. This is to show Electron beam lithography followed by lift-off process. I want to make a cross shaped hole in the top layer and fill it with a gray color material till half. How to achieve this with opacity and shading?
Thanks
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
end{scope}
end{tikzpicture}
end{frame}
end{document}
tikz-pgf 3d
I want to achieve 3D effect in my picture. This is to show Electron beam lithography followed by lift-off process. I want to make a cross shaped hole in the top layer and fill it with a gray color material till half. How to achieve this with opacity and shading?
Thanks
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
end{scope}
end{tikzpicture}
end{frame}
end{document}
tikz-pgf 3d
tikz-pgf 3d
asked 4 hours ago
user3227125user3227125
354
354
You only want to change the last frame, right?
– marmot
4 hours ago
add a comment |
You only want to change the last frame, right?
– marmot
4 hours ago
You only want to change the last frame, right?
– marmot
4 hours ago
You only want to change the last frame, right?
– marmot
4 hours ago
add a comment |
1 Answer
1
active
oldest
votes
You could do something like this:
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
% filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
%
%
% filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
% filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
% filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
% filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
clip[scale = 0.08,postaction={fill=blue!40!black}]
(11,16-2) -- (14,16-2) -- (13.9,17-2)
-- (15.5,17-2) --(15.2,18.25-2)
--(13.7,18.25-2)--(13.6,19-2)--
(11.4,19-2)--(11.3,18.25-2)--(9.8,18.25-2)
--(9.5,17-2)--(11.1,17-2)--cycle;
fill[blue,scale = 0.08] (9.8,18.25-3) --(9.8,18.25-2)
--(9.5,17-2) --(9.5,17-3);
filldraw[blue!60!white,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(9.8,18.25-3) --(9.8,18.25-2);
fill[blue,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(11.4,19-3) --(11.4,19-2);
filldraw[blue!60!white,scale = 0.08] (11.4,19-2) --(13.6,19-2) --(13.6,19-3) -- (11.4,19-3);
fill[blue!60!green!70,scale = 0.08]
(13.6,19-2) --(13.7,18.25-2) --(13.7,18.25-3) --(13.6,19-3);
filldraw[blue!60!white,scale = 0.08]
(13.7,18.25-2) --(15.2,18.25-2) --(15.2,18.25-3)
--(13.7,18.25-3);
fill[blue!60!green!70,scale = 0.08]
(15.2,18.25-2) --(15.2,18.25-3)--(15.5,17-3)--(15.5,17-2);
end{scope}
end{tikzpicture}
end{frame}
end{document}
However, I would really like to draw your attention to this great answer, which allows you to draw things in 3d perspective. If I was you, I would redraw your diagram with these tools.
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
usepackage{tikz-3dplot}
usetikzlibrary{overlay-beamer-styles}
usepgfmodule{nonlineartransformations}
% Max magic
makeatletter
% the first part is not in use here
deftikz@scan@transform@one@point#1{%
tikz@scan@one@pointpgf@process#1%
pgf@pos@transform{pgf@x}{pgf@y}}
tikzset{%
grid source opposite corners/.code args={#1and#2}{%
pgfextract@processtikz@transform@source@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@source@northeast{%
tikz@scan@transform@one@point{#2}}%
},
grid target corners/.code args={#1--#2--#3--#4}{%
pgfextract@processtikz@transform@target@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@target@southeast{%
tikz@scan@transform@one@point{#2}}%
pgfextract@processtikz@transform@target@northeast{%
tikz@scan@transform@one@point{#3}}%
pgfextract@processtikz@transform@target@northwest{%
tikz@scan@transform@one@point{#4}}%
}
}
deftikzgridtransform{%
pgfextract@processtikz@current@point{}%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}%
{tikz@transform@source@northeast}%
}%
pgf@xc=pgf@xpgf@yc=pgf@y%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}{tikz@current@point}%
}%
pgfmathparse{pgf@x/pgf@xc}lettikz@tx=pgfmathresult%
pgfmathparse{pgf@y/pgf@yc}lettikz@ty=pgfmathresult%
%
pgfpointlineattime{tikz@ty}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@southwest}%
{tikz@transform@target@southeast}}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@northwest}%
{tikz@transform@target@northeast}}%
}
% Initialize H matrix for perspective view
pgfmathsetmacroH@tpp@aa{1}pgfmathsetmacroH@tpp@ab{0}pgfmathsetmacroH@tpp@ac{0}%pgfmathsetmacroH@tpp@ad{0}
pgfmathsetmacroH@tpp@ba{0}pgfmathsetmacroH@tpp@bb{1}pgfmathsetmacroH@tpp@bc{0}%pgfmathsetmacroH@tpp@bd{0}
pgfmathsetmacroH@tpp@ca{0}pgfmathsetmacroH@tpp@cb{0}pgfmathsetmacroH@tpp@cc{1}%pgfmathsetmacroH@tpp@cd{0}
pgfmathsetmacroH@tpp@da{0}pgfmathsetmacroH@tpp@db{0}pgfmathsetmacroH@tpp@dc{0}%pgfmathsetmacroH@tpp@dd{1}
%Initialize H matrix for main rotation
pgfmathsetmacroH@rot@aa{1}pgfmathsetmacroH@rot@ab{0}pgfmathsetmacroH@rot@ac{0}%pgfmathsetmacroH@rot@ad{0}
pgfmathsetmacroH@rot@ba{0}pgfmathsetmacroH@rot@bb{1}pgfmathsetmacroH@rot@bc{0}%pgfmathsetmacroH@rot@bd{0}
pgfmathsetmacroH@rot@ca{0}pgfmathsetmacroH@rot@cb{0}pgfmathsetmacroH@rot@cc{1}%pgfmathsetmacroH@rot@cd{0}
%pgfmathsetmacroH@rot@da{0}pgfmathsetmacroH@rot@db{0}pgfmathsetmacroH@rot@dc{0}pgfmathsetmacroH@rot@dd{1}
pgfkeys{
/three point perspective/.cd,
p/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#1))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ba{#2/#1}
pgfmathsetmacroH@tpp@ca{#3/#1}
pgfmathsetmacroH@tpp@da{ 1/#1}
coordinate (vp-p) at (#1,#2,#3);
fi
},
q/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#2))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ab{#1/#2}
pgfmathsetmacroH@tpp@cb{#3/#2}
pgfmathsetmacroH@tpp@db{ 1/#2}
coordinate (vp-q) at (#1,#2,#3);
fi
},
r/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#3))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ac{#1/#3}
pgfmathsetmacroH@tpp@bc{#2/#3}
pgfmathsetmacroH@tpp@dc{ 1/#3}
coordinate (vp-r) at (#1,#2,#3);
fi
},
coordinate/.code args={#1,#2,#3}{
pgfmathsetmacrotpp@x{#1} %<- Max' fix
pgfmathsetmacrotpp@y{#2}
pgfmathsetmacrotpp@z{#3}
},
}
tikzset{
view/.code 2 args={
pgfmathsetmacrorot@main@theta{#1}
pgfmathsetmacrorot@main@phi{#2}
% Row 1
pgfmathsetmacroH@rot@aa{cos(rot@main@phi)}
pgfmathsetmacroH@rot@ab{sin(rot@main@phi)}
pgfmathsetmacroH@rot@ac{0}
% Row 2
pgfmathsetmacroH@rot@ba{-cos(rot@main@theta)*sin(rot@main@phi)}
pgfmathsetmacroH@rot@bb{cos(rot@main@phi)*cos(rot@main@theta)}
pgfmathsetmacroH@rot@bc{sin(rot@main@theta)}
% Row 3
pgfmathsetmacroH@m@ca{sin(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cb{-cos(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cc{cos(rot@main@theta)}
% Set vector values
pgfmathsetmacrovec@x@x{H@rot@aa}
pgfmathsetmacrovec@y@x{H@rot@ab}
pgfmathsetmacrovec@z@x{H@rot@ac}
pgfmathsetmacrovec@x@y{H@rot@ba}
pgfmathsetmacrovec@y@y{H@rot@bb}
pgfmathsetmacrovec@z@y{H@rot@bc}
% Set pgf vectors
pgfsetxvec{pgfpoint{vec@x@x cm}{vec@x@y cm}}
pgfsetyvec{pgfpoint{vec@y@x cm}{vec@y@y cm}}
pgfsetzvec{pgfpoint{vec@z@x cm}{vec@z@y cm}}
},
}
tikzset{
perspective/.code={pgfkeys{/three point perspective/.cd,#1}},
perspective/.default={p={(15,0,0)},q={(0,15,0)},r={(0,0,50)}},
}
tikzdeclarecoordinatesystem{three point perspective}{
pgfkeys{/three point perspective/.cd,coordinate={#1}}
pgfmathsetmacrotemp@p@w{H@tpp@da*tpp@x + H@tpp@db*tpp@y + H@tpp@dc*tpp@z + 1}
pgfmathsetmacrotemp@p@x{(H@tpp@aa*tpp@x + H@tpp@ab*tpp@y + H@tpp@ac*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@y{(H@tpp@ba*tpp@x + H@tpp@bb*tpp@y + H@tpp@bc*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@z{(H@tpp@ca*tpp@x + H@tpp@cb*tpp@y + H@tpp@cc*tpp@z)/temp@p@w}
pgfpointxyz{temp@p@x}{temp@p@y}{temp@p@z}
}
tikzaliascoordinatesystem{tpp}{three point perspective}
makeatother
tikzset{set mark/.style args={#1|#2}{
postaction={decorate,decoration={markings,
mark=at position #1 with {coordinate(#2);}}}}}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{shapes,fadings}
begin{document}
foreach X in {0,0.08,...,0.8,0.72,0.64,...,0}
{begin{frame}[t]
frametitle{Fabrication of Metasurface}
tdplotsetmaincoords{77}{0}
pgfmathsetmacro{vq}{5}
begin{tikzpicture}[scale=pi,%tdplot_main_coords
view={tdplotmaintheta}{tdplotmainphi},
perspective={
p = {(0,0,10)},
q = {(0,vq,1.25)},
}
]
path[tdplot_screen_coords] (-1.5,0.1) rectangle (1.5,2.7);
filldraw[blue!40!black]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:0.9,-0.9,0.8) -- (tpp cs:-0.9,-0.9,0.8) -- cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1) -- (tpp cs:1,1,1) -- (tpp cs:-1,1,1)
-- cycle;
%onslide<2->
begin{scope}
filldraw[blue!60!green,opacity = 0.6]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:1,-1,1.1) -- (tpp cs:-1,-1,1.1) -- cycle;
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6]
(tpp cs:-1,-1,1.1) -- (tpp cs:1,-1,1.1) -- (tpp cs:1,1,1.1) -- (tpp cs:-1,1,1.1)
-- cycle;
end{scope}
%onslide<3->
begin{scope}[tdplot_screen_coords,shift={(-0.75,1.5)},scale=0.3]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
%onslide<4->
begin{scope}
defmyx{X}
clip[postaction={fill=blue!40!black}] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.6,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1)
-- cycle;
fill[blue!50] (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- cycle; % 1
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1)
-- (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- cycle; % 2
fill[blue!50!black] (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- cycle; % 2
fill[blue!50] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 3
fill[blue!50] (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- cycle; % 3
fill[blue!60!green!70] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1) -- (tpp cs:myx-0.1,-0.6,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 4
fill[blue!50!black] (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- (tpp cs:myx-0.7,-0.6,1) -- (tpp cs:myx-0.7,-0.6,1.1)
-- cycle; % 4
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.8,1.1) -- (tpp cs:myx-0.3,-0.8,1)
-- (tpp cs:myx-0.3,-0.6,1) -- (tpp cs:myx-0.3,-0.6,1.1)
-- cycle; % 5
fill[blue!50!black] (tpp cs:myx-0.5,-0.6,1.1) -- (tpp cs:myx-0.5,-0.6,1)
-- (tpp cs:myx-0.5,-0.8,1) -- (tpp cs:myx-0.5,-0.8,1.1)
-- cycle; % 5
end{scope}
end{tikzpicture}
end{frame}}
end{document}
This is to illustrate the advantage of Max' great code: you draw in 3d, and TikZ will compute the perspective projection for you.
This is a great answer!
– Claudio Fiandrino
2 hours ago
@ClaudioFiandrino Thanks! But all credits go to tex.stackexchange.com/a/447120/121799.
– marmot
2 hours ago
@marmot Thank you very much.
– user3227125
2 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%2f476110%2f3d-buried-view-in-tikz%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
You could do something like this:
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
% filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
%
%
% filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
% filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
% filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
% filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
clip[scale = 0.08,postaction={fill=blue!40!black}]
(11,16-2) -- (14,16-2) -- (13.9,17-2)
-- (15.5,17-2) --(15.2,18.25-2)
--(13.7,18.25-2)--(13.6,19-2)--
(11.4,19-2)--(11.3,18.25-2)--(9.8,18.25-2)
--(9.5,17-2)--(11.1,17-2)--cycle;
fill[blue,scale = 0.08] (9.8,18.25-3) --(9.8,18.25-2)
--(9.5,17-2) --(9.5,17-3);
filldraw[blue!60!white,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(9.8,18.25-3) --(9.8,18.25-2);
fill[blue,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(11.4,19-3) --(11.4,19-2);
filldraw[blue!60!white,scale = 0.08] (11.4,19-2) --(13.6,19-2) --(13.6,19-3) -- (11.4,19-3);
fill[blue!60!green!70,scale = 0.08]
(13.6,19-2) --(13.7,18.25-2) --(13.7,18.25-3) --(13.6,19-3);
filldraw[blue!60!white,scale = 0.08]
(13.7,18.25-2) --(15.2,18.25-2) --(15.2,18.25-3)
--(13.7,18.25-3);
fill[blue!60!green!70,scale = 0.08]
(15.2,18.25-2) --(15.2,18.25-3)--(15.5,17-3)--(15.5,17-2);
end{scope}
end{tikzpicture}
end{frame}
end{document}
However, I would really like to draw your attention to this great answer, which allows you to draw things in 3d perspective. If I was you, I would redraw your diagram with these tools.
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
usepackage{tikz-3dplot}
usetikzlibrary{overlay-beamer-styles}
usepgfmodule{nonlineartransformations}
% Max magic
makeatletter
% the first part is not in use here
deftikz@scan@transform@one@point#1{%
tikz@scan@one@pointpgf@process#1%
pgf@pos@transform{pgf@x}{pgf@y}}
tikzset{%
grid source opposite corners/.code args={#1and#2}{%
pgfextract@processtikz@transform@source@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@source@northeast{%
tikz@scan@transform@one@point{#2}}%
},
grid target corners/.code args={#1--#2--#3--#4}{%
pgfextract@processtikz@transform@target@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@target@southeast{%
tikz@scan@transform@one@point{#2}}%
pgfextract@processtikz@transform@target@northeast{%
tikz@scan@transform@one@point{#3}}%
pgfextract@processtikz@transform@target@northwest{%
tikz@scan@transform@one@point{#4}}%
}
}
deftikzgridtransform{%
pgfextract@processtikz@current@point{}%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}%
{tikz@transform@source@northeast}%
}%
pgf@xc=pgf@xpgf@yc=pgf@y%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}{tikz@current@point}%
}%
pgfmathparse{pgf@x/pgf@xc}lettikz@tx=pgfmathresult%
pgfmathparse{pgf@y/pgf@yc}lettikz@ty=pgfmathresult%
%
pgfpointlineattime{tikz@ty}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@southwest}%
{tikz@transform@target@southeast}}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@northwest}%
{tikz@transform@target@northeast}}%
}
% Initialize H matrix for perspective view
pgfmathsetmacroH@tpp@aa{1}pgfmathsetmacroH@tpp@ab{0}pgfmathsetmacroH@tpp@ac{0}%pgfmathsetmacroH@tpp@ad{0}
pgfmathsetmacroH@tpp@ba{0}pgfmathsetmacroH@tpp@bb{1}pgfmathsetmacroH@tpp@bc{0}%pgfmathsetmacroH@tpp@bd{0}
pgfmathsetmacroH@tpp@ca{0}pgfmathsetmacroH@tpp@cb{0}pgfmathsetmacroH@tpp@cc{1}%pgfmathsetmacroH@tpp@cd{0}
pgfmathsetmacroH@tpp@da{0}pgfmathsetmacroH@tpp@db{0}pgfmathsetmacroH@tpp@dc{0}%pgfmathsetmacroH@tpp@dd{1}
%Initialize H matrix for main rotation
pgfmathsetmacroH@rot@aa{1}pgfmathsetmacroH@rot@ab{0}pgfmathsetmacroH@rot@ac{0}%pgfmathsetmacroH@rot@ad{0}
pgfmathsetmacroH@rot@ba{0}pgfmathsetmacroH@rot@bb{1}pgfmathsetmacroH@rot@bc{0}%pgfmathsetmacroH@rot@bd{0}
pgfmathsetmacroH@rot@ca{0}pgfmathsetmacroH@rot@cb{0}pgfmathsetmacroH@rot@cc{1}%pgfmathsetmacroH@rot@cd{0}
%pgfmathsetmacroH@rot@da{0}pgfmathsetmacroH@rot@db{0}pgfmathsetmacroH@rot@dc{0}pgfmathsetmacroH@rot@dd{1}
pgfkeys{
/three point perspective/.cd,
p/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#1))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ba{#2/#1}
pgfmathsetmacroH@tpp@ca{#3/#1}
pgfmathsetmacroH@tpp@da{ 1/#1}
coordinate (vp-p) at (#1,#2,#3);
fi
},
q/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#2))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ab{#1/#2}
pgfmathsetmacroH@tpp@cb{#3/#2}
pgfmathsetmacroH@tpp@db{ 1/#2}
coordinate (vp-q) at (#1,#2,#3);
fi
},
r/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#3))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ac{#1/#3}
pgfmathsetmacroH@tpp@bc{#2/#3}
pgfmathsetmacroH@tpp@dc{ 1/#3}
coordinate (vp-r) at (#1,#2,#3);
fi
},
coordinate/.code args={#1,#2,#3}{
pgfmathsetmacrotpp@x{#1} %<- Max' fix
pgfmathsetmacrotpp@y{#2}
pgfmathsetmacrotpp@z{#3}
},
}
tikzset{
view/.code 2 args={
pgfmathsetmacrorot@main@theta{#1}
pgfmathsetmacrorot@main@phi{#2}
% Row 1
pgfmathsetmacroH@rot@aa{cos(rot@main@phi)}
pgfmathsetmacroH@rot@ab{sin(rot@main@phi)}
pgfmathsetmacroH@rot@ac{0}
% Row 2
pgfmathsetmacroH@rot@ba{-cos(rot@main@theta)*sin(rot@main@phi)}
pgfmathsetmacroH@rot@bb{cos(rot@main@phi)*cos(rot@main@theta)}
pgfmathsetmacroH@rot@bc{sin(rot@main@theta)}
% Row 3
pgfmathsetmacroH@m@ca{sin(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cb{-cos(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cc{cos(rot@main@theta)}
% Set vector values
pgfmathsetmacrovec@x@x{H@rot@aa}
pgfmathsetmacrovec@y@x{H@rot@ab}
pgfmathsetmacrovec@z@x{H@rot@ac}
pgfmathsetmacrovec@x@y{H@rot@ba}
pgfmathsetmacrovec@y@y{H@rot@bb}
pgfmathsetmacrovec@z@y{H@rot@bc}
% Set pgf vectors
pgfsetxvec{pgfpoint{vec@x@x cm}{vec@x@y cm}}
pgfsetyvec{pgfpoint{vec@y@x cm}{vec@y@y cm}}
pgfsetzvec{pgfpoint{vec@z@x cm}{vec@z@y cm}}
},
}
tikzset{
perspective/.code={pgfkeys{/three point perspective/.cd,#1}},
perspective/.default={p={(15,0,0)},q={(0,15,0)},r={(0,0,50)}},
}
tikzdeclarecoordinatesystem{three point perspective}{
pgfkeys{/three point perspective/.cd,coordinate={#1}}
pgfmathsetmacrotemp@p@w{H@tpp@da*tpp@x + H@tpp@db*tpp@y + H@tpp@dc*tpp@z + 1}
pgfmathsetmacrotemp@p@x{(H@tpp@aa*tpp@x + H@tpp@ab*tpp@y + H@tpp@ac*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@y{(H@tpp@ba*tpp@x + H@tpp@bb*tpp@y + H@tpp@bc*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@z{(H@tpp@ca*tpp@x + H@tpp@cb*tpp@y + H@tpp@cc*tpp@z)/temp@p@w}
pgfpointxyz{temp@p@x}{temp@p@y}{temp@p@z}
}
tikzaliascoordinatesystem{tpp}{three point perspective}
makeatother
tikzset{set mark/.style args={#1|#2}{
postaction={decorate,decoration={markings,
mark=at position #1 with {coordinate(#2);}}}}}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{shapes,fadings}
begin{document}
foreach X in {0,0.08,...,0.8,0.72,0.64,...,0}
{begin{frame}[t]
frametitle{Fabrication of Metasurface}
tdplotsetmaincoords{77}{0}
pgfmathsetmacro{vq}{5}
begin{tikzpicture}[scale=pi,%tdplot_main_coords
view={tdplotmaintheta}{tdplotmainphi},
perspective={
p = {(0,0,10)},
q = {(0,vq,1.25)},
}
]
path[tdplot_screen_coords] (-1.5,0.1) rectangle (1.5,2.7);
filldraw[blue!40!black]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:0.9,-0.9,0.8) -- (tpp cs:-0.9,-0.9,0.8) -- cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1) -- (tpp cs:1,1,1) -- (tpp cs:-1,1,1)
-- cycle;
%onslide<2->
begin{scope}
filldraw[blue!60!green,opacity = 0.6]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:1,-1,1.1) -- (tpp cs:-1,-1,1.1) -- cycle;
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6]
(tpp cs:-1,-1,1.1) -- (tpp cs:1,-1,1.1) -- (tpp cs:1,1,1.1) -- (tpp cs:-1,1,1.1)
-- cycle;
end{scope}
%onslide<3->
begin{scope}[tdplot_screen_coords,shift={(-0.75,1.5)},scale=0.3]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
%onslide<4->
begin{scope}
defmyx{X}
clip[postaction={fill=blue!40!black}] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.6,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1)
-- cycle;
fill[blue!50] (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- cycle; % 1
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1)
-- (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- cycle; % 2
fill[blue!50!black] (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- cycle; % 2
fill[blue!50] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 3
fill[blue!50] (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- cycle; % 3
fill[blue!60!green!70] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1) -- (tpp cs:myx-0.1,-0.6,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 4
fill[blue!50!black] (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- (tpp cs:myx-0.7,-0.6,1) -- (tpp cs:myx-0.7,-0.6,1.1)
-- cycle; % 4
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.8,1.1) -- (tpp cs:myx-0.3,-0.8,1)
-- (tpp cs:myx-0.3,-0.6,1) -- (tpp cs:myx-0.3,-0.6,1.1)
-- cycle; % 5
fill[blue!50!black] (tpp cs:myx-0.5,-0.6,1.1) -- (tpp cs:myx-0.5,-0.6,1)
-- (tpp cs:myx-0.5,-0.8,1) -- (tpp cs:myx-0.5,-0.8,1.1)
-- cycle; % 5
end{scope}
end{tikzpicture}
end{frame}}
end{document}
This is to illustrate the advantage of Max' great code: you draw in 3d, and TikZ will compute the perspective projection for you.
This is a great answer!
– Claudio Fiandrino
2 hours ago
@ClaudioFiandrino Thanks! But all credits go to tex.stackexchange.com/a/447120/121799.
– marmot
2 hours ago
@marmot Thank you very much.
– user3227125
2 hours ago
add a comment |
You could do something like this:
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
% filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
%
%
% filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
% filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
% filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
% filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
clip[scale = 0.08,postaction={fill=blue!40!black}]
(11,16-2) -- (14,16-2) -- (13.9,17-2)
-- (15.5,17-2) --(15.2,18.25-2)
--(13.7,18.25-2)--(13.6,19-2)--
(11.4,19-2)--(11.3,18.25-2)--(9.8,18.25-2)
--(9.5,17-2)--(11.1,17-2)--cycle;
fill[blue,scale = 0.08] (9.8,18.25-3) --(9.8,18.25-2)
--(9.5,17-2) --(9.5,17-3);
filldraw[blue!60!white,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(9.8,18.25-3) --(9.8,18.25-2);
fill[blue,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(11.4,19-3) --(11.4,19-2);
filldraw[blue!60!white,scale = 0.08] (11.4,19-2) --(13.6,19-2) --(13.6,19-3) -- (11.4,19-3);
fill[blue!60!green!70,scale = 0.08]
(13.6,19-2) --(13.7,18.25-2) --(13.7,18.25-3) --(13.6,19-3);
filldraw[blue!60!white,scale = 0.08]
(13.7,18.25-2) --(15.2,18.25-2) --(15.2,18.25-3)
--(13.7,18.25-3);
fill[blue!60!green!70,scale = 0.08]
(15.2,18.25-2) --(15.2,18.25-3)--(15.5,17-3)--(15.5,17-2);
end{scope}
end{tikzpicture}
end{frame}
end{document}
However, I would really like to draw your attention to this great answer, which allows you to draw things in 3d perspective. If I was you, I would redraw your diagram with these tools.
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
usepackage{tikz-3dplot}
usetikzlibrary{overlay-beamer-styles}
usepgfmodule{nonlineartransformations}
% Max magic
makeatletter
% the first part is not in use here
deftikz@scan@transform@one@point#1{%
tikz@scan@one@pointpgf@process#1%
pgf@pos@transform{pgf@x}{pgf@y}}
tikzset{%
grid source opposite corners/.code args={#1and#2}{%
pgfextract@processtikz@transform@source@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@source@northeast{%
tikz@scan@transform@one@point{#2}}%
},
grid target corners/.code args={#1--#2--#3--#4}{%
pgfextract@processtikz@transform@target@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@target@southeast{%
tikz@scan@transform@one@point{#2}}%
pgfextract@processtikz@transform@target@northeast{%
tikz@scan@transform@one@point{#3}}%
pgfextract@processtikz@transform@target@northwest{%
tikz@scan@transform@one@point{#4}}%
}
}
deftikzgridtransform{%
pgfextract@processtikz@current@point{}%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}%
{tikz@transform@source@northeast}%
}%
pgf@xc=pgf@xpgf@yc=pgf@y%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}{tikz@current@point}%
}%
pgfmathparse{pgf@x/pgf@xc}lettikz@tx=pgfmathresult%
pgfmathparse{pgf@y/pgf@yc}lettikz@ty=pgfmathresult%
%
pgfpointlineattime{tikz@ty}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@southwest}%
{tikz@transform@target@southeast}}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@northwest}%
{tikz@transform@target@northeast}}%
}
% Initialize H matrix for perspective view
pgfmathsetmacroH@tpp@aa{1}pgfmathsetmacroH@tpp@ab{0}pgfmathsetmacroH@tpp@ac{0}%pgfmathsetmacroH@tpp@ad{0}
pgfmathsetmacroH@tpp@ba{0}pgfmathsetmacroH@tpp@bb{1}pgfmathsetmacroH@tpp@bc{0}%pgfmathsetmacroH@tpp@bd{0}
pgfmathsetmacroH@tpp@ca{0}pgfmathsetmacroH@tpp@cb{0}pgfmathsetmacroH@tpp@cc{1}%pgfmathsetmacroH@tpp@cd{0}
pgfmathsetmacroH@tpp@da{0}pgfmathsetmacroH@tpp@db{0}pgfmathsetmacroH@tpp@dc{0}%pgfmathsetmacroH@tpp@dd{1}
%Initialize H matrix for main rotation
pgfmathsetmacroH@rot@aa{1}pgfmathsetmacroH@rot@ab{0}pgfmathsetmacroH@rot@ac{0}%pgfmathsetmacroH@rot@ad{0}
pgfmathsetmacroH@rot@ba{0}pgfmathsetmacroH@rot@bb{1}pgfmathsetmacroH@rot@bc{0}%pgfmathsetmacroH@rot@bd{0}
pgfmathsetmacroH@rot@ca{0}pgfmathsetmacroH@rot@cb{0}pgfmathsetmacroH@rot@cc{1}%pgfmathsetmacroH@rot@cd{0}
%pgfmathsetmacroH@rot@da{0}pgfmathsetmacroH@rot@db{0}pgfmathsetmacroH@rot@dc{0}pgfmathsetmacroH@rot@dd{1}
pgfkeys{
/three point perspective/.cd,
p/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#1))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ba{#2/#1}
pgfmathsetmacroH@tpp@ca{#3/#1}
pgfmathsetmacroH@tpp@da{ 1/#1}
coordinate (vp-p) at (#1,#2,#3);
fi
},
q/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#2))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ab{#1/#2}
pgfmathsetmacroH@tpp@cb{#3/#2}
pgfmathsetmacroH@tpp@db{ 1/#2}
coordinate (vp-q) at (#1,#2,#3);
fi
},
r/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#3))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ac{#1/#3}
pgfmathsetmacroH@tpp@bc{#2/#3}
pgfmathsetmacroH@tpp@dc{ 1/#3}
coordinate (vp-r) at (#1,#2,#3);
fi
},
coordinate/.code args={#1,#2,#3}{
pgfmathsetmacrotpp@x{#1} %<- Max' fix
pgfmathsetmacrotpp@y{#2}
pgfmathsetmacrotpp@z{#3}
},
}
tikzset{
view/.code 2 args={
pgfmathsetmacrorot@main@theta{#1}
pgfmathsetmacrorot@main@phi{#2}
% Row 1
pgfmathsetmacroH@rot@aa{cos(rot@main@phi)}
pgfmathsetmacroH@rot@ab{sin(rot@main@phi)}
pgfmathsetmacroH@rot@ac{0}
% Row 2
pgfmathsetmacroH@rot@ba{-cos(rot@main@theta)*sin(rot@main@phi)}
pgfmathsetmacroH@rot@bb{cos(rot@main@phi)*cos(rot@main@theta)}
pgfmathsetmacroH@rot@bc{sin(rot@main@theta)}
% Row 3
pgfmathsetmacroH@m@ca{sin(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cb{-cos(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cc{cos(rot@main@theta)}
% Set vector values
pgfmathsetmacrovec@x@x{H@rot@aa}
pgfmathsetmacrovec@y@x{H@rot@ab}
pgfmathsetmacrovec@z@x{H@rot@ac}
pgfmathsetmacrovec@x@y{H@rot@ba}
pgfmathsetmacrovec@y@y{H@rot@bb}
pgfmathsetmacrovec@z@y{H@rot@bc}
% Set pgf vectors
pgfsetxvec{pgfpoint{vec@x@x cm}{vec@x@y cm}}
pgfsetyvec{pgfpoint{vec@y@x cm}{vec@y@y cm}}
pgfsetzvec{pgfpoint{vec@z@x cm}{vec@z@y cm}}
},
}
tikzset{
perspective/.code={pgfkeys{/three point perspective/.cd,#1}},
perspective/.default={p={(15,0,0)},q={(0,15,0)},r={(0,0,50)}},
}
tikzdeclarecoordinatesystem{three point perspective}{
pgfkeys{/three point perspective/.cd,coordinate={#1}}
pgfmathsetmacrotemp@p@w{H@tpp@da*tpp@x + H@tpp@db*tpp@y + H@tpp@dc*tpp@z + 1}
pgfmathsetmacrotemp@p@x{(H@tpp@aa*tpp@x + H@tpp@ab*tpp@y + H@tpp@ac*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@y{(H@tpp@ba*tpp@x + H@tpp@bb*tpp@y + H@tpp@bc*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@z{(H@tpp@ca*tpp@x + H@tpp@cb*tpp@y + H@tpp@cc*tpp@z)/temp@p@w}
pgfpointxyz{temp@p@x}{temp@p@y}{temp@p@z}
}
tikzaliascoordinatesystem{tpp}{three point perspective}
makeatother
tikzset{set mark/.style args={#1|#2}{
postaction={decorate,decoration={markings,
mark=at position #1 with {coordinate(#2);}}}}}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{shapes,fadings}
begin{document}
foreach X in {0,0.08,...,0.8,0.72,0.64,...,0}
{begin{frame}[t]
frametitle{Fabrication of Metasurface}
tdplotsetmaincoords{77}{0}
pgfmathsetmacro{vq}{5}
begin{tikzpicture}[scale=pi,%tdplot_main_coords
view={tdplotmaintheta}{tdplotmainphi},
perspective={
p = {(0,0,10)},
q = {(0,vq,1.25)},
}
]
path[tdplot_screen_coords] (-1.5,0.1) rectangle (1.5,2.7);
filldraw[blue!40!black]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:0.9,-0.9,0.8) -- (tpp cs:-0.9,-0.9,0.8) -- cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1) -- (tpp cs:1,1,1) -- (tpp cs:-1,1,1)
-- cycle;
%onslide<2->
begin{scope}
filldraw[blue!60!green,opacity = 0.6]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:1,-1,1.1) -- (tpp cs:-1,-1,1.1) -- cycle;
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6]
(tpp cs:-1,-1,1.1) -- (tpp cs:1,-1,1.1) -- (tpp cs:1,1,1.1) -- (tpp cs:-1,1,1.1)
-- cycle;
end{scope}
%onslide<3->
begin{scope}[tdplot_screen_coords,shift={(-0.75,1.5)},scale=0.3]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
%onslide<4->
begin{scope}
defmyx{X}
clip[postaction={fill=blue!40!black}] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.6,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1)
-- cycle;
fill[blue!50] (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- cycle; % 1
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1)
-- (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- cycle; % 2
fill[blue!50!black] (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- cycle; % 2
fill[blue!50] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 3
fill[blue!50] (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- cycle; % 3
fill[blue!60!green!70] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1) -- (tpp cs:myx-0.1,-0.6,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 4
fill[blue!50!black] (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- (tpp cs:myx-0.7,-0.6,1) -- (tpp cs:myx-0.7,-0.6,1.1)
-- cycle; % 4
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.8,1.1) -- (tpp cs:myx-0.3,-0.8,1)
-- (tpp cs:myx-0.3,-0.6,1) -- (tpp cs:myx-0.3,-0.6,1.1)
-- cycle; % 5
fill[blue!50!black] (tpp cs:myx-0.5,-0.6,1.1) -- (tpp cs:myx-0.5,-0.6,1)
-- (tpp cs:myx-0.5,-0.8,1) -- (tpp cs:myx-0.5,-0.8,1.1)
-- cycle; % 5
end{scope}
end{tikzpicture}
end{frame}}
end{document}
This is to illustrate the advantage of Max' great code: you draw in 3d, and TikZ will compute the perspective projection for you.
This is a great answer!
– Claudio Fiandrino
2 hours ago
@ClaudioFiandrino Thanks! But all credits go to tex.stackexchange.com/a/447120/121799.
– marmot
2 hours ago
@marmot Thank you very much.
– user3227125
2 hours ago
add a comment |
You could do something like this:
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
% filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
%
%
% filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
% filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
% filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
% filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
clip[scale = 0.08,postaction={fill=blue!40!black}]
(11,16-2) -- (14,16-2) -- (13.9,17-2)
-- (15.5,17-2) --(15.2,18.25-2)
--(13.7,18.25-2)--(13.6,19-2)--
(11.4,19-2)--(11.3,18.25-2)--(9.8,18.25-2)
--(9.5,17-2)--(11.1,17-2)--cycle;
fill[blue,scale = 0.08] (9.8,18.25-3) --(9.8,18.25-2)
--(9.5,17-2) --(9.5,17-3);
filldraw[blue!60!white,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(9.8,18.25-3) --(9.8,18.25-2);
fill[blue,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(11.4,19-3) --(11.4,19-2);
filldraw[blue!60!white,scale = 0.08] (11.4,19-2) --(13.6,19-2) --(13.6,19-3) -- (11.4,19-3);
fill[blue!60!green!70,scale = 0.08]
(13.6,19-2) --(13.7,18.25-2) --(13.7,18.25-3) --(13.6,19-3);
filldraw[blue!60!white,scale = 0.08]
(13.7,18.25-2) --(15.2,18.25-2) --(15.2,18.25-3)
--(13.7,18.25-3);
fill[blue!60!green!70,scale = 0.08]
(15.2,18.25-2) --(15.2,18.25-3)--(15.5,17-3)--(15.5,17-2);
end{scope}
end{tikzpicture}
end{frame}
end{document}
However, I would really like to draw your attention to this great answer, which allows you to draw things in 3d perspective. If I was you, I would redraw your diagram with these tools.
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
usepackage{tikz-3dplot}
usetikzlibrary{overlay-beamer-styles}
usepgfmodule{nonlineartransformations}
% Max magic
makeatletter
% the first part is not in use here
deftikz@scan@transform@one@point#1{%
tikz@scan@one@pointpgf@process#1%
pgf@pos@transform{pgf@x}{pgf@y}}
tikzset{%
grid source opposite corners/.code args={#1and#2}{%
pgfextract@processtikz@transform@source@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@source@northeast{%
tikz@scan@transform@one@point{#2}}%
},
grid target corners/.code args={#1--#2--#3--#4}{%
pgfextract@processtikz@transform@target@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@target@southeast{%
tikz@scan@transform@one@point{#2}}%
pgfextract@processtikz@transform@target@northeast{%
tikz@scan@transform@one@point{#3}}%
pgfextract@processtikz@transform@target@northwest{%
tikz@scan@transform@one@point{#4}}%
}
}
deftikzgridtransform{%
pgfextract@processtikz@current@point{}%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}%
{tikz@transform@source@northeast}%
}%
pgf@xc=pgf@xpgf@yc=pgf@y%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}{tikz@current@point}%
}%
pgfmathparse{pgf@x/pgf@xc}lettikz@tx=pgfmathresult%
pgfmathparse{pgf@y/pgf@yc}lettikz@ty=pgfmathresult%
%
pgfpointlineattime{tikz@ty}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@southwest}%
{tikz@transform@target@southeast}}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@northwest}%
{tikz@transform@target@northeast}}%
}
% Initialize H matrix for perspective view
pgfmathsetmacroH@tpp@aa{1}pgfmathsetmacroH@tpp@ab{0}pgfmathsetmacroH@tpp@ac{0}%pgfmathsetmacroH@tpp@ad{0}
pgfmathsetmacroH@tpp@ba{0}pgfmathsetmacroH@tpp@bb{1}pgfmathsetmacroH@tpp@bc{0}%pgfmathsetmacroH@tpp@bd{0}
pgfmathsetmacroH@tpp@ca{0}pgfmathsetmacroH@tpp@cb{0}pgfmathsetmacroH@tpp@cc{1}%pgfmathsetmacroH@tpp@cd{0}
pgfmathsetmacroH@tpp@da{0}pgfmathsetmacroH@tpp@db{0}pgfmathsetmacroH@tpp@dc{0}%pgfmathsetmacroH@tpp@dd{1}
%Initialize H matrix for main rotation
pgfmathsetmacroH@rot@aa{1}pgfmathsetmacroH@rot@ab{0}pgfmathsetmacroH@rot@ac{0}%pgfmathsetmacroH@rot@ad{0}
pgfmathsetmacroH@rot@ba{0}pgfmathsetmacroH@rot@bb{1}pgfmathsetmacroH@rot@bc{0}%pgfmathsetmacroH@rot@bd{0}
pgfmathsetmacroH@rot@ca{0}pgfmathsetmacroH@rot@cb{0}pgfmathsetmacroH@rot@cc{1}%pgfmathsetmacroH@rot@cd{0}
%pgfmathsetmacroH@rot@da{0}pgfmathsetmacroH@rot@db{0}pgfmathsetmacroH@rot@dc{0}pgfmathsetmacroH@rot@dd{1}
pgfkeys{
/three point perspective/.cd,
p/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#1))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ba{#2/#1}
pgfmathsetmacroH@tpp@ca{#3/#1}
pgfmathsetmacroH@tpp@da{ 1/#1}
coordinate (vp-p) at (#1,#2,#3);
fi
},
q/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#2))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ab{#1/#2}
pgfmathsetmacroH@tpp@cb{#3/#2}
pgfmathsetmacroH@tpp@db{ 1/#2}
coordinate (vp-q) at (#1,#2,#3);
fi
},
r/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#3))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ac{#1/#3}
pgfmathsetmacroH@tpp@bc{#2/#3}
pgfmathsetmacroH@tpp@dc{ 1/#3}
coordinate (vp-r) at (#1,#2,#3);
fi
},
coordinate/.code args={#1,#2,#3}{
pgfmathsetmacrotpp@x{#1} %<- Max' fix
pgfmathsetmacrotpp@y{#2}
pgfmathsetmacrotpp@z{#3}
},
}
tikzset{
view/.code 2 args={
pgfmathsetmacrorot@main@theta{#1}
pgfmathsetmacrorot@main@phi{#2}
% Row 1
pgfmathsetmacroH@rot@aa{cos(rot@main@phi)}
pgfmathsetmacroH@rot@ab{sin(rot@main@phi)}
pgfmathsetmacroH@rot@ac{0}
% Row 2
pgfmathsetmacroH@rot@ba{-cos(rot@main@theta)*sin(rot@main@phi)}
pgfmathsetmacroH@rot@bb{cos(rot@main@phi)*cos(rot@main@theta)}
pgfmathsetmacroH@rot@bc{sin(rot@main@theta)}
% Row 3
pgfmathsetmacroH@m@ca{sin(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cb{-cos(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cc{cos(rot@main@theta)}
% Set vector values
pgfmathsetmacrovec@x@x{H@rot@aa}
pgfmathsetmacrovec@y@x{H@rot@ab}
pgfmathsetmacrovec@z@x{H@rot@ac}
pgfmathsetmacrovec@x@y{H@rot@ba}
pgfmathsetmacrovec@y@y{H@rot@bb}
pgfmathsetmacrovec@z@y{H@rot@bc}
% Set pgf vectors
pgfsetxvec{pgfpoint{vec@x@x cm}{vec@x@y cm}}
pgfsetyvec{pgfpoint{vec@y@x cm}{vec@y@y cm}}
pgfsetzvec{pgfpoint{vec@z@x cm}{vec@z@y cm}}
},
}
tikzset{
perspective/.code={pgfkeys{/three point perspective/.cd,#1}},
perspective/.default={p={(15,0,0)},q={(0,15,0)},r={(0,0,50)}},
}
tikzdeclarecoordinatesystem{three point perspective}{
pgfkeys{/three point perspective/.cd,coordinate={#1}}
pgfmathsetmacrotemp@p@w{H@tpp@da*tpp@x + H@tpp@db*tpp@y + H@tpp@dc*tpp@z + 1}
pgfmathsetmacrotemp@p@x{(H@tpp@aa*tpp@x + H@tpp@ab*tpp@y + H@tpp@ac*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@y{(H@tpp@ba*tpp@x + H@tpp@bb*tpp@y + H@tpp@bc*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@z{(H@tpp@ca*tpp@x + H@tpp@cb*tpp@y + H@tpp@cc*tpp@z)/temp@p@w}
pgfpointxyz{temp@p@x}{temp@p@y}{temp@p@z}
}
tikzaliascoordinatesystem{tpp}{three point perspective}
makeatother
tikzset{set mark/.style args={#1|#2}{
postaction={decorate,decoration={markings,
mark=at position #1 with {coordinate(#2);}}}}}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{shapes,fadings}
begin{document}
foreach X in {0,0.08,...,0.8,0.72,0.64,...,0}
{begin{frame}[t]
frametitle{Fabrication of Metasurface}
tdplotsetmaincoords{77}{0}
pgfmathsetmacro{vq}{5}
begin{tikzpicture}[scale=pi,%tdplot_main_coords
view={tdplotmaintheta}{tdplotmainphi},
perspective={
p = {(0,0,10)},
q = {(0,vq,1.25)},
}
]
path[tdplot_screen_coords] (-1.5,0.1) rectangle (1.5,2.7);
filldraw[blue!40!black]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:0.9,-0.9,0.8) -- (tpp cs:-0.9,-0.9,0.8) -- cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1) -- (tpp cs:1,1,1) -- (tpp cs:-1,1,1)
-- cycle;
%onslide<2->
begin{scope}
filldraw[blue!60!green,opacity = 0.6]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:1,-1,1.1) -- (tpp cs:-1,-1,1.1) -- cycle;
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6]
(tpp cs:-1,-1,1.1) -- (tpp cs:1,-1,1.1) -- (tpp cs:1,1,1.1) -- (tpp cs:-1,1,1.1)
-- cycle;
end{scope}
%onslide<3->
begin{scope}[tdplot_screen_coords,shift={(-0.75,1.5)},scale=0.3]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
%onslide<4->
begin{scope}
defmyx{X}
clip[postaction={fill=blue!40!black}] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.6,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1)
-- cycle;
fill[blue!50] (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- cycle; % 1
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1)
-- (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- cycle; % 2
fill[blue!50!black] (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- cycle; % 2
fill[blue!50] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 3
fill[blue!50] (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- cycle; % 3
fill[blue!60!green!70] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1) -- (tpp cs:myx-0.1,-0.6,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 4
fill[blue!50!black] (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- (tpp cs:myx-0.7,-0.6,1) -- (tpp cs:myx-0.7,-0.6,1.1)
-- cycle; % 4
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.8,1.1) -- (tpp cs:myx-0.3,-0.8,1)
-- (tpp cs:myx-0.3,-0.6,1) -- (tpp cs:myx-0.3,-0.6,1.1)
-- cycle; % 5
fill[blue!50!black] (tpp cs:myx-0.5,-0.6,1.1) -- (tpp cs:myx-0.5,-0.6,1)
-- (tpp cs:myx-0.5,-0.8,1) -- (tpp cs:myx-0.5,-0.8,1.1)
-- cycle; % 5
end{scope}
end{tikzpicture}
end{frame}}
end{document}
This is to illustrate the advantage of Max' great code: you draw in 3d, and TikZ will compute the perspective projection for you.
You could do something like this:
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{arrows,snakes,shapes,fadings}
begin{document}
begin{frame}
frametitle{Fabrication of Metasurface}
begin{tikzpicture}[scale = 1]
onslide<1->
useasboundingbox (0,0) rectangle (10,8);
begin{scope}
filldraw[blue!40!black] (1.5,1) -- (9.5,1) -- (9.75,1.5) --(1.25,1.5)--cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70] (1.25,1.5) --(9.75,1.5) -- (8,3.5) -- (3,3.5) --cycle;
end{scope}
onslide<2->
filldraw[blue!60!green,opacity = 0.6] (1.25,1.5) rectangle (9.75,1.75);
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6] (1.25,1.75) --(9.75,1.75) -- (8.03,3.61) -- (2.97,3.61) --cycle;
onslide<3>
begin{scope}[shift = {(3,4)}]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
onslide<4->
begin{scope}[shift = {(1,-1.3)},scale = 3,opacity = 1]
% filldraw[gray!50!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (15.5,17) --(15.2,18.25)--(13.7,18.25)--(13.6,19)--(11.4,19)--(11.3,18.25)--(9.8,18.25)--(9.5,17)--(11.1,17)--cycle;
%
%
% filldraw[gray!70!white,scale = 0.08] (11,16) -- (14,16) -- (13.9,17) -- (13.7,18.25)--(11.3,18.25)--(11.1,17)--cycle;
% filldraw[blue!60!green!70,scale = 0.08] (9.5,17)--(9.6,14.5)--(11.05,14.5)--(11,16)--(11.1,17)--cycle;
% filldraw[blue!60!green,scale = 0.08] (11,16) -- (11.1,14) -- (13.9,14) -- (14,16)-- cycle;
% filldraw[blue!60!green!70,scale = 0.08] (15.5,17) --(15.4,14.5) --(13.95,14.5) --(14,16) -- (13.9,17) --cycle;
clip[scale = 0.08,postaction={fill=blue!40!black}]
(11,16-2) -- (14,16-2) -- (13.9,17-2)
-- (15.5,17-2) --(15.2,18.25-2)
--(13.7,18.25-2)--(13.6,19-2)--
(11.4,19-2)--(11.3,18.25-2)--(9.8,18.25-2)
--(9.5,17-2)--(11.1,17-2)--cycle;
fill[blue,scale = 0.08] (9.8,18.25-3) --(9.8,18.25-2)
--(9.5,17-2) --(9.5,17-3);
filldraw[blue!60!white,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(9.8,18.25-3) --(9.8,18.25-2);
fill[blue,scale = 0.08] (11.3,18.25-2) -- (11.3,18.25-3)
--(11.4,19-3) --(11.4,19-2);
filldraw[blue!60!white,scale = 0.08] (11.4,19-2) --(13.6,19-2) --(13.6,19-3) -- (11.4,19-3);
fill[blue!60!green!70,scale = 0.08]
(13.6,19-2) --(13.7,18.25-2) --(13.7,18.25-3) --(13.6,19-3);
filldraw[blue!60!white,scale = 0.08]
(13.7,18.25-2) --(15.2,18.25-2) --(15.2,18.25-3)
--(13.7,18.25-3);
fill[blue!60!green!70,scale = 0.08]
(15.2,18.25-2) --(15.2,18.25-3)--(15.5,17-3)--(15.5,17-2);
end{scope}
end{tikzpicture}
end{frame}
end{document}
However, I would really like to draw your attention to this great answer, which allows you to draw things in 3d perspective. If I was you, I would redraw your diagram with these tools.
documentclass[pdf]{beamer}
mode<presentation>{usetheme{Warsaw}}
usepackage{animate}
usepackage{amsmath}
usepackage{tikz}
usepackage{tikz-3dplot}
usetikzlibrary{overlay-beamer-styles}
usepgfmodule{nonlineartransformations}
% Max magic
makeatletter
% the first part is not in use here
deftikz@scan@transform@one@point#1{%
tikz@scan@one@pointpgf@process#1%
pgf@pos@transform{pgf@x}{pgf@y}}
tikzset{%
grid source opposite corners/.code args={#1and#2}{%
pgfextract@processtikz@transform@source@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@source@northeast{%
tikz@scan@transform@one@point{#2}}%
},
grid target corners/.code args={#1--#2--#3--#4}{%
pgfextract@processtikz@transform@target@southwest{%
tikz@scan@transform@one@point{#1}}%
pgfextract@processtikz@transform@target@southeast{%
tikz@scan@transform@one@point{#2}}%
pgfextract@processtikz@transform@target@northeast{%
tikz@scan@transform@one@point{#3}}%
pgfextract@processtikz@transform@target@northwest{%
tikz@scan@transform@one@point{#4}}%
}
}
deftikzgridtransform{%
pgfextract@processtikz@current@point{}%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}%
{tikz@transform@source@northeast}%
}%
pgf@xc=pgf@xpgf@yc=pgf@y%
pgf@process{%
pgfpointdiff{tikz@transform@source@southwest}{tikz@current@point}%
}%
pgfmathparse{pgf@x/pgf@xc}lettikz@tx=pgfmathresult%
pgfmathparse{pgf@y/pgf@yc}lettikz@ty=pgfmathresult%
%
pgfpointlineattime{tikz@ty}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@southwest}%
{tikz@transform@target@southeast}}{%
pgfpointlineattime{tikz@tx}{tikz@transform@target@northwest}%
{tikz@transform@target@northeast}}%
}
% Initialize H matrix for perspective view
pgfmathsetmacroH@tpp@aa{1}pgfmathsetmacroH@tpp@ab{0}pgfmathsetmacroH@tpp@ac{0}%pgfmathsetmacroH@tpp@ad{0}
pgfmathsetmacroH@tpp@ba{0}pgfmathsetmacroH@tpp@bb{1}pgfmathsetmacroH@tpp@bc{0}%pgfmathsetmacroH@tpp@bd{0}
pgfmathsetmacroH@tpp@ca{0}pgfmathsetmacroH@tpp@cb{0}pgfmathsetmacroH@tpp@cc{1}%pgfmathsetmacroH@tpp@cd{0}
pgfmathsetmacroH@tpp@da{0}pgfmathsetmacroH@tpp@db{0}pgfmathsetmacroH@tpp@dc{0}%pgfmathsetmacroH@tpp@dd{1}
%Initialize H matrix for main rotation
pgfmathsetmacroH@rot@aa{1}pgfmathsetmacroH@rot@ab{0}pgfmathsetmacroH@rot@ac{0}%pgfmathsetmacroH@rot@ad{0}
pgfmathsetmacroH@rot@ba{0}pgfmathsetmacroH@rot@bb{1}pgfmathsetmacroH@rot@bc{0}%pgfmathsetmacroH@rot@bd{0}
pgfmathsetmacroH@rot@ca{0}pgfmathsetmacroH@rot@cb{0}pgfmathsetmacroH@rot@cc{1}%pgfmathsetmacroH@rot@cd{0}
%pgfmathsetmacroH@rot@da{0}pgfmathsetmacroH@rot@db{0}pgfmathsetmacroH@rot@dc{0}pgfmathsetmacroH@rot@dd{1}
pgfkeys{
/three point perspective/.cd,
p/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#1))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ba{#2/#1}
pgfmathsetmacroH@tpp@ca{#3/#1}
pgfmathsetmacroH@tpp@da{ 1/#1}
coordinate (vp-p) at (#1,#2,#3);
fi
},
q/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#2))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ab{#1/#2}
pgfmathsetmacroH@tpp@cb{#3/#2}
pgfmathsetmacroH@tpp@db{ 1/#2}
coordinate (vp-q) at (#1,#2,#3);
fi
},
r/.code args={(#1,#2,#3)}{
pgfmathparse{int(round(#3))}
ifnumpgfmathresult=0else
pgfmathsetmacroH@tpp@ac{#1/#3}
pgfmathsetmacroH@tpp@bc{#2/#3}
pgfmathsetmacroH@tpp@dc{ 1/#3}
coordinate (vp-r) at (#1,#2,#3);
fi
},
coordinate/.code args={#1,#2,#3}{
pgfmathsetmacrotpp@x{#1} %<- Max' fix
pgfmathsetmacrotpp@y{#2}
pgfmathsetmacrotpp@z{#3}
},
}
tikzset{
view/.code 2 args={
pgfmathsetmacrorot@main@theta{#1}
pgfmathsetmacrorot@main@phi{#2}
% Row 1
pgfmathsetmacroH@rot@aa{cos(rot@main@phi)}
pgfmathsetmacroH@rot@ab{sin(rot@main@phi)}
pgfmathsetmacroH@rot@ac{0}
% Row 2
pgfmathsetmacroH@rot@ba{-cos(rot@main@theta)*sin(rot@main@phi)}
pgfmathsetmacroH@rot@bb{cos(rot@main@phi)*cos(rot@main@theta)}
pgfmathsetmacroH@rot@bc{sin(rot@main@theta)}
% Row 3
pgfmathsetmacroH@m@ca{sin(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cb{-cos(rot@main@phi)*sin(rot@main@theta)}
pgfmathsetmacroH@m@cc{cos(rot@main@theta)}
% Set vector values
pgfmathsetmacrovec@x@x{H@rot@aa}
pgfmathsetmacrovec@y@x{H@rot@ab}
pgfmathsetmacrovec@z@x{H@rot@ac}
pgfmathsetmacrovec@x@y{H@rot@ba}
pgfmathsetmacrovec@y@y{H@rot@bb}
pgfmathsetmacrovec@z@y{H@rot@bc}
% Set pgf vectors
pgfsetxvec{pgfpoint{vec@x@x cm}{vec@x@y cm}}
pgfsetyvec{pgfpoint{vec@y@x cm}{vec@y@y cm}}
pgfsetzvec{pgfpoint{vec@z@x cm}{vec@z@y cm}}
},
}
tikzset{
perspective/.code={pgfkeys{/three point perspective/.cd,#1}},
perspective/.default={p={(15,0,0)},q={(0,15,0)},r={(0,0,50)}},
}
tikzdeclarecoordinatesystem{three point perspective}{
pgfkeys{/three point perspective/.cd,coordinate={#1}}
pgfmathsetmacrotemp@p@w{H@tpp@da*tpp@x + H@tpp@db*tpp@y + H@tpp@dc*tpp@z + 1}
pgfmathsetmacrotemp@p@x{(H@tpp@aa*tpp@x + H@tpp@ab*tpp@y + H@tpp@ac*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@y{(H@tpp@ba*tpp@x + H@tpp@bb*tpp@y + H@tpp@bc*tpp@z)/temp@p@w}
pgfmathsetmacrotemp@p@z{(H@tpp@ca*tpp@x + H@tpp@cb*tpp@y + H@tpp@cc*tpp@z)/temp@p@w}
pgfpointxyz{temp@p@x}{temp@p@y}{temp@p@z}
}
tikzaliascoordinatesystem{tpp}{three point perspective}
makeatother
tikzset{set mark/.style args={#1|#2}{
postaction={decorate,decoration={markings,
mark=at position #1 with {coordinate(#2);}}}}}
title[]{My Presentation}
author[Raghuram Dharmavarapu]{Raghu}
date{}
usetikzlibrary{shapes,fadings}
begin{document}
foreach X in {0,0.08,...,0.8,0.72,0.64,...,0}
{begin{frame}[t]
frametitle{Fabrication of Metasurface}
tdplotsetmaincoords{77}{0}
pgfmathsetmacro{vq}{5}
begin{tikzpicture}[scale=pi,%tdplot_main_coords
view={tdplotmaintheta}{tdplotmainphi},
perspective={
p = {(0,0,10)},
q = {(0,vq,1.25)},
}
]
path[tdplot_screen_coords] (-1.5,0.1) rectangle (1.5,2.7);
filldraw[blue!40!black]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:0.9,-0.9,0.8) -- (tpp cs:-0.9,-0.9,0.8) -- cycle;
shade[top color = blue!40!white, bottom color = blue!40!white!70]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1) -- (tpp cs:1,1,1) -- (tpp cs:-1,1,1)
-- cycle;
%onslide<2->
begin{scope}
filldraw[blue!60!green,opacity = 0.6]
(tpp cs:-1,-1,1) -- (tpp cs:1,-1,1)
-- (tpp cs:1,-1,1.1) -- (tpp cs:-1,-1,1.1) -- cycle;
shade[top color = blue!60!green!70, bottom color = blue!60!green!70,opacity = 0.6]
(tpp cs:-1,-1,1.1) -- (tpp cs:1,-1,1.1) -- (tpp cs:1,1,1.1) -- (tpp cs:-1,1,1.1)
-- cycle;
end{scope}
%onslide<3->
begin{scope}[tdplot_screen_coords,shift={(-0.75,1.5)},scale=0.3]
shade[inner color=red!70!black, top color=red!75!white] (2.2,1.8)
-- ++(0.6,0) -- ++(-0.3,-1.8) -- cycle;
shade[left color=gray!50!white,right color=gray] (1.7,3)
-- ++(1.6,0) -- ++(-0.3,-1) -- ++(-1,0) -- cycle;
shade[left color=gray!50!white,right color=gray] (2.1,2)
-- ++(0.8,0) -- ++(0,-0.2) -- ++(-0.8,0) -- cycle;
draw[gray!80!black] (1.7,3) -- ++(1.6,0) -- ++(-0.3,-1)
-- ++(-1,0) -- cycle;
draw[gray!80!black] (2.1,2) -- ++(0,-0.2) -- ++(0.8,0)
-- ++(0,0.2);
end{scope}
%onslide<4->
begin{scope}
defmyx{X}
clip[postaction={fill=blue!40!black}] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.6,1.1)
-- (tpp cs:myx-0.5,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.8,1.1)
-- (tpp cs:myx-0.3,-0.6,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1)
-- cycle;
fill[blue!50] (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- cycle; % 1
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1)
-- (tpp cs:myx-0.3,-0.2,1) -- (tpp cs:myx-0.3,-0.2,1.1)
-- cycle; % 2
fill[blue!50!black] (tpp cs:myx-0.5,-0.2,1.1) -- (tpp cs:myx-0.5,-0.2,1)
-- (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- cycle; % 2
fill[blue!50] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.3,-0.4,1.1) -- (tpp cs:myx-0.3,-0.4,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 3
fill[blue!50] (tpp cs:myx-0.5,-0.4,1) -- (tpp cs:myx-0.5,-0.4,1.1)
-- (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- cycle; % 3
fill[blue!60!green!70] (tpp cs:myx-0.1,-0.4,1.1)
-- (tpp cs:myx-0.1,-0.6,1.1) -- (tpp cs:myx-0.1,-0.6,1) -- (tpp cs:myx-0.1,-0.4,1)
-- cycle; % 4
fill[blue!50!black] (tpp cs:myx-0.7,-0.4,1.1) -- (tpp cs:myx-0.7,-0.4,1)
-- (tpp cs:myx-0.7,-0.6,1) -- (tpp cs:myx-0.7,-0.6,1.1)
-- cycle; % 4
fill[blue!60!green!70] (tpp cs:myx-0.3,-0.8,1.1) -- (tpp cs:myx-0.3,-0.8,1)
-- (tpp cs:myx-0.3,-0.6,1) -- (tpp cs:myx-0.3,-0.6,1.1)
-- cycle; % 5
fill[blue!50!black] (tpp cs:myx-0.5,-0.6,1.1) -- (tpp cs:myx-0.5,-0.6,1)
-- (tpp cs:myx-0.5,-0.8,1) -- (tpp cs:myx-0.5,-0.8,1.1)
-- cycle; % 5
end{scope}
end{tikzpicture}
end{frame}}
end{document}
This is to illustrate the advantage of Max' great code: you draw in 3d, and TikZ will compute the perspective projection for you.
edited 3 hours ago
answered 4 hours ago
marmotmarmot
102k4120230
102k4120230
This is a great answer!
– Claudio Fiandrino
2 hours ago
@ClaudioFiandrino Thanks! But all credits go to tex.stackexchange.com/a/447120/121799.
– marmot
2 hours ago
@marmot Thank you very much.
– user3227125
2 hours ago
add a comment |
This is a great answer!
– Claudio Fiandrino
2 hours ago
@ClaudioFiandrino Thanks! But all credits go to tex.stackexchange.com/a/447120/121799.
– marmot
2 hours ago
@marmot Thank you very much.
– user3227125
2 hours ago
This is a great answer!
– Claudio Fiandrino
2 hours ago
This is a great answer!
– Claudio Fiandrino
2 hours ago
@ClaudioFiandrino Thanks! But all credits go to tex.stackexchange.com/a/447120/121799.
– marmot
2 hours ago
@ClaudioFiandrino Thanks! But all credits go to tex.stackexchange.com/a/447120/121799.
– marmot
2 hours ago
@marmot Thank you very much.
– user3227125
2 hours ago
@marmot Thank you very much.
– user3227125
2 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%2f476110%2f3d-buried-view-in-tikz%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
You only want to change the last frame, right?
– marmot
4 hours ago