\input regression-test.tex \documentclass{article} \usepackage{tikzphysics} \newdimen\tikzphysicstestx \newdimen\tikzphysicstesty \newdimen\tikzphysicstestxx \newdimen\tikzphysicstestyy \newdimen\tikzphysicstestdiff \newdimen\tikzphysicstestexpected \newcommand{\tikzphysicsgetpoint}[2]{% \pgfextractx{\tikzphysicstestx}{\pgfpointanchor{#1}{#2}}% \pgfextracty{\tikzphysicstesty}{\pgfpointanchor{#1}{#2}}% } \newcommand{\tikzphysicsassertdim}[3]{% \tikzphysicstestexpected=#2\relax \tikzphysicstestdiff=#1\relax \advance\tikzphysicstestdiff by -\tikzphysicstestexpected\relax \ifdim\tikzphysicstestdiff<0pt \tikzphysicstestdiff=-\tikzphysicstestdiff\fi \ifdim\tikzphysicstestdiff<0.03pt \TYPE{PASS: #3}% \else \TYPE{FAIL: #3 (got \the#1, expected \the\tikzphysicstestexpected)}% \fi } \newcommand{\tikzphysicsassertpoint}[5]{% \tikzphysicsgetpoint{#1}{#2}% \tikzphysicstestxx=\tikzphysicstestx \tikzphysicstestyy=\tikzphysicstesty \tikzphysicsgetpoint{#3}{#4}% \tikzphysicsassertdim{\tikzphysicstestxx}{\tikzphysicstestx}{#5 x}% \tikzphysicsassertdim{\tikzphysicstestyy}{\tikzphysicstesty}{#5 y}% } \newcommand{\tikzphysicsassertnumber}[3]{% \pgfmathparse{abs((#1)-(#2))}% \ifdim\pgfmathresult pt<0.001pt \TYPE{PASS: #3}% \else \TYPE{FAIL: #3 (difference \pgfmathresult)}% \fi } \begin{document}\START \setbox0=\hbox{\begin{tikzpicture}[>=latex] \node[polar element,element inner radius=3cm,element outer radius=3.2cm,element start angle=-15,element delta angle=30] (L) {}; \tikzphysicsgetpoint{L}{centroid} \tikzphysicsassertdim{\tikzphysicstestx}{3.0657724cm}{large sector independently calculated centroid x} \tikzphysicsassertdim{\tikzphysicstesty}{0cm}{large sector independently calculated centroid y} \node[polar element,element inner radius=2cm,element outer radius=4cm,element start angle=-.0005,element delta angle=.001] (N) {}; \tikzphysicsgetpoint{N}{centroid} \tikzphysicsassertdim{\tikzphysicstestx}{3.1111111cm}{narrow sector limiting centroid x} \tikzphysicsassertdim{\tikzphysicstesty}{0cm}{narrow sector limiting centroid y} \node[polar element,element inner radius=30mm,element outer radius=32mm,element start angle=-15,element delta angle=30,rotate=90,scale=1.5] (T) at (1,2) {}; \tikzphysicsgetpoint{T}{centroid} \tikzphysicsassertdim{\tikzphysicstestx}{1cm}{rotated scaled mixed-unit centroid x} \tikzphysicsassertdim{\tikzphysicstesty}{6.5986586cm}{rotated scaled mixed-unit centroid y} \node[polar element] (A0) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A0}{inner-\p}} \TYPE{PASS: polar element inner all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A0}{outer-\p}} \TYPE{PASS: polar element outer all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A0}{start-\p}} \TYPE{PASS: polar element start all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A0}{end-\p}} \TYPE{PASS: polar element end all integer percentages} \node[differential sector] (A1) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A1}{inner-\p}} \TYPE{PASS: differential sector inner all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A1}{outer-\p}} \TYPE{PASS: differential sector outer all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A1}{start-\p}} \TYPE{PASS: differential sector start all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A1}{end-\p}} \TYPE{PASS: differential sector end all integer percentages} \node[differential ring] (A2) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A2}{inner-\p}} \TYPE{PASS: differential ring inner all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A2}{outer-\p}} \TYPE{PASS: differential ring outer all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A2}{start-\p}} \TYPE{PASS: differential ring start all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A2}{end-\p}} \TYPE{PASS: differential ring end all integer percentages} \node[spherical shell] (A3) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A3}{inner-\p}} \TYPE{PASS: spherical shell inner all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A3}{outer-\p}} \TYPE{PASS: spherical shell outer all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A3}{start-\p}} \TYPE{PASS: spherical shell start all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A3}{end-\p}} \TYPE{PASS: spherical shell end all integer percentages} \node[hollow sphere] (A4) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A4}{inner-\p}} \TYPE{PASS: hollow sphere inner all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A4}{outer-\p}} \TYPE{PASS: hollow sphere outer all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A4}{start-\p}} \TYPE{PASS: hollow sphere start all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A4}{end-\p}} \TYPE{PASS: hollow sphere end all integer percentages} \node[unwrapped ring] (A5) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A5}{bottom-\p}} \TYPE{PASS: unwrapped ring bottom all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A5}{right-\p}} \TYPE{PASS: unwrapped ring right all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A5}{top-\p}} \TYPE{PASS: unwrapped ring top all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A5}{left-\p}} \TYPE{PASS: unwrapped ring left all integer percentages} \node[rectangular element] (A6) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A6}{bottom-\p}} \TYPE{PASS: rectangular element bottom all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A6}{right-\p}} \TYPE{PASS: rectangular element right all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A6}{top-\p}} \TYPE{PASS: rectangular element top all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A6}{left-\p}} \TYPE{PASS: rectangular element left all integer percentages} \node[rectangular strip] (A7) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A7}{bottom-\p}} \TYPE{PASS: rectangular strip bottom all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A7}{right-\p}} \TYPE{PASS: rectangular strip right all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A7}{top-\p}} \TYPE{PASS: rectangular strip top all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A7}{left-\p}} \TYPE{PASS: rectangular strip left all integer percentages} \node[rectangular sheet] (A8) {}; \foreach \p in {0,...,100}{\pgfpointanchor{A8}{bottom-\p}} \TYPE{PASS: rectangular sheet bottom all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A8}{right-\p}} \TYPE{PASS: rectangular sheet right all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A8}{top-\p}} \TYPE{PASS: rectangular sheet top all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{A8}{left-\p}} \TYPE{PASS: rectangular sheet left all integer percentages} \pic (SS) {sphere slice diagram}; \pic (CS) {cylinder shell diagram}; \pic (CX) at (6,0) {cylinder slice diagram}; \pic (KX) at (12,0) {cone slice diagram}; \foreach \p in {0,...,100}{\pgfpointanchor{SS-disk-rim-\p}{center}} \TYPE{PASS: SS disk-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CS-body-rim-\p}{center}} \TYPE{PASS: CS body-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CS-shell-outer-rim-\p}{center}} \TYPE{PASS: CS shell-outer-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CS-shell-inner-rim-\p}{center}} \TYPE{PASS: CS shell-inner-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CS-height-\p}{center}} \TYPE{PASS: CS height all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CX-body-rim-\p}{center}} \TYPE{PASS: CX body-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CX-slice-top-rim-\p}{center}} \TYPE{PASS: CX slice-top-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CX-slice-bottom-rim-\p}{center}} \TYPE{PASS: CX slice-bottom-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{CX-height-\p}{center}} \TYPE{PASS: CX height all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{KX-body-rim-\p}{center}} \TYPE{PASS: KX body-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{KX-slice-top-rim-\p}{center}} \TYPE{PASS: KX slice-top-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{KX-slice-bottom-rim-\p}{center}} \TYPE{PASS: KX slice-bottom-rim all integer percentages} \foreach \p in {0,...,100}{\pgfpointanchor{KX-height-\p}{center}} \TYPE{PASS: KX height all integer percentages} \tikzphysicsgetpoint{CS-height-0}{center} \tikzphysicsassertdim{\tikzphysicstestx}{0cm}{cylinder physical height bottom x} \tikzphysicsassertdim{\tikzphysicstesty}{-1.7cm}{cylinder physical height bottom y} \tikzphysicsgetpoint{CS-height-100}{center} \tikzphysicsassertdim{\tikzphysicstestx}{0cm}{cylinder physical height top x} \tikzphysicsassertdim{\tikzphysicstesty}{1.7cm}{cylinder physical height top y} \tikzphysicsgetpoint{CS-shell-outer-rim-25}{center} \tikzphysicsassertdim{\tikzphysicstestx}{0cm}{outer shell top projected rim x} \tikzphysicsassertdim{\tikzphysicstesty}{1.9625cm}{outer shell top projected rim y} \tikzphysicsgetpoint{CS-shell-inner-rim-50}{center} \tikzphysicsassertdim{\tikzphysicstestx}{-0.9cm}{inner shell left rim x} \tikzphysicsassertdim{\tikzphysicstesty}{1.7cm}{inner shell left rim y} \tikzphysicsgetpoint{CX-slice-top-rim-25}{center} \tikzphysicsassertdim{\tikzphysicstestx}{6cm}{cylinder slice top projected rim x} \tikzphysicsassertdim{\tikzphysicstesty}{0.67cm}{cylinder slice top projected rim y} \tikzphysicsgetpoint{CX-slice-bottom-rim-75}{center} \tikzphysicsassertdim{\tikzphysicstestx}{6cm}{cylinder slice bottom projected rim x} \tikzphysicsassertdim{\tikzphysicstesty}{-0.33cm}{cylinder slice bottom projected rim y} \tikzphysicsgetpoint{KX-slice-top-rim-0}{center} \tikzphysicsassertdim{\tikzphysicstestx}{13.044cm}{cone top radius x} \tikzphysicsassertdim{\tikzphysicstesty}{-0.32cm}{cone top radius y} \tikzphysicsgetpoint{KX-slice-bottom-rim-0}{center} \tikzphysicsassertdim{\tikzphysicstestx}{13.134cm}{cone bottom radius x} \tikzphysicsassertdim{\tikzphysicstesty}{-0.52cm}{cone bottom radius y} \tikzphysicsgetpoint{SS-disk-rim-25}{center} \tikzphysicsassertdim{\tikzphysicstestx}{0.7cm}{sphere disk projected top x} \tikzphysicsassertdim{\tikzphysicstesty}{1.8734994cm}{sphere disk projected top y} \tikzphysicsgetpoint{SS-disk-rim-37}{center} \tikzphysicsassertdim{\tikzphysicstestx}{0.3922003cm}{sphere disk interior ellipse point x} \tikzphysicsassertdim{\tikzphysicstesty}{1.3657223cm}{sphere disk interior ellipse point y} \begin{scope}[rotate=90,scale=.5,transform shape] \pic (R) {cone slice diagram}; \end{scope} \tikzphysicsgetpoint{R-slice-top-rim-25}{center} \tikzphysicsassertdim{\tikzphysicstestx}{0.03472cm}{transformed cone ellipse x} \tikzphysicsassertdim{\tikzphysicstesty}{0cm}{transformed cone ellipse y} \node[differential sector,element outer radius=1cm,element delta angle=270] {}; \tikzphysicsgetpoint{L}{centroid} \tikzphysicsassertdim{\tikzphysicstestx}{3.0657724cm}{centroid survives later node x} \tikzphysicsassertdim{\tikzphysicstesty}{0cm}{centroid survives later node y} \tikzphysicsgetpoint{CX-slice-top-rim-25}{center} \tikzphysicsassertdim{\tikzphysicstestx}{6cm}{pic coordinates survive later node x} \tikzphysicsassertdim{\tikzphysicstesty}{0.67cm}{pic coordinates survive later node y} \end{tikzpicture}} \END\end{document}