Reference variables from package calculator in TiKZ
up vote
0
down vote
favorite
I have this code:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (7.908394:5.994461) node (a1) {} arc[radius=5.994461, start angle=7.908394, end angle= 13.546137] -- (13.546137:6.61482) node (a2) {} arc[radius=6.61482, start angle=13.546137, end angle= 7.908394] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
I want to use the variables: "rh11, rh12, thetadeg11 and thetadeg12"
,calculated with the calculator package before the TiKZpicture,
for use as coordinates of the hole in the TiKZpicture. I Have tried with this:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (thetadeg11:rh11) node (a1) {} arc[radius=rh11, start angle=thetadeg11, end angle= thetadeg12] -- (thetadeg12:rh12) node (a2) {} arc[radius=rh12, start angle=thetadeg12, end angle= thetadeg11] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
But it does not compile, it shows en error warning. How can I reference them?.
tikz-pgf calculations
add a comment |
up vote
0
down vote
favorite
I have this code:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (7.908394:5.994461) node (a1) {} arc[radius=5.994461, start angle=7.908394, end angle= 13.546137] -- (13.546137:6.61482) node (a2) {} arc[radius=6.61482, start angle=13.546137, end angle= 7.908394] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
I want to use the variables: "rh11, rh12, thetadeg11 and thetadeg12"
,calculated with the calculator package before the TiKZpicture,
for use as coordinates of the hole in the TiKZpicture. I Have tried with this:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (thetadeg11:rh11) node (a1) {} arc[radius=rh11, start angle=thetadeg11, end angle= thetadeg12] -- (thetadeg12:rh12) node (a2) {} arc[radius=rh12, start angle=thetadeg12, end angle= thetadeg11] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
But it does not compile, it shows en error warning. How can I reference them?.
tikz-pgf calculations
1
You could probably usepgfmathinstead ofcalculator, e.g.pgfmathsetmacro{foo}{3*sin(60)}calculates the product of 3 and the sine of 60 degrees and saves it to the macrofoo.
– Torbjørn T.
Nov 9 at 17:22
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I have this code:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (7.908394:5.994461) node (a1) {} arc[radius=5.994461, start angle=7.908394, end angle= 13.546137] -- (13.546137:6.61482) node (a2) {} arc[radius=6.61482, start angle=13.546137, end angle= 7.908394] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
I want to use the variables: "rh11, rh12, thetadeg11 and thetadeg12"
,calculated with the calculator package before the TiKZpicture,
for use as coordinates of the hole in the TiKZpicture. I Have tried with this:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (thetadeg11:rh11) node (a1) {} arc[radius=rh11, start angle=thetadeg11, end angle= thetadeg12] -- (thetadeg12:rh12) node (a2) {} arc[radius=rh12, start angle=thetadeg12, end angle= thetadeg11] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
But it does not compile, it shows en error warning. How can I reference them?.
tikz-pgf calculations
I have this code:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (7.908394:5.994461) node (a1) {} arc[radius=5.994461, start angle=7.908394, end angle= 13.546137] -- (13.546137:6.61482) node (a2) {} arc[radius=6.61482, start angle=13.546137, end angle= 7.908394] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
I want to use the variables: "rh11, rh12, thetadeg11 and thetadeg12"
,calculated with the calculator package before the TiKZpicture,
for use as coordinates of the hole in the TiKZpicture. I Have tried with this:
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (thetadeg11:rh11) node (a1) {} arc[radius=rh11, start angle=thetadeg11, end angle= thetadeg12] -- (thetadeg12:rh12) node (a2) {} arc[radius=rh12, start angle=thetadeg12, end angle= thetadeg11] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
But it does not compile, it shows en error warning. How can I reference them?.
tikz-pgf calculations
tikz-pgf calculations
asked Nov 9 at 17:15
Alfredo
646
646
1
You could probably usepgfmathinstead ofcalculator, e.g.pgfmathsetmacro{foo}{3*sin(60)}calculates the product of 3 and the sine of 60 degrees and saves it to the macrofoo.
– Torbjørn T.
Nov 9 at 17:22
add a comment |
1
You could probably usepgfmathinstead ofcalculator, e.g.pgfmathsetmacro{foo}{3*sin(60)}calculates the product of 3 and the sine of 60 degrees and saves it to the macrofoo.
– Torbjørn T.
Nov 9 at 17:22
1
1
You could probably use
pgfmath instead of calculator, e.g. pgfmathsetmacro{foo}{3*sin(60)} calculates the product of 3 and the sine of 60 degrees and saves it to the macro foo.– Torbjørn T.
Nov 9 at 17:22
You could probably use
pgfmath instead of calculator, e.g. pgfmathsetmacro{foo}{3*sin(60)} calculates the product of 3 and the sine of 60 degrees and saves it to the macro foo.– Torbjørn T.
Nov 9 at 17:22
add a comment |
2 Answers
2
active
oldest
votes
up vote
1
down vote
I believe that Torbjørn T'.'s suggestion is the cleanest way to proceed here. Nevertheless, as some sort of academic exercise (or even more, depending on how you view things), in the following I show a rather simple way to make things work. Let me, however, stress that
this code throws several pstricks-related warnings which I did not try to make disappear.
I have been using pstricks for more than a decade, and just recently switched to TikZ. I always loved using pstricks and am really grateful to those who wrote and maintain that great package. However, unfortunately I cannot find enough motivation any more to find out what the sometimes arguably somewhat cryptic warnings mean.
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
xdeftmpa{rh11}
%typeout{tmpa}
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
xdeftmpb{rh12}
typeout{tmpb}
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
xdeftmpc{thetadeg11}
%typeout{tmpc}
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
xdeftmpd{thetadeg12}
%typeout{tmpd}
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (tmpc:tmpa) coordinate (a1)
arc[radius=tmpa, start angle=tmpc, end angle= tmpd] --
(tmpd:tmpb) coordinate (a2) arc[radius=tmpb, start angle=tmpd, end angle=
tmpc] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}

