METAPOST equivalent to TikZ polar coordinates?
When drawing with TikZ, I find sometime convenient to use polar coordinates (angle:distance), as in this MWE
documentclassarticle
usepackagetikz
begindocument
begintikzpicture
[pole/.style=circle,draw=gray,fill=gray,thick,text width=2cm, align=center]
node[pole] (eur) at (60:3cm) Europe;
node[pole] (afr) at (300:3cm) Afrique;
node[pole] (amq) at (180:3cm) Amérique;
endtikzpicture
enddocument
How can I get a similar effect using METAPOST ? I could'nt find direct answer in the manual. I am quite sure one can achieve the same with a good knowledge of geometry. It would be good for scripting.
So far, my METAPOST equivalent would be
beginfig(1);
u:=1cm ;
label(btex Amérique etex, (-3u,0) ) ;
label(btex Europe etex, (u,2u) ) ;
label(btex Afrique etex, (u,-2u) ) ;
endfig ;
end
Of course this are not polar coordinates and I am even not sure angles are the same as in TikZ.
Since I am not a scientist, I would be glad to have some explanation if some geometry knowledge is required.
metapost
add a comment |
When drawing with TikZ, I find sometime convenient to use polar coordinates (angle:distance), as in this MWE
documentclassarticle
usepackagetikz
begindocument
begintikzpicture
[pole/.style=circle,draw=gray,fill=gray,thick,text width=2cm, align=center]
node[pole] (eur) at (60:3cm) Europe;
node[pole] (afr) at (300:3cm) Afrique;
node[pole] (amq) at (180:3cm) Amérique;
endtikzpicture
enddocument
How can I get a similar effect using METAPOST ? I could'nt find direct answer in the manual. I am quite sure one can achieve the same with a good knowledge of geometry. It would be good for scripting.
So far, my METAPOST equivalent would be
beginfig(1);
u:=1cm ;
label(btex Amérique etex, (-3u,0) ) ;
label(btex Europe etex, (u,2u) ) ;
label(btex Afrique etex, (u,-2u) ) ;
endfig ;
end
Of course this are not polar coordinates and I am even not sure angles are the same as in TikZ.
Since I am not a scientist, I would be glad to have some explanation if some geometry knowledge is required.
metapost
You can easily convert r and φ to cartesian coordinates using the prescription (x,y) = (r*cos(φ),r*sin(φ))
– Henri Menke
Nov 15 '18 at 20:21
add a comment |
When drawing with TikZ, I find sometime convenient to use polar coordinates (angle:distance), as in this MWE
documentclassarticle
usepackagetikz
begindocument
begintikzpicture
[pole/.style=circle,draw=gray,fill=gray,thick,text width=2cm, align=center]
node[pole] (eur) at (60:3cm) Europe;
node[pole] (afr) at (300:3cm) Afrique;
node[pole] (amq) at (180:3cm) Amérique;
endtikzpicture
enddocument
How can I get a similar effect using METAPOST ? I could'nt find direct answer in the manual. I am quite sure one can achieve the same with a good knowledge of geometry. It would be good for scripting.
So far, my METAPOST equivalent would be
beginfig(1);
u:=1cm ;
label(btex Amérique etex, (-3u,0) ) ;
label(btex Europe etex, (u,2u) ) ;
label(btex Afrique etex, (u,-2u) ) ;
endfig ;
end
Of course this are not polar coordinates and I am even not sure angles are the same as in TikZ.
Since I am not a scientist, I would be glad to have some explanation if some geometry knowledge is required.
metapost
When drawing with TikZ, I find sometime convenient to use polar coordinates (angle:distance), as in this MWE
documentclassarticle
usepackagetikz
begindocument
begintikzpicture
[pole/.style=circle,draw=gray,fill=gray,thick,text width=2cm, align=center]
node[pole] (eur) at (60:3cm) Europe;
node[pole] (afr) at (300:3cm) Afrique;
node[pole] (amq) at (180:3cm) Amérique;
endtikzpicture
enddocument
How can I get a similar effect using METAPOST ? I could'nt find direct answer in the manual. I am quite sure one can achieve the same with a good knowledge of geometry. It would be good for scripting.
So far, my METAPOST equivalent would be
beginfig(1);
u:=1cm ;
label(btex Amérique etex, (-3u,0) ) ;
label(btex Europe etex, (u,2u) ) ;
label(btex Afrique etex, (u,-2u) ) ;
endfig ;
end
Of course this are not polar coordinates and I am even not sure angles are the same as in TikZ.
Since I am not a scientist, I would be glad to have some explanation if some geometry knowledge is required.
metapost
metapost
asked Nov 15 '18 at 20:02
sztrukssztruks
1,6541817
1,6541817
You can easily convert r and φ to cartesian coordinates using the prescription (x,y) = (r*cos(φ),r*sin(φ))
– Henri Menke
Nov 15 '18 at 20:21
add a comment |
You can easily convert r and φ to cartesian coordinates using the prescription (x,y) = (r*cos(φ),r*sin(φ))
– Henri Menke
Nov 15 '18 at 20:21
You can easily convert r and φ to cartesian coordinates using the prescription (x,y) = (r*cos(φ),r*sin(φ))
– Henri Menke
Nov 15 '18 at 20:21
You can easily convert r and φ to cartesian coordinates using the prescription (x,y) = (r*cos(φ),r*sin(φ))
– Henri Menke
Nov 15 '18 at 20:21
add a comment |
1 Answer
1
active
oldest
votes
Use the dir
operator. From the MetaPost manual:
Here with MetaFun in ConTeXt:
startMPpage
u:=1cm ;
label(btex Amérique etex, 3u*dir 60) ;
label(btex Europe etex, 3u*dir 300) ;
label(btex Afrique etex, 3u*dir 180) ;
stopMPpage
Thanks. I wouldn't have been able to find this on my own. It's been too long since I learnt what does cos and sin reflect… But now I see the point.
– sztruks
Nov 15 '18 at 21:24
There is also an operatorangle
that does the opposite, so thatangle dir 60
should return60
. A bit likeatan2
in other languages.
– Thruston
Nov 15 '18 at 21:42
As a matter of style you could also write3 dir 60 scaled u
.
– Thruston
Nov 15 '18 at 21:47
@Thrustonangle
does exactly performatan2
(at least indouble
anddecimal
mode) github.com/TeX-Live/texlive-source/blob/…
– Henri Menke
Nov 15 '18 at 21:50
Yes quite right. In my old-fashioned British way, when I say “a bit like” I mean “exactly the same as”…
– Thruston
Nov 15 '18 at 21:55
add a comment |
Your Answer
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
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%2f460188%2fmetapost-equivalent-to-tikz-polar-coordinates%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Use the dir
operator. From the MetaPost manual:
Here with MetaFun in ConTeXt:
startMPpage
u:=1cm ;
label(btex Amérique etex, 3u*dir 60) ;
label(btex Europe etex, 3u*dir 300) ;
label(btex Afrique etex, 3u*dir 180) ;
stopMPpage
Thanks. I wouldn't have been able to find this on my own. It's been too long since I learnt what does cos and sin reflect… But now I see the point.
– sztruks
Nov 15 '18 at 21:24
There is also an operatorangle
that does the opposite, so thatangle dir 60
should return60
. A bit likeatan2
in other languages.
– Thruston
Nov 15 '18 at 21:42
As a matter of style you could also write3 dir 60 scaled u
.
– Thruston
Nov 15 '18 at 21:47
@Thrustonangle
does exactly performatan2
(at least indouble
anddecimal
mode) github.com/TeX-Live/texlive-source/blob/…
– Henri Menke
Nov 15 '18 at 21:50
Yes quite right. In my old-fashioned British way, when I say “a bit like” I mean “exactly the same as”…
– Thruston
Nov 15 '18 at 21:55
add a comment |
Use the dir
operator. From the MetaPost manual:
Here with MetaFun in ConTeXt:
startMPpage
u:=1cm ;
label(btex Amérique etex, 3u*dir 60) ;
label(btex Europe etex, 3u*dir 300) ;
label(btex Afrique etex, 3u*dir 180) ;
stopMPpage
Thanks. I wouldn't have been able to find this on my own. It's been too long since I learnt what does cos and sin reflect… But now I see the point.
– sztruks
Nov 15 '18 at 21:24
There is also an operatorangle
that does the opposite, so thatangle dir 60
should return60
. A bit likeatan2
in other languages.
– Thruston
Nov 15 '18 at 21:42
As a matter of style you could also write3 dir 60 scaled u
.
– Thruston
Nov 15 '18 at 21:47
@Thrustonangle
does exactly performatan2
(at least indouble
anddecimal
mode) github.com/TeX-Live/texlive-source/blob/…
– Henri Menke
Nov 15 '18 at 21:50
Yes quite right. In my old-fashioned British way, when I say “a bit like” I mean “exactly the same as”…
– Thruston
Nov 15 '18 at 21:55
add a comment |
Use the dir
operator. From the MetaPost manual:
Here with MetaFun in ConTeXt:
startMPpage
u:=1cm ;
label(btex Amérique etex, 3u*dir 60) ;
label(btex Europe etex, 3u*dir 300) ;
label(btex Afrique etex, 3u*dir 180) ;
stopMPpage
Use the dir
operator. From the MetaPost manual:
Here with MetaFun in ConTeXt:
startMPpage
u:=1cm ;
label(btex Amérique etex, 3u*dir 60) ;
label(btex Europe etex, 3u*dir 300) ;
label(btex Afrique etex, 3u*dir 180) ;
stopMPpage
answered Nov 15 '18 at 20:16
Henri MenkeHenri Menke
76.9k8168283
76.9k8168283
Thanks. I wouldn't have been able to find this on my own. It's been too long since I learnt what does cos and sin reflect… But now I see the point.
– sztruks
Nov 15 '18 at 21:24
There is also an operatorangle
that does the opposite, so thatangle dir 60
should return60
. A bit likeatan2
in other languages.
– Thruston
Nov 15 '18 at 21:42
As a matter of style you could also write3 dir 60 scaled u
.
– Thruston
Nov 15 '18 at 21:47
@Thrustonangle
does exactly performatan2
(at least indouble
anddecimal
mode) github.com/TeX-Live/texlive-source/blob/…
– Henri Menke
Nov 15 '18 at 21:50
Yes quite right. In my old-fashioned British way, when I say “a bit like” I mean “exactly the same as”…
– Thruston
Nov 15 '18 at 21:55
add a comment |
Thanks. I wouldn't have been able to find this on my own. It's been too long since I learnt what does cos and sin reflect… But now I see the point.
– sztruks
Nov 15 '18 at 21:24
There is also an operatorangle
that does the opposite, so thatangle dir 60
should return60
. A bit likeatan2
in other languages.
– Thruston
Nov 15 '18 at 21:42
As a matter of style you could also write3 dir 60 scaled u
.
– Thruston
Nov 15 '18 at 21:47
@Thrustonangle
does exactly performatan2
(at least indouble
anddecimal
mode) github.com/TeX-Live/texlive-source/blob/…
– Henri Menke
Nov 15 '18 at 21:50
Yes quite right. In my old-fashioned British way, when I say “a bit like” I mean “exactly the same as”…
– Thruston
Nov 15 '18 at 21:55
Thanks. I wouldn't have been able to find this on my own. It's been too long since I learnt what does cos and sin reflect… But now I see the point.
– sztruks
Nov 15 '18 at 21:24
Thanks. I wouldn't have been able to find this on my own. It's been too long since I learnt what does cos and sin reflect… But now I see the point.
– sztruks
Nov 15 '18 at 21:24
There is also an operator
angle
that does the opposite, so that angle dir 60
should return 60
. A bit like atan2
in other languages.– Thruston
Nov 15 '18 at 21:42
There is also an operator
angle
that does the opposite, so that angle dir 60
should return 60
. A bit like atan2
in other languages.– Thruston
Nov 15 '18 at 21:42
As a matter of style you could also write
3 dir 60 scaled u
.– Thruston
Nov 15 '18 at 21:47
As a matter of style you could also write
3 dir 60 scaled u
.– Thruston
Nov 15 '18 at 21:47
@Thruston
angle
does exactly perform atan2
(at least in double
and decimal
mode) github.com/TeX-Live/texlive-source/blob/…– Henri Menke
Nov 15 '18 at 21:50
@Thruston
angle
does exactly perform atan2
(at least in double
and decimal
mode) github.com/TeX-Live/texlive-source/blob/…– Henri Menke
Nov 15 '18 at 21:50
Yes quite right. In my old-fashioned British way, when I say “a bit like” I mean “exactly the same as”…
– Thruston
Nov 15 '18 at 21:55
Yes quite right. In my old-fashioned British way, when I say “a bit like” I mean “exactly the same as”…
– Thruston
Nov 15 '18 at 21:55
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.
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%2f460188%2fmetapost-equivalent-to-tikz-polar-coordinates%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
You can easily convert r and φ to cartesian coordinates using the prescription (x,y) = (r*cos(φ),r*sin(φ))
– Henri Menke
Nov 15 '18 at 20:21