Fri, 06 Dec 2024 13:53:09 -0500
Cylinder pgfplots code reuse
visualisation/cylinder.tex | file | annotate | diff | comparison | revisions |
--- a/visualisation/cylinder.tex Fri Dec 06 13:44:34 2024 -0500 +++ b/visualisation/cylinder.tex Fri Dec 06 13:53:09 2024 -0500 @@ -8,6 +8,11 @@ \begin{tikzpicture} \pgfplotsset{ + cyl data/.code = \pgfplotsset{% + table/x expr = \thisrow{r} * cos(deg(\thisrow{angle})), + table/y expr = \thisrow{r} * sin(deg(\thisrow{angle})), + table/z = z, + }, onlyfront/.code = \pgfplotsset{x filter/.expression={% \thisrow{face} == 0 || (% and(\thisrow{face}==2, or(2*pi+\a <= \thisrow{angle}, \thisrow{angle} <= \b)) @@ -28,28 +33,12 @@ \addplot3[edge, domain=\b:(2*pi+\a), samples = 90, samples y = 0] ({cos(deg(x))}, {sin(deg(x))}, {-0.5}); % Data on hidden faces - \addplot3[backdata] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/data.csv}; + \addplot3[backdata] table [cyl data] {\datapath/data.csv}; % Iterates on hidden faces - \addplot3[backiter1,onlyback] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/x1_log.csv}; - \addplot3[backiter2,onlyback] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/x2_log.csv}; - \addplot3[backiter3,onlyback] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/x3_log.csv}; + \addplot3[backiter1,onlyback] table [cyl data] {\datapath/x1_log.csv}; + \addplot3[backiter2,onlyback] table [cyl data] {\datapath/x2_log.csv}; + \addplot3[backiter3,onlyback] table [cyl data] {\datapath/x3_log.csv}; % Surface \addplot3[ @@ -83,39 +72,19 @@ \addplot3[edge] coordinates { (cos(deg(\b)), sin(deg(\b)), -0.5) (cos(deg(\b)), sin(deg(\b)), 0.5) }; % Data - \addplot3[data, onlyfront] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/data.csv}; + \addplot3[data, onlyfront] table [cyl data] {\datapath/data.csv}; \addlegendentry{Data} % Iterates - \addplot3[iter1,onlyfront] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/x1_log.csv}; + \addplot3[iter1,onlyfront] table [cyl data] {\datapath/x1_log.csv}; \addlegendentry{Iterates 1} - \addplot3[iter2,onlyfront] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/x2_log.csv}; + \addplot3[iter2,onlyfront] table [cyl data] {\datapath/x2_log.csv}; \addlegendentry{Iterates 2} - \addplot3[iter3,onlyfront] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/x3_log.csv}; + \addplot3[iter3,onlyfront] table [cyl data] {\datapath/x3_log.csv}; \addlegendentry{Iterates 3} % Origin - \addplot3[origin, onlyfront] table[ - x expr = \thisrow{r} * cos(deg(\thisrow{angle})), - y expr = \thisrow{r} * sin(deg(\thisrow{angle})), - z = z, - ] {\datapath/origin.csv}; + \addplot3[origin, onlyfront] table [cyl data] {\datapath/origin.csv}; \addlegendentry{Origin} \end{axis} \end{tikzpicture}