add a comment |
up vote
0
down vote
documentclass[border=3pt]{standalone}
%usepackage[letterpaper, landscape, margin=0in]{geometry}
%usepackage{graphicx}
%usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
%usepackage{pstricks}
%usepackage{amsmath}
%usepackage[none]{hyphenat}
%usepackage{bigstrut}
% allowdisplaybreaks
%usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
usepackage{xintexpr}
begin{document}
makeatletter
xintdefvar doverh := 0.5; % d/h relation
xintdefvar h := 1.4; % Plate thickness
xintdefvar equivalent_circle_diameter := doverh * h;
% xintdefvar A_part_1 := equivalent_circle_diameter^2;
% 3.141592653589793238462643383279502884197169399375105820974944...
xintdefvar Pi := 3.1415926535897932;
% xintdefvar A_part_2 := Pi * A_part_1;
% xintdefvar Area := A_part_2/4;
xintdefvar Area := Pi * equivalent_circle_diameter^2/4;
%xintdefvar temp1r_h11 := sqrt(Area);
%xintdefvar temp2r_h11 := temp1r_h11/2;
xintdefvar temp2r_h11 := sqrt(Area)/2;
xintdefvar r1 := 6.304640974884; % Central radius of the first hole.
xintdefvar rh11 := r1 - temp2r_h11; % Internal radius of hole 1.
%$xintthefloatexpr[8] rh11relax$
xintdefvar rh12 := r1 + temp2r_h11;% External radius of hole 1
%$xintthefloatexpr[8] rh12relax$
% xintdefvar theta_hs1_part1 := 1/r1;
% xintdefvar theta_hs1 := temp2r_h11 * theta_hs1_part1;
xintdefvar theta_hs1 := temp2r_h11 /r1;
xintdefvar varph1 := 0.187226105362745; % angle of the first hole.
xintdefvar thetarad11_rad := varph1 - theta_hs1; % angle in radians of the
% first border of hole 1
% xintdefvar thetadeg11_part1 := thetarad11_rad/Pi;
% xintdefvar thetadeg11 := 180 * thetadeg11_part1;
xintdefvar thetadeg11 := 180 * thetarad11_rad/Pi;
%$xintthefloatexpr[8] thetadeg11relax$
xintdefvar thetarad12_rad := varph1 + theta_hs1; % angle in radians of the
% second border of hole 1
% xintdefvar thetadeg12_part1 := thetarad12_rad/Pi;
% xintdefvar thetadeg12 := thetadeg12_part1 * 180;
xintdefvar thetadeg12 := 180 * thetarad12_rad/Pi;
%$xintthefloatexpr[8] thetadeg12relax$
newcommandxuse[1]{xintthefloatexpr[8] #1relax}% float rounding to 8 digits
% of precision
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (xuse{thetadeg11}:xuse{rh11}) node (a1) {} arc[radius=xuse{rh11}, start angle=xuse{thetadeg11}, end angle=xuse{thetadeg12}] -- (xuse{thetadeg12}:xuse{rh12}) node (a2) {} arc[radius=xuse{rh12}, start angle=xuse{thetadeg12}, end angle= xuse{thetadeg11}] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
Remark: in the above quantities will be rounded again to 8 digits float precision each time xuse is invoked. It is possible to arrange for this rounding to be done once and for all.

add a comment |
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
I believe that Torbjørn T'.'s suggestion is the cleanest way to proceed here. Nevertheless, as some sort of academic exercise (or even more, depending on how you view things), in the following I show a rather simple way to make things work. Let me, however, stress that
this code throws several pstricks-related warnings which I did not try to make disappear.
I have been using pstricks for more than a decade, and just recently switched to TikZ. I always loved using pstricks and am really grateful to those who wrote and maintain that great package. However, unfortunately I cannot find enough motivation any more to find out what the sometimes arguably somewhat cryptic warnings mean.
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
xdeftmpa{rh11}
%typeout{tmpa}
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
xdeftmpb{rh12}
typeout{tmpb}
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
xdeftmpc{thetadeg11}
%typeout{tmpc}
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
xdeftmpd{thetadeg12}
%typeout{tmpd}
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (tmpc:tmpa) coordinate (a1)
arc[radius=tmpa, start angle=tmpc, end angle= tmpd] --
(tmpd:tmpb) coordinate (a2) arc[radius=tmpb, start angle=tmpd, end angle=
tmpc] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}

add a comment |
up vote
1
down vote
I believe that Torbjørn T'.'s suggestion is the cleanest way to proceed here. Nevertheless, as some sort of academic exercise (or even more, depending on how you view things), in the following I show a rather simple way to make things work. Let me, however, stress that
this code throws several pstricks-related warnings which I did not try to make disappear.
I have been using pstricks for more than a decade, and just recently switched to TikZ. I always loved using pstricks and am really grateful to those who wrote and maintain that great package. However, unfortunately I cannot find enough motivation any more to find out what the sometimes arguably somewhat cryptic warnings mean.
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
xdeftmpa{rh11}
%typeout{tmpa}
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
xdeftmpb{rh12}
typeout{tmpb}
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
xdeftmpc{thetadeg11}
%typeout{tmpc}
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
xdeftmpd{thetadeg12}
%typeout{tmpd}
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (tmpc:tmpa) coordinate (a1)
arc[radius=tmpa, start angle=tmpc, end angle= tmpd] --
(tmpd:tmpb) coordinate (a2) arc[radius=tmpb, start angle=tmpd, end angle=
tmpc] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}

add a comment |
up vote
1
down vote
up vote
1
down vote
I believe that Torbjørn T'.'s suggestion is the cleanest way to proceed here. Nevertheless, as some sort of academic exercise (or even more, depending on how you view things), in the following I show a rather simple way to make things work. Let me, however, stress that
this code throws several pstricks-related warnings which I did not try to make disappear.
I have been using pstricks for more than a decade, and just recently switched to TikZ. I always loved using pstricks and am really grateful to those who wrote and maintain that great package. However, unfortunately I cannot find enough motivation any more to find out what the sometimes arguably somewhat cryptic warnings mean.
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
xdeftmpa{rh11}
%typeout{tmpa}
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
xdeftmpb{rh12}
typeout{tmpb}
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
xdeftmpc{thetadeg11}
%typeout{tmpc}
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
xdeftmpd{thetadeg12}
%typeout{tmpd}
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (tmpc:tmpa) coordinate (a1)
arc[radius=tmpa, start angle=tmpc, end angle= tmpd] --
(tmpd:tmpb) coordinate (a2) arc[radius=tmpb, start angle=tmpd, end angle=
tmpc] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}

I believe that Torbjørn T'.'s suggestion is the cleanest way to proceed here. Nevertheless, as some sort of academic exercise (or even more, depending on how you view things), in the following I show a rather simple way to make things work. Let me, however, stress that
this code throws several pstricks-related warnings which I did not try to make disappear.
I have been using pstricks for more than a decade, and just recently switched to TikZ. I always loved using pstricks and am really grateful to those who wrote and maintain that great package. However, unfortunately I cannot find enough motivation any more to find out what the sometimes arguably somewhat cryptic warnings mean.
documentclass[letterpaper,12pt]{report}
usepackage[letterpaper, landscape, margin=0in]{geometry}
usepackage{graphicx}
usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
usepackage{pstricks}
usepackage{amsmath}
usepackage[none]{hyphenat}
usepackage{bigstrut}
allowdisplaybreaks
usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
begin{document}
COPY{0.5}{d_h_relation} % d/h relation
COPY{1.4}{h} % Plate thickness
MULTIPLY{d_h_relation}{h}{equivalent_circle_diameter}
MULTIPLY{equivalent_circle_diameter}{equivalent_circle_diameter}{A_part_1}
MULTIPLY{A_part_1}{numberPI}{A_part_2}
DIVIDE{A_part_2}{4}{Area}% Area of the hole.
SQUAREROOT{Area}{temp1r_h11}
DIVIDE{temp1r_h11}{2}{temp2r_h11}
COPY{6.304640974884}{r1} % Central radius of the first hole.
SUBTRACT{r1}{temp2r_h11}{rh11} % Internal radius of hole 1.
$rh11$
xdeftmpa{rh11}
%typeout{tmpa}
ADD{r1}{temp2r_h11}{rh12} % External radius of hole 1
$rh12$
xdeftmpb{rh12}
typeout{tmpb}
DIVIDE{1}{r1}{theta_hs1_part1}
MULTIPLY{temp2r_h11}{theta_hs1_part1}{theta_hs1}
COPY{0.187226105362745}{varph1} % angle of the first hole.
SUBTRACT{varph1}{theta_hs1}{thetarad11_rad} % angle in radians of the first border of hole 1
DIVIDE{thetarad11_rad}{numberPI}{thetadeg11_part1}
MULTIPLY{thetadeg11_part1}{180}{thetadeg11}
$thetadeg11$
xdeftmpc{thetadeg11}
%typeout{tmpc}
ADD{varph1}{theta_hs1}{thetarad12_rad} % angle in radians of the second border of hole 1
DIVIDE{thetarad12_rad}{numberPI}{thetadeg12_part1}
MULTIPLY{thetadeg12_part1}{180}{thetadeg12}
$thetadeg12$
xdeftmpd{thetadeg12}
%typeout{tmpd}
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (tmpc:tmpa) coordinate (a1)
arc[radius=tmpa, start angle=tmpc, end angle= tmpd] --
(tmpd:tmpb) coordinate (a2) arc[radius=tmpb, start angle=tmpd, end angle=
tmpc] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}

answered Nov 10 at 2:20
marmot
82.3k492176
82.3k492176
add a comment |
add a comment |
up vote
0
down vote
documentclass[border=3pt]{standalone}
%usepackage[letterpaper, landscape, margin=0in]{geometry}
%usepackage{graphicx}
%usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
%usepackage{pstricks}
%usepackage{amsmath}
%usepackage[none]{hyphenat}
%usepackage{bigstrut}
% allowdisplaybreaks
%usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
usepackage{xintexpr}
begin{document}
makeatletter
xintdefvar doverh := 0.5; % d/h relation
xintdefvar h := 1.4; % Plate thickness
xintdefvar equivalent_circle_diameter := doverh * h;
% xintdefvar A_part_1 := equivalent_circle_diameter^2;
% 3.141592653589793238462643383279502884197169399375105820974944...
xintdefvar Pi := 3.1415926535897932;
% xintdefvar A_part_2 := Pi * A_part_1;
% xintdefvar Area := A_part_2/4;
xintdefvar Area := Pi * equivalent_circle_diameter^2/4;
%xintdefvar temp1r_h11 := sqrt(Area);
%xintdefvar temp2r_h11 := temp1r_h11/2;
xintdefvar temp2r_h11 := sqrt(Area)/2;
xintdefvar r1 := 6.304640974884; % Central radius of the first hole.
xintdefvar rh11 := r1 - temp2r_h11; % Internal radius of hole 1.
%$xintthefloatexpr[8] rh11relax$
xintdefvar rh12 := r1 + temp2r_h11;% External radius of hole 1
%$xintthefloatexpr[8] rh12relax$
% xintdefvar theta_hs1_part1 := 1/r1;
% xintdefvar theta_hs1 := temp2r_h11 * theta_hs1_part1;
xintdefvar theta_hs1 := temp2r_h11 /r1;
xintdefvar varph1 := 0.187226105362745; % angle of the first hole.
xintdefvar thetarad11_rad := varph1 - theta_hs1; % angle in radians of the
% first border of hole 1
% xintdefvar thetadeg11_part1 := thetarad11_rad/Pi;
% xintdefvar thetadeg11 := 180 * thetadeg11_part1;
xintdefvar thetadeg11 := 180 * thetarad11_rad/Pi;
%$xintthefloatexpr[8] thetadeg11relax$
xintdefvar thetarad12_rad := varph1 + theta_hs1; % angle in radians of the
% second border of hole 1
% xintdefvar thetadeg12_part1 := thetarad12_rad/Pi;
% xintdefvar thetadeg12 := thetadeg12_part1 * 180;
xintdefvar thetadeg12 := 180 * thetarad12_rad/Pi;
%$xintthefloatexpr[8] thetadeg12relax$
newcommandxuse[1]{xintthefloatexpr[8] #1relax}% float rounding to 8 digits
% of precision
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (xuse{thetadeg11}:xuse{rh11}) node (a1) {} arc[radius=xuse{rh11}, start angle=xuse{thetadeg11}, end angle=xuse{thetadeg12}] -- (xuse{thetadeg12}:xuse{rh12}) node (a2) {} arc[radius=xuse{rh12}, start angle=xuse{thetadeg12}, end angle= xuse{thetadeg11}] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
Remark: in the above quantities will be rounded again to 8 digits float precision each time xuse is invoked. It is possible to arrange for this rounding to be done once and for all.

add a comment |
up vote
0
down vote
documentclass[border=3pt]{standalone}
%usepackage[letterpaper, landscape, margin=0in]{geometry}
%usepackage{graphicx}
%usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
%usepackage{pstricks}
%usepackage{amsmath}
%usepackage[none]{hyphenat}
%usepackage{bigstrut}
% allowdisplaybreaks
%usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
usepackage{xintexpr}
begin{document}
makeatletter
xintdefvar doverh := 0.5; % d/h relation
xintdefvar h := 1.4; % Plate thickness
xintdefvar equivalent_circle_diameter := doverh * h;
% xintdefvar A_part_1 := equivalent_circle_diameter^2;
% 3.141592653589793238462643383279502884197169399375105820974944...
xintdefvar Pi := 3.1415926535897932;
% xintdefvar A_part_2 := Pi * A_part_1;
% xintdefvar Area := A_part_2/4;
xintdefvar Area := Pi * equivalent_circle_diameter^2/4;
%xintdefvar temp1r_h11 := sqrt(Area);
%xintdefvar temp2r_h11 := temp1r_h11/2;
xintdefvar temp2r_h11 := sqrt(Area)/2;
xintdefvar r1 := 6.304640974884; % Central radius of the first hole.
xintdefvar rh11 := r1 - temp2r_h11; % Internal radius of hole 1.
%$xintthefloatexpr[8] rh11relax$
xintdefvar rh12 := r1 + temp2r_h11;% External radius of hole 1
%$xintthefloatexpr[8] rh12relax$
% xintdefvar theta_hs1_part1 := 1/r1;
% xintdefvar theta_hs1 := temp2r_h11 * theta_hs1_part1;
xintdefvar theta_hs1 := temp2r_h11 /r1;
xintdefvar varph1 := 0.187226105362745; % angle of the first hole.
xintdefvar thetarad11_rad := varph1 - theta_hs1; % angle in radians of the
% first border of hole 1
% xintdefvar thetadeg11_part1 := thetarad11_rad/Pi;
% xintdefvar thetadeg11 := 180 * thetadeg11_part1;
xintdefvar thetadeg11 := 180 * thetarad11_rad/Pi;
%$xintthefloatexpr[8] thetadeg11relax$
xintdefvar thetarad12_rad := varph1 + theta_hs1; % angle in radians of the
% second border of hole 1
% xintdefvar thetadeg12_part1 := thetarad12_rad/Pi;
% xintdefvar thetadeg12 := thetadeg12_part1 * 180;
xintdefvar thetadeg12 := 180 * thetarad12_rad/Pi;
%$xintthefloatexpr[8] thetadeg12relax$
newcommandxuse[1]{xintthefloatexpr[8] #1relax}% float rounding to 8 digits
% of precision
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (xuse{thetadeg11}:xuse{rh11}) node (a1) {} arc[radius=xuse{rh11}, start angle=xuse{thetadeg11}, end angle=xuse{thetadeg12}] -- (xuse{thetadeg12}:xuse{rh12}) node (a2) {} arc[radius=xuse{rh12}, start angle=xuse{thetadeg12}, end angle= xuse{thetadeg11}] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
Remark: in the above quantities will be rounded again to 8 digits float precision each time xuse is invoked. It is possible to arrange for this rounding to be done once and for all.

add a comment |
up vote
0
down vote
up vote
0
down vote
documentclass[border=3pt]{standalone}
%usepackage[letterpaper, landscape, margin=0in]{geometry}
%usepackage{graphicx}
%usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
%usepackage{pstricks}
%usepackage{amsmath}
%usepackage[none]{hyphenat}
%usepackage{bigstrut}
% allowdisplaybreaks
%usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
usepackage{xintexpr}
begin{document}
makeatletter
xintdefvar doverh := 0.5; % d/h relation
xintdefvar h := 1.4; % Plate thickness
xintdefvar equivalent_circle_diameter := doverh * h;
% xintdefvar A_part_1 := equivalent_circle_diameter^2;
% 3.141592653589793238462643383279502884197169399375105820974944...
xintdefvar Pi := 3.1415926535897932;
% xintdefvar A_part_2 := Pi * A_part_1;
% xintdefvar Area := A_part_2/4;
xintdefvar Area := Pi * equivalent_circle_diameter^2/4;
%xintdefvar temp1r_h11 := sqrt(Area);
%xintdefvar temp2r_h11 := temp1r_h11/2;
xintdefvar temp2r_h11 := sqrt(Area)/2;
xintdefvar r1 := 6.304640974884; % Central radius of the first hole.
xintdefvar rh11 := r1 - temp2r_h11; % Internal radius of hole 1.
%$xintthefloatexpr[8] rh11relax$
xintdefvar rh12 := r1 + temp2r_h11;% External radius of hole 1
%$xintthefloatexpr[8] rh12relax$
% xintdefvar theta_hs1_part1 := 1/r1;
% xintdefvar theta_hs1 := temp2r_h11 * theta_hs1_part1;
xintdefvar theta_hs1 := temp2r_h11 /r1;
xintdefvar varph1 := 0.187226105362745; % angle of the first hole.
xintdefvar thetarad11_rad := varph1 - theta_hs1; % angle in radians of the
% first border of hole 1
% xintdefvar thetadeg11_part1 := thetarad11_rad/Pi;
% xintdefvar thetadeg11 := 180 * thetadeg11_part1;
xintdefvar thetadeg11 := 180 * thetarad11_rad/Pi;
%$xintthefloatexpr[8] thetadeg11relax$
xintdefvar thetarad12_rad := varph1 + theta_hs1; % angle in radians of the
% second border of hole 1
% xintdefvar thetadeg12_part1 := thetarad12_rad/Pi;
% xintdefvar thetadeg12 := thetadeg12_part1 * 180;
xintdefvar thetadeg12 := 180 * thetarad12_rad/Pi;
%$xintthefloatexpr[8] thetadeg12relax$
newcommandxuse[1]{xintthefloatexpr[8] #1relax}% float rounding to 8 digits
% of precision
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (xuse{thetadeg11}:xuse{rh11}) node (a1) {} arc[radius=xuse{rh11}, start angle=xuse{thetadeg11}, end angle=xuse{thetadeg12}] -- (xuse{thetadeg12}:xuse{rh12}) node (a2) {} arc[radius=xuse{rh12}, start angle=xuse{thetadeg12}, end angle= xuse{thetadeg11}] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
Remark: in the above quantities will be rounded again to 8 digits float precision each time xuse is invoked. It is possible to arrange for this rounding to be done once and for all.

documentclass[border=3pt]{standalone}
%usepackage[letterpaper, landscape, margin=0in]{geometry}
%usepackage{graphicx}
%usepackage[spanish]{babel}
usepackage{tikz}
usepackage{pgfplots}
usepackage{pgfmath}
pgfplotsset{width=15cm,compat=1.9}
%usepackage{pstricks}
%usepackage{amsmath}
%usepackage[none]{hyphenat}
%usepackage{bigstrut}
% allowdisplaybreaks
%usepackage{calculator}
usetikzlibrary{calc}
usetikzlibrary{arrows}
usetikzlibrary{trees}
usetikzlibrary{babel}
usepackage{xintexpr}
begin{document}
makeatletter
xintdefvar doverh := 0.5; % d/h relation
xintdefvar h := 1.4; % Plate thickness
xintdefvar equivalent_circle_diameter := doverh * h;
% xintdefvar A_part_1 := equivalent_circle_diameter^2;
% 3.141592653589793238462643383279502884197169399375105820974944...
xintdefvar Pi := 3.1415926535897932;
% xintdefvar A_part_2 := Pi * A_part_1;
% xintdefvar Area := A_part_2/4;
xintdefvar Area := Pi * equivalent_circle_diameter^2/4;
%xintdefvar temp1r_h11 := sqrt(Area);
%xintdefvar temp2r_h11 := temp1r_h11/2;
xintdefvar temp2r_h11 := sqrt(Area)/2;
xintdefvar r1 := 6.304640974884; % Central radius of the first hole.
xintdefvar rh11 := r1 - temp2r_h11; % Internal radius of hole 1.
%$xintthefloatexpr[8] rh11relax$
xintdefvar rh12 := r1 + temp2r_h11;% External radius of hole 1
%$xintthefloatexpr[8] rh12relax$
% xintdefvar theta_hs1_part1 := 1/r1;
% xintdefvar theta_hs1 := temp2r_h11 * theta_hs1_part1;
xintdefvar theta_hs1 := temp2r_h11 /r1;
xintdefvar varph1 := 0.187226105362745; % angle of the first hole.
xintdefvar thetarad11_rad := varph1 - theta_hs1; % angle in radians of the
% first border of hole 1
% xintdefvar thetadeg11_part1 := thetarad11_rad/Pi;
% xintdefvar thetadeg11 := 180 * thetadeg11_part1;
xintdefvar thetadeg11 := 180 * thetarad11_rad/Pi;
%$xintthefloatexpr[8] thetadeg11relax$
xintdefvar thetarad12_rad := varph1 + theta_hs1; % angle in radians of the
% second border of hole 1
% xintdefvar thetadeg12_part1 := thetarad12_rad/Pi;
% xintdefvar thetadeg12 := thetadeg12_part1 * 180;
xintdefvar thetadeg12 := 180 * thetarad12_rad/Pi;
%$xintthefloatexpr[8] thetadeg12relax$
newcommandxuse[1]{xintthefloatexpr[8] #1relax}% float rounding to 8 digits
% of precision
begin{tikzpicture}
draw (0,0) circle [radius=10.75cm];
draw (0,0) circle [radius=4.2cm];
begin{scope}[even odd rule]
draw[fill=gray!20,thick] (0,0) circle [radius=8cm] circle [radius=6cm];
end{scope}
draw[fill=white] (xuse{thetadeg11}:xuse{rh11}) node (a1) {} arc[radius=xuse{rh11}, start angle=xuse{thetadeg11}, end angle=xuse{thetadeg12}] -- (xuse{thetadeg12}:xuse{rh12}) node (a2) {} arc[radius=xuse{rh12}, start angle=xuse{thetadeg12}, end angle= xuse{thetadeg11}] -- cycle;
path (a1) -- (a2) node[inner sep=2pt,circle,fill,pos=0.5] (x1) {};
draw (0,0) -- (x1) node[pos=0.5,fill=white,circle] {$r_1$};
draw (0,0) -- ++(3.5,0);
draw[->] (0:2.5cm) arc (0:10.72:2.5cm) node[pos=0.5,label={0:$varphi_1$}] {};
end{tikzpicture}
end{document}
Remark: in the above quantities will be rounded again to 8 digits float precision each time xuse is invoked. It is possible to arrange for this rounding to be done once and for all.

answered 3 hours ago
jfbu
45.6k65147
45.6k65147
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f459172%2freference-variables-from-package-calculator-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
1
You could probably use
pgfmathinstead ofcalculator, e.g.pgfmathsetmacro{foo}{3*sin(60)}calculates the product of 3 and the sine of 60 degrees and saves it to the macrofoo.– Torbjørn T.
Nov 9 at 17:22