Draw arc using relative coordinates with tikz
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
My quetion may be dumb, but consider that I am very new with Tikz.
I am trying to draw a tower similar to Eifel using the following code
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
deftower#1% #1=position
draw[thick]
%... tower arc
#1++(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
tower(0,0) % this works!
tower(0,20) % this is messy!
endtikzpicture
enddocument
It works fine when I do tower(0,0)
, but becomes messy when I use any other coordinate. What am I doing wrong here?
tikz-pgf
add a comment |
up vote
2
down vote
favorite
My quetion may be dumb, but consider that I am very new with Tikz.
I am trying to draw a tower similar to Eifel using the following code
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
deftower#1% #1=position
draw[thick]
%... tower arc
#1++(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
tower(0,0) % this works!
tower(0,20) % this is messy!
endtikzpicture
enddocument
It works fine when I do tower(0,0)
, but becomes messy when I use any other coordinate. What am I doing wrong here?
tikz-pgf
1
Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with adocumentclass
command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
– Andrew
6 hours ago
Yes, sure! I will edit my question. Thank you, @Andrew
– Brasil
6 hours ago
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
My quetion may be dumb, but consider that I am very new with Tikz.
I am trying to draw a tower similar to Eifel using the following code
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
deftower#1% #1=position
draw[thick]
%... tower arc
#1++(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
tower(0,0) % this works!
tower(0,20) % this is messy!
endtikzpicture
enddocument
It works fine when I do tower(0,0)
, but becomes messy when I use any other coordinate. What am I doing wrong here?
tikz-pgf
My quetion may be dumb, but consider that I am very new with Tikz.
I am trying to draw a tower similar to Eifel using the following code
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
deftower#1% #1=position
draw[thick]
%... tower arc
#1++(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
tower(0,0) % this works!
tower(0,20) % this is messy!
endtikzpicture
enddocument
It works fine when I do tower(0,0)
, but becomes messy when I use any other coordinate. What am I doing wrong here?
tikz-pgf
tikz-pgf
edited 6 hours ago
asked 6 hours ago
Brasil
186112
186112
1
Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with adocumentclass
command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
– Andrew
6 hours ago
Yes, sure! I will edit my question. Thank you, @Andrew
– Brasil
6 hours ago
add a comment |
1
Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with adocumentclass
command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.
– Andrew
6 hours ago
Yes, sure! I will edit my question. Thank you, @Andrew
– Brasil
6 hours ago
1
1
Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a
documentclass
command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.– Andrew
6 hours ago
Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a
documentclass
command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.– Andrew
6 hours ago
Yes, sure! I will edit my question. Thank you, @Andrew
– Brasil
6 hours ago
Yes, sure! I will edit my question. Thank you, @Andrew
– Brasil
6 hours ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
4
down vote
accepted
It becomes messy because ++
does not add these coordinates, you might use calc
for that if there was not a (IMHO) much more elegant way: pic
s.
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
tikzsetpics/.cd,
tower/.style=code=
draw[thick]
(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
path (0,0) pictower (0,20) pictower;
endtikzpicture
enddocument
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
4
down vote
accepted
It becomes messy because ++
does not add these coordinates, you might use calc
for that if there was not a (IMHO) much more elegant way: pic
s.
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
tikzsetpics/.cd,
tower/.style=code=
draw[thick]
(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
path (0,0) pictower (0,20) pictower;
endtikzpicture
enddocument
add a comment |
up vote
4
down vote
accepted
It becomes messy because ++
does not add these coordinates, you might use calc
for that if there was not a (IMHO) much more elegant way: pic
s.
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
tikzsetpics/.cd,
tower/.style=code=
draw[thick]
(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
path (0,0) pictower (0,20) pictower;
endtikzpicture
enddocument
add a comment |
up vote
4
down vote
accepted
up vote
4
down vote
accepted
It becomes messy because ++
does not add these coordinates, you might use calc
for that if there was not a (IMHO) much more elegant way: pic
s.
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
tikzsetpics/.cd,
tower/.style=code=
draw[thick]
(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
path (0,0) pictower (0,20) pictower;
endtikzpicture
enddocument
It becomes messy because ++
does not add these coordinates, you might use calc
for that if there was not a (IMHO) much more elegant way: pic
s.
documentclassarticle
usepackagetikz
usetikzlibraryshapes.geometric
usetikzlibraryshapes.misc
begindocument
tikzsetpics/.cd,
tower/.style=code=
draw[thick]
(-towerar,0)
arc(180:0:towerar)--
(towerwd/2,0) to[out=120,in=270]
(0,towerht) to[out=270,in=60]
(-towerwd/2,0)--
cycle
;
begintikzpicture[x=(1mm,0),y=(0,1mm)]
deftowerwd5 % tower width
deftowerht10 % tower height
deftowerar4*towerwd/10 % tower arc radius
path (0,0) pictower (0,20) pictower;
endtikzpicture
enddocument
answered 6 hours ago
marmot
73.7k479154
73.7k479154
add a comment |
add a comment |
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
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f459391%2fdraw-arc-using-relative-coordinates-with-tikz%23new-answer', 'question_page');
);
Post as a guest
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
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
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
1
Welcome to TeX.SX! Can you please expand the code snippet that you have posted to a full minimal working example. It is much easier to help you if we can start with some compilable code that illustrates your problem. A MWE should start with a
documentclass
command, include any necessary packages and be as small as possible to demonstrate your problem. At the moment we have to guess what packages etc you are using before we can compile your code.– Andrew
6 hours ago
Yes, sure! I will edit my question. Thank you, @Andrew
– Brasil
6 hours ago