* [NTG-context] Help with Metapopst code
@ 2024-08-28 8:55 Shiv Shankar Dayal
2024-08-28 9:02 ` [NTG-context] " Shiv Shankar Dayal
0 siblings, 1 reply; 6+ messages in thread
From: Shiv Shankar Dayal @ 2024-08-28 8:55 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi,
Consider following code:
vardef polygon_with_side(expr n, s) =
save a, b, r; numeric a, b, r;
a * n = 360; a + 2b = 180; r = s * sind(b) / sind(a);
for i = 0 upto n-1: (0, r) rotated (a * i) -- endfor cycle
enddef;
beginfig(1);
path p; p = polygon_with_side(21, 20);
draw p;
endfig;
bye;
It draws a polygon with 21 sides with radius 20. I understand all of
it except the for loop.
What is (0, r) rotated (a *i) doing?
--
Respect,
Shiv Shankar Dayal
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* [NTG-context] Re: Help with Metapopst code
2024-08-28 8:55 [NTG-context] Help with Metapopst code Shiv Shankar Dayal
@ 2024-08-28 9:02 ` Shiv Shankar Dayal
2024-08-28 10:16 ` Mikael Sundqvist
0 siblings, 1 reply; 6+ messages in thread
From: Shiv Shankar Dayal @ 2024-08-28 9:02 UTC (permalink / raw)
To: mailing list for ConTeXt users
I think it works like (0, r) rotated (a) -- (0, r) rotated (a * 2) --
... (0, r) rotated (a*20) -- cycle
Is my understanding correct? Also, how can I label these vertices in a for loop?
On Wed, Aug 28, 2024 at 2:25 PM Shiv Shankar Dayal
<shivshankar.dayal@gmail.com> wrote:
>
> Hi,
>
> Consider following code:
>
> vardef polygon_with_side(expr n, s) =
> save a, b, r; numeric a, b, r;
> a * n = 360; a + 2b = 180; r = s * sind(b) / sind(a);
> for i = 0 upto n-1: (0, r) rotated (a * i) -- endfor cycle
> enddef;
>
> beginfig(1);
> path p; p = polygon_with_side(21, 20);
> draw p;
> endfig;
> bye;
>
> It draws a polygon with 21 sides with radius 20. I understand all of
> it except the for loop.
>
> What is (0, r) rotated (a *i) doing?
>
> --
> Respect,
> Shiv Shankar Dayal
--
Respect,
Shiv Shankar Dayal
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* [NTG-context] Re: Help with Metapopst code
2024-08-28 9:02 ` [NTG-context] " Shiv Shankar Dayal
@ 2024-08-28 10:16 ` Mikael Sundqvist
2024-08-28 10:23 ` Shiv Shankar Dayal
0 siblings, 1 reply; 6+ messages in thread
From: Mikael Sundqvist @ 2024-08-28 10:16 UTC (permalink / raw)
To: mailing list for ConTeXt users
Hi,
I don't know where you found the code, but the answer to "What is (0,
r) rotated (a *i) doing?" is that it takes the point (0,r) and rotates
it a*i degrees.
For your labeling problem, see the last example of section 2.9 of
https://www.pragma-ade.com/general/manuals/metafun-p.pdf
/Mikael
PS Please do not cross post here and on stackexchange (at least not
without telling).
On Wed, Aug 28, 2024 at 11:12 AM Shiv Shankar Dayal
<shivshankar.dayal@gmail.com> wrote:
>
> I think it works like (0, r) rotated (a) -- (0, r) rotated (a * 2) --
> ... (0, r) rotated (a*20) -- cycle
>
> Is my understanding correct? Also, how can I label these vertices in a for loop?
>
> On Wed, Aug 28, 2024 at 2:25 PM Shiv Shankar Dayal
> <shivshankar.dayal@gmail.com> wrote:
> >
> > Hi,
> >
> > Consider following code:
> >
> > vardef polygon_with_side(expr n, s) =
> > save a, b, r; numeric a, b, r;
> > a * n = 360; a + 2b = 180; r = s * sind(b) / sind(a);
> > for i = 0 upto n-1: (0, r) rotated (a * i) -- endfor cycle
> > enddef;
> >
> > beginfig(1);
> > path p; p = polygon_with_side(21, 20);
> > draw p;
> > endfig;
> > bye;
> >
> > It draws a polygon with 21 sides with radius 20. I understand all of
> > it except the for loop.
> >
> > What is (0, r) rotated (a *i) doing?
> >
> > --
> > Respect,
> > Shiv Shankar Dayal
>
>
>
> --
> Respect,
> Shiv Shankar Dayal
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* [NTG-context] Re: Help with Metapopst code
2024-08-28 10:16 ` Mikael Sundqvist
@ 2024-08-28 10:23 ` Shiv Shankar Dayal
2024-08-28 10:34 ` Wolfgang Schuster
2024-08-28 10:37 ` Mikael Sundqvist
0 siblings, 2 replies; 6+ messages in thread
From: Shiv Shankar Dayal @ 2024-08-28 10:23 UTC (permalink / raw)
To: mailing list for ConTeXt users
> I don't know where you found the code, but the answer to "What is (0,
> r) rotated (a *i) doing?" is that it takes the point (0,r) and rotates
> it a*i degrees.
I do not understand the concept of rotating a point. It is rotated with respect
to what reference?
>
> For your labeling problem, see the last example of section 2.9 of
>
> https://www.pragma-ade.com/general/manuals/metafun-p.pdf
>
Thanks, I am reading that.
> /Mikael
>
> PS Please do not cross post here and on stackexchange (at least not
> without telling).
>
I will keep this in mind.
--
Respect,
Shiv Shankar Dayal
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* [NTG-context] Re: Help with Metapopst code
2024-08-28 10:23 ` Shiv Shankar Dayal
@ 2024-08-28 10:34 ` Wolfgang Schuster
2024-08-28 10:37 ` Mikael Sundqvist
1 sibling, 0 replies; 6+ messages in thread
From: Wolfgang Schuster @ 2024-08-28 10:34 UTC (permalink / raw)
To: mailing list for ConTeXt users, Shiv Shankar Dayal
Shiv Shankar Dayal schrieb am 28.08.2024 um 12:23:
>> I don't know where you found the code, but the answer to "What is (0,
>> r) rotated (a *i) doing?" is that it takes the point (0,r) and rotates
>> it a*i degrees.
>
> I do not understand the concept of rotating a point. It is rotated with respect
> to what reference?
You rotate around a point with the x and y coordinates 0.
The blue dot shows the point with the coordinates 0. The green dot is
rotated around this point.
\starttext
\startMPcode
drawdot (0,0) withpen pencircle scaled 5mm withcolor blue;
draw fullsquare scaled (4cm) withcolor red;
\stopMPcode
\startMPcode
drawdot (0,0) withpen pencircle scaled 5mm withcolor blue;
drawdot (1.5cm,0) withpen pencircle scaled 5mm withcolor green;
draw fullsquare scaled (4cm) withcolor red;
\stopMPcode
\startMPcode
drawdot (0,0) withpen pencircle scaled 5mm withcolor blue;
drawdot (1.5cm,0) rotated (30) withpen pencircle scaled 5mm withcolor green;
draw fullsquare scaled (4cm) withcolor red;
\stopMPcode
\startMPcode
drawdot (0,0) withpen pencircle scaled 5mm withcolor blue;
drawdot (1.5cm,0) rotated (60) withpen pencircle scaled 5mm withcolor green;
draw fullsquare scaled (4cm) withcolor red;
\stopMPcode
\startMPcode
drawdot (0,0) withpen pencircle scaled 5mm withcolor blue;
drawdot (1.5cm,0) rotated (90) withpen pencircle scaled 5mm withcolor green;
draw fullsquare scaled (4cm) withcolor red;
\stopMPcode
\stoptext
Wolfgang
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
* [NTG-context] Re: Help with Metapopst code
2024-08-28 10:23 ` Shiv Shankar Dayal
2024-08-28 10:34 ` Wolfgang Schuster
@ 2024-08-28 10:37 ` Mikael Sundqvist
1 sibling, 0 replies; 6+ messages in thread
From: Mikael Sundqvist @ 2024-08-28 10:37 UTC (permalink / raw)
To: mailing list for ConTeXt users
It is rotated with respect to the origin (that is (0,0)).
If you want to rotate around another point you have rotatedaround.
/Mikael
On Wed, Aug 28, 2024 at 12:27 PM Shiv Shankar Dayal
<shivshankar.dayal@gmail.com> wrote:
>
> > I don't know where you found the code, but the answer to "What is (0,
> > r) rotated (a *i) doing?" is that it takes the point (0,r) and rotates
> > it a*i degrees.
>
> I do not understand the concept of rotating a point. It is rotated with respect
> to what reference?
>
> >
> > For your labeling problem, see the last example of section 2.9 of
> >
> > https://www.pragma-ade.com/general/manuals/metafun-p.pdf
> >
>
> Thanks, I am reading that.
>
> > /Mikael
> >
> > PS Please do not cross post here and on stackexchange (at least not
> > without telling).
> >
>
> I will keep this in mind.
>
> --
> Respect,
> Shiv Shankar Dayal
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
>
> maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
> webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
> archive : https://github.com/contextgarden/context
> wiki : https://wiki.contextgarden.net
> ___________________________________________________________________________________
___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!
maillist : ntg-context@ntg.nl / https://mailman.ntg.nl/mailman3/lists/ntg-context.ntg.nl
webpage : https://www.pragma-ade.nl / https://context.aanhet.net (mirror)
archive : https://github.com/contextgarden/context
wiki : https://wiki.contextgarden.net
___________________________________________________________________________________
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-08-28 10:39 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-08-28 8:55 [NTG-context] Help with Metapopst code Shiv Shankar Dayal
2024-08-28 9:02 ` [NTG-context] " Shiv Shankar Dayal
2024-08-28 10:16 ` Mikael Sundqvist
2024-08-28 10:23 ` Shiv Shankar Dayal
2024-08-28 10:34 ` Wolfgang Schuster
2024-08-28 10:37 ` Mikael Sundqvist
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).