Created
December 1, 2018 20:25
-
-
Save kietdlam/62a7842921bb1395b271610a6d6590b8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
\documentclass{article} | |
\usepackage{amsmath} | |
\usepackage{tikz} | |
\usepackage{tikz-3dplot} | |
\usetikzlibrary{arrows} | |
\usepackage{pgfplots} | |
\usepackage{miller} | |
\newcommand\mycalc[1]{\directlua{tex.sprint(#1)}} | |
\pgfplotsset{compat=1.16} | |
% set up externalization | |
\usetikzlibrary{external} | |
\tikzset{external/system call={lualatex \tikzexternalcheckshellescape -halt-on-error | |
-interaction=batchmode -jobname "\image" "\texsource"; | |
dvips -o "\image".ps "\image".dvi; | |
ps2eps "\image.ps"}} | |
\tikzexternalize | |
\begin{document} | |
\begin{figure}[h!] | |
\centering | |
% Good preset for coordinates | |
%\tdplotsetmaincoords{110}{340} | |
% Note that this is {azimuth}{elevation} | |
%\tdplotsetmaincoords{-66}{43} | |
\tdplotsetmaincoords{58}{20} | |
\begin{tikzpicture}[tdplot_main_coords, scale=7] | |
\draw[thick,->, opacity=0.8] (0,0,0) -- (2,0,0) node[anchor=north east](X){$x$}; | |
\node (Xmiller) [below of=X, yshift=3ex]{$\mathbf{\hkl[-3-53]}$}; | |
\draw[thin,->, opacity=0.8] (0,0,0) -- (0,3,0) node[anchor=north west](Y){$y$}; | |
\node (Ymiller) [above of=Y, yshift=-2ex]{$\mathbf{\hkl[34 -18 4]}$}; | |
\draw[thin,->, opacity=0.8] (0,0,0) -- (0,0,1.7) node[anchor=south](Z){$z$}; | |
\node (Zmiller) [above of=Z, yshift=-3ex]{$\mathbf{\hkl[135]}$}; | |
\def \maxy {1} | |
\def \maxx {1.6} | |
\def \maxz {1} | |
\def \step {5} | |
\foreach \x in {0,...,\step} | |
\draw[thin,-, opacity=0.2] (\mycalc{(\maxx / \step) * \x},0,0) -- (\mycalc{(\maxx / \step) * \x}, \maxy,0); | |
\foreach \y in {0,...,\step} | |
\draw[thin,-, opacity=0.2] (0,\mycalc{(\maxy / \step) * \y},0) -- (\maxx, \mycalc{(\maxy / \step) * \y},0); | |
\foreach \y in {0,...,\step} | |
\draw[thin,-, opacity=0.2] (0,\mycalc{(\maxy / \step) * \y},0) -- (0, \mycalc{(\maxy / \step) * \y},\maxz); | |
\foreach \z in {0,...,\step} | |
\draw[thin,-, opacity=0.2] (0,0,\mycalc{(\maxz / \step) * \z}) -- (0,\maxy,\mycalc{(\maxz / \step) * \z}); | |
\foreach \x in {0,...,\step} | |
\draw[thin,-, opacity=0.2] (\mycalc{(\maxx / \step) * \x},\maxy,0) -- (\mycalc{(\maxx / \step) * \x}, \maxy,\maxz); | |
\foreach \z in {0,...,\step} | |
\draw[thin,-, opacity=0.2] (0,\maxy,\mycalc{(\maxz / \step) * \z}) -- (\maxx,\maxy,\mycalc{(\maxz / \step) * \z}); | |
% Grain Boundary | |
\filldraw[ | |
draw=gray,% | |
fill=gray!20,% | |
] | |
(0.54321544,0,0) | |
-- (0.54321544, 1, 0) | |
-- (0.666, 1, 1) | |
-- (0.666, 0, 1) | |
-- cycle; | |
% Right Slip Plane | |
\filldraw[ | |
draw=orange,% | |
fill=orange!20,% | |
] | |
(0.62684361, 0, 0.68109683) | |
-- (1.26309912, 0,1.0) | |
-- (1.6, 0.49679101, 1.0) | |
-- (1.6 , 1.0 , 0.82895747) | |
-- (0.58237183, 1.0 , 0.31890317) | |
-- cycle; | |
% Crystal boundary | |
\draw[black] (1.6,1,0) -- (1.6,1,1) -- (1.6,0,1) -- (1.6,0,0) -- cycle; | |
\draw[black] (1.6,1,1) -- (1.6,0,1) -- (0,0,1) -- (0,1,1) -- cycle; | |
\draw[black] (0,0,0) -- (0,1,0) -- (0,1,1) -- (0,0,1) -- cycle; | |
\draw[black] (0,1,0) -- (0,1,1) -- (1.6,1,1) -- (1.6,1,0) -- cycle; | |
\draw[black] (1.6,1,0) -- (1.6,0,0) -- (0,0,0) -- (0,1,0) -- cycle; | |
\draw[black] (0,1,0) -- (0,1,1) -- (1.6,1,1) -- (1.6,1,0) -- cycle; | |
% Grain Boundary vertices | |
\draw plot [only marks, mark=*, mark size=0.4, mark options={color=black, opacity=0.3}] | |
coordinates{ | |
(0.54321544, 0.0 , 0.0 ) | |
(0.666 , 1.0 , 1.0 ) | |
(0.666 , 0.0 , 1.0 ) | |
(0.54321544, 1.0 , 0.0 ) | |
}; | |
% Right plane vertices | |
\draw plot [only marks, mark=*, mark size=0.4, mark options={color=red, opacity=0.3}] | |
coordinates{ | |
(1.26309912, 0.0 , 1.0 ) | |
(0.62684361, 0.0 , 0.68109683) | |
(1.6 , 1.0 , 0.82895747) | |
(1.6 , 0.49679101, 1.0 ) | |
(0.58237183, 1.0 , 0.31890317) | |
}; | |
% Marker vertices | |
%\draw plot [only marks, mark=*, mark size=0.4, mark options={color=black, opacity=0.99, text mark=1.6}] | |
%coordinates{ | |
%(1.6, 0.0 , 0.0 ) | |
%} ; | |
\node (P1) at (1.7,0,0) {}; | |
\node (P2) at (1.5,0,0) {}; | |
\draw (P1) -- node[sloped,below] {(1.6,\ 0,\ 0)} (P2); | |
\node (P3) at (0, 1, 1.05) {(0,\ 1,\ 1)}; | |
\end{tikzpicture} | |
\end{figure} | |
\end{document} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment