ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Metapost Animation of Sine
@ 2021-07-21 14:08 Jeroen
  2021-07-21 15:54 ` Fabrice L
  0 siblings, 1 reply; 7+ messages in thread
From: Jeroen @ 2021-07-21 14:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1135 bytes --]

I use this small animation to enlarge a circle


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
    \startMPcode
    path p;
    numeric n, u;
    u := 1cm;
    n:=\recurselevel*u;
    p := fullcircle scaled n;
    draw p;
    \stopMPcode
  \stopframe}}
\stopanimation
\stoptext


This I use to draw a sine


\starttext
\startMPcode
  draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
(i/360*1.5cm,0.9cm*(sind(i)))endfor;
\stopMPcode
\stoptext


When I put it together to animate the sine as following, it does not
entirely create the sine animation I am looking for


\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startanimation[menu=yes,framerate=10]
\dorecurse{7}{\expanded
  {\startframe
    \startMPcode
    path p;
    numeric n, u;
    u := 1cm;
    n:=\recurselevel*u;
    p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
(i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
    draw p;
    \stopMPcode
    \stopframe}}
\stopanimation
\stoptext


What better way can I create a sine animation with Metapost?

[-- Attachment #1.2: Type: text/html, Size: 1817 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Metapost Animation of Sine
  2021-07-21 14:08 Metapost Animation of Sine Jeroen
@ 2021-07-21 15:54 ` Fabrice L
  2021-07-21 17:44   ` Jeroen
  0 siblings, 1 reply; 7+ messages in thread
From: Fabrice L @ 2021-07-21 15:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 1843 bytes --]

Hi,

> Le 21 juill. 2021 à 10:08, Jeroen <contextntg@gmail.com> a écrit :
> 
> I use this small animation to enlarge a circle
> 
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
>     \startMPcode
>     path p;
>     numeric n, u;
>     u := 1cm;
>     n:=\recurselevel*u;
>     p := fullcircle scaled n;
>     draw p;
>     \stopMPcode
>   \stopframe}}
> \stopanimation
> \stoptext
> 
> 
> This I use to draw a sine
> 
> 
> \starttext
> \startMPcode
>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> \stopMPcode
> \stoptext
> 
> 
> When I put it together to animate the sine as following, it does not entirely create the sine animation I am looking for
> 
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
>     \startMPcode
>     path p;
>     numeric n, u;
>     u := 1cm;
>     n:=\recurselevel*u;
>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>     draw p;
>     \stopMPcode
>     \stopframe}}
> \stopanimation
> \stoptext
> 
> 
> What better way can I create a sine animation with Metapost?
>  
> 

Here is another way to do your animation. This is doing something, but I guess not what you want. Could you describe what do you have in mind ?

\starttext
\dorecurse{7}{ % 3180
\startMPpage
	myvariable := #1 ;
	path p;
    numeric n, u;
    u := 1cm;
    n:=myvariable*u;
    p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
    draw p;
\stopMPpage
}
\stoptext

Fabrice.



[-- Attachment #1.2: Type: text/html, Size: 3873 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Metapost Animation of Sine
  2021-07-21 15:54 ` Fabrice L
@ 2021-07-21 17:44   ` Jeroen
  2021-07-21 21:26     ` Otared Kavian
  2021-07-21 21:45     ` Otared Kavian
  0 siblings, 2 replies; 7+ messages in thread
From: Jeroen @ 2021-07-21 17:44 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 2656 bytes --]

I am looking for a sine animation as the one file f.pdf on this site

http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm

Jeroen

Op wo 21 jul. 2021 om 17:54 schreef Fabrice L <fabrice.alpha@gmail.com>:

> Hi,
>
> Le 21 juill. 2021 à 10:08, Jeroen <contextntg@gmail.com> a écrit :
>
> I use this small animation to enlarge a circle
>
>
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
>     \startMPcode
>     path p;
>     numeric n, u;
>     u := 1cm;
>     n:=\recurselevel*u;
>     p := fullcircle scaled n;
>     draw p;
>     \stopMPcode
>   \stopframe}}
> \stopanimation
> \stoptext
>
>
> This I use to draw a sine
>
>
> \starttext
> \startMPcode
>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> \stopMPcode
> \stoptext
>
>
> When I put it together to animate the sine as following, it does not
> entirely create the sine animation I am looking for
>
>
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startanimation[menu=yes,framerate=10]
> \dorecurse{7}{\expanded
>   {\startframe
>     \startMPcode
>     path p;
>     numeric n, u;
>     u := 1cm;
>     n:=\recurselevel*u;
>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>     draw p;
>     \stopMPcode
>     \stopframe}}
> \stopanimation
> \stoptext
>
>
> What better way can I create a sine animation with Metapost?
>
>
>
>
> Here is another way to do your animation. This is doing something, but I
> guess not what you want. Could you describe what do you have in mind ?
>
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
> myvariable := #1 ;
> path p;
>     numeric n, u;
>     u := 1cm;
>     n:=myvariable*u;
>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>     draw p;
> \stopMPpage
> }
> \stoptext
>
> Fabrice.
>
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 4490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Metapost Animation of Sine
  2021-07-21 17:44   ` Jeroen
@ 2021-07-21 21:26     ` Otared Kavian
  2021-07-22 12:28       ` Jeroen
  2021-07-21 21:45     ` Otared Kavian
  1 sibling, 1 reply; 7+ messages in thread
From: Otared Kavian @ 2021-07-21 21:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi, 

I wonder whether something like the following is what you are looking for:

% begin wave-sine.tex
\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startTEXpage[offset=2pt]
\startanimation[menu=yes,framerate=10]
	\dorecurse{100}{\expanded
		{\startframe
		\startMPcode
			numeric u, omega, mylength, tt ;
			u := 2cm ;
			omega := 4 ;
			mylength := 3.141596 ;
			tt := \recurselevel ;
			path p ;
			p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 : 
							.. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
					endfor ;
			draw p withpen pencircle scaled .5pt withcolor darkred ;
		\stopMPcode
		\stopframe}
		}
\stopanimation
\stopTEXpage
\stoptext
% end wave-sine.tex

Best regards: OK

> On 21 Jul 2021, at 19:44, Jeroen <contextntg@gmail.com> wrote:
> 
> I am looking for a sine animation as the one file f.pdf on this site
> 
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> 
> Jeroen
> 
> Op wo 21 jul. 2021 om 17:54 schreef Fabrice L <fabrice.alpha@gmail.com>:
> Hi,
> 
>> Le 21 juill. 2021 à 10:08, Jeroen <contextntg@gmail.com> a écrit :
>> 
>> I use this small animation to enlarge a circle
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>>     \startMPcode
>>     path p;
>>     numeric n, u;
>>     u := 1cm;
>>     n:=\recurselevel*u;
>>     p := fullcircle scaled n;
>>     draw p;
>>     \stopMPcode
>>   \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> This I use to draw a sine
>> 
>> 
>> \starttext
>> \startMPcode
>>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i)))endfor;
>> \stopMPcode
>> \stoptext
>> 
>> 
>> When I put it together to animate the sine as following, it does not entirely create the sine animation I am looking for
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>>     \startMPcode
>>     path p;
>>     numeric n, u;
>>     u := 1cm;
>>     n:=\recurselevel*u;
>>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>>     draw p;
>>     \stopMPcode
>>     \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> What better way can I create a sine animation with Metapost?
>>  
>> 
> 
> Here is another way to do your animation. This is doing something, but I guess not what you want. Could you describe what do you have in mind ?
> 
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
> 	myvariable := #1 ;
> 	path p;
>     numeric n, u;
>     u := 1cm;
>     n:=myvariable*u;
>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>     draw p;
> \stopMPpage
> }
> \stoptext
> 
> Fabrice.
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Metapost Animation of Sine
  2021-07-21 17:44   ` Jeroen
  2021-07-21 21:26     ` Otared Kavian
@ 2021-07-21 21:45     ` Otared Kavian
  1 sibling, 0 replies; 7+ messages in thread
From: Otared Kavian @ 2021-07-21 21:45 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hi,

Adding to my previous message, if you are looking for an animation of the wave equation for a string with fixed endpoints, one has to use something like the following:

% begin wave-sine-string.tex
\usemodule[animation]
\setupinteraction[state=start]
\starttext
\startTEXpage[offset=2pt]
\startanimation[menu=yes,framerate=10]
	\dorecurse{101}{\expanded
		{\startframe
		\startMPcode
			numeric u, omega, mylength, tt, N ;
			u := 2cm ;
			omega := 4 ;
			mylength := 3.141596 ;
			tt := \recurselevel - 1 ;
			N := 500 ; % number of steps
			path p ;
			p := (0u,0u) for i = 1 upto N : 
							-- (((mylength/N)*i)*u,cos(omega*(mylength/N)*tt)*sin(omega*(mylength/N)*i)*u) 
					endfor ;
			draw p withpen pencircle scaled .5pt withcolor darkred ;
		\stopMPcode
		\stopframe}
		}
\stopanimation
\stopTEXpage
\stoptext
% end wave-sine-string.tex

Best regards: OK

> On 21 Jul 2021, at 19:44, Jeroen <contextntg@gmail.com> wrote:
> 
> I am looking for a sine animation as the one file f.pdf on this site
> 
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> 
> Jeroen
> 
> Op wo 21 jul. 2021 om 17:54 schreef Fabrice L <fabrice.alpha@gmail.com>:
> Hi,
> 
>> Le 21 juill. 2021 à 10:08, Jeroen <contextntg@gmail.com> a écrit :
>> 
>> I use this small animation to enlarge a circle
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>>     \startMPcode
>>     path p;
>>     numeric n, u;
>>     u := 1cm;
>>     n:=\recurselevel*u;
>>     p := fullcircle scaled n;
>>     draw p;
>>     \stopMPcode
>>   \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> This I use to draw a sine
>> 
>> 
>> \starttext
>> \startMPcode
>>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i)))endfor;
>> \stopMPcode
>> \stoptext
>> 
>> 
>> When I put it together to animate the sine as following, it does not entirely create the sine animation I am looking for
>> 
>> 
>> \usemodule[animation]
>> \setupinteraction[state=start]
>> \starttext
>> \startanimation[menu=yes,framerate=10]
>> \dorecurse{7}{\expanded
>>   {\startframe
>>     \startMPcode
>>     path p;
>>     numeric n, u;
>>     u := 1cm;
>>     n:=\recurselevel*u;
>>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>>     draw p;
>>     \stopMPcode
>>     \stopframe}}
>> \stopanimation
>> \stoptext
>> 
>> 
>> What better way can I create a sine animation with Metapost?
>>  
>> 
> 
> Here is another way to do your animation. This is doing something, but I guess not what you want. Could you describe what do you have in mind ?
> 
> \starttext
> \dorecurse{7}{ % 3180
> \startMPpage
> 	myvariable := #1 ;
> 	path p;
>     numeric n, u;
>     u := 1cm;
>     n:=myvariable*u;
>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
>     draw p;
> \stopMPpage
> }
> \stoptext
> 
> Fabrice.
> 
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Metapost Animation of Sine
  2021-07-21 21:26     ` Otared Kavian
@ 2021-07-22 12:28       ` Jeroen
  2021-07-22 20:38         ` Otared Kavian
  0 siblings, 1 reply; 7+ messages in thread
From: Jeroen @ 2021-07-22 12:28 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 6022 bytes --]

Hi, both solutions are great! This is what I had in mind, a rolling sine.
Is there a way to get the same result with the Tikz module?

\usemodule[animation]
\setupinteraction[state=start]

\starttext

\input tufte

\framed{
\startanimation[menu=yes,framerate=40]
\dorecurse{50}{\expanded
{\startframe
\startMPcode
numeric u, omega, mylength, tt ;
u := 2cm ;
omega := 4 ;
mylength := 3.141596 ;
tt := \recurselevel ;
path p ;
p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 :
.. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u)
endfor ;
draw p withpen pencircle scaled .5pt withcolor darkred ;
\stopMPcode
\stopframe}
}
\stopanimation
}

\stoptext

Op wo 21 jul. 2021 om 23:26 schreef Otared Kavian <otared@gmail.com>:

> Hi,
>
> I wonder whether something like the following is what you are looking for:
>
> % begin wave-sine.tex
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startTEXpage[offset=2pt]
> \startanimation[menu=yes,framerate=10]
>         \dorecurse{100}{\expanded
>                 {\startframe
>                 \startMPcode
>                         numeric u, omega, mylength, tt ;
>                         u := 2cm ;
>                         omega := 4 ;
>                         mylength := 3.141596 ;
>                         tt := \recurselevel ;
>                         path p ;
>                         p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1
> upto 100 :
>                                                         ..
> (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u)
>                                         endfor ;
>                         draw p withpen pencircle scaled .5pt withcolor
> darkred ;
>                 \stopMPcode
>                 \stopframe}
>                 }
> \stopanimation
> \stopTEXpage
> \stoptext
> % end wave-sine.tex
>
> Best regards: OK
>
> > On 21 Jul 2021, at 19:44, Jeroen <contextntg@gmail.com> wrote:
> >
> > I am looking for a sine animation as the one file f.pdf on this site
> >
> >
> http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm
> >
> > Jeroen
> >
> > Op wo 21 jul. 2021 om 17:54 schreef Fabrice L <fabrice.alpha@gmail.com>:
> > Hi,
> >
> >> Le 21 juill. 2021 à 10:08, Jeroen <contextntg@gmail.com> a écrit :
> >>
> >> I use this small animation to enlarge a circle
> >>
> >>
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >>     \startMPcode
> >>     path p;
> >>     numeric n, u;
> >>     u := 1cm;
> >>     n:=\recurselevel*u;
> >>     p := fullcircle scaled n;
> >>     draw p;
> >>     \stopMPcode
> >>   \stopframe}}
> >> \stopanimation
> >> \stoptext
> >>
> >>
> >> This I use to draw a sine
> >>
> >>
> >> \starttext
> >> \startMPcode
> >>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> >> \stopMPcode
> >> \stoptext
> >>
> >>
> >> When I put it together to animate the sine as following, it does not
> entirely create the sine animation I am looking for
> >>
> >>
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >>     \startMPcode
> >>     path p;
> >>     numeric n, u;
> >>     u := 1cm;
> >>     n:=\recurselevel*u;
> >>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >>     draw p;
> >>     \stopMPcode
> >>     \stopframe}}
> >> \stopanimation
> >> \stoptext
> >>
> >>
> >> What better way can I create a sine animation with Metapost?
> >>
> >>
> >
> > Here is another way to do your animation. This is doing something, but I
> guess not what you want. Could you describe what do you have in mind ?
> >
> > \starttext
> > \dorecurse{7}{ % 3180
> > \startMPpage
> >       myvariable := #1 ;
> >       path p;
> >     numeric n, u;
> >     u := 1cm;
> >     n:=myvariable*u;
> >     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: ..
> (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >     draw p;
> > \stopMPpage
> > }
> > \stoptext
> >
> > Fabrice.
> >
> >
> >
> ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry
> to the Wiki!
> >
> > maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> > webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> > archive  : https://bitbucket.org/phg/context-mirror/commits/
> > wiki     : http://contextgarden.net
> >
> ___________________________________________________________________________________
> >
> ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry
> to the Wiki!
> >
> > maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> > webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> > archive  : https://bitbucket.org/phg/context-mirror/commits/
> > wiki     : http://contextgarden.net
> >
> ___________________________________________________________________________________
>
>
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to
> the Wiki!
>
> maillist : ntg-context@ntg.nl /
> http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
>
> ___________________________________________________________________________________
>

[-- Attachment #1.2: Type: text/html, Size: 9170 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: Metapost Animation of Sine
  2021-07-22 12:28       ` Jeroen
@ 2021-07-22 20:38         ` Otared Kavian
  0 siblings, 0 replies; 7+ messages in thread
From: Otared Kavian @ 2021-07-22 20:38 UTC (permalink / raw)
  To: mailing list for ConTeXt users


[-- Attachment #1.1: Type: text/plain, Size: 7723 bytes --]

Hi Jeroen,

Unfortunately I am not familiar with Tikz, since all my documents use what is built-in ConTeXt and Metapost…
That being said I am sure someone on the list can help you with Tikz module.

Best regards: Otared

> On 22 Jul 2021, at 14:28, Jeroen <contextntg@gmail.com> wrote:
> 
> Hi, both solutions are great! This is what I had in mind, a rolling sine. Is there a way to get the same result with the Tikz module?
> 
> \usemodule[animation]
> \setupinteraction[state=start]
> 
> \starttext
> 
> \input tufte
> 
> \framed{
> \startanimation[menu=yes,framerate=40]
> \dorecurse{50}{\expanded
> {\startframe
> \startMPcode
> numeric u, omega, mylength, tt ;
> u := 2cm ;
> omega := 4 ;
> mylength := 3.141596 ;
> tt := \recurselevel ;
> path p ;
> p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 : 
> .. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
> endfor ;
> draw p withpen pencircle scaled .5pt withcolor darkred ;
> \stopMPcode
> \stopframe}
> }
> \stopanimation
> }
> 
> \stoptext
> 
> Op wo 21 jul. 2021 om 23:26 schreef Otared Kavian <otared@gmail.com <mailto:otared@gmail.com>>:
> Hi, 
> 
> I wonder whether something like the following is what you are looking for:
> 
> % begin wave-sine.tex
> \usemodule[animation]
> \setupinteraction[state=start]
> \starttext
> \startTEXpage[offset=2pt]
> \startanimation[menu=yes,framerate=10]
>         \dorecurse{100}{\expanded
>                 {\startframe
>                 \startMPcode
>                         numeric u, omega, mylength, tt ;
>                         u := 2cm ;
>                         omega := 4 ;
>                         mylength := 3.141596 ;
>                         tt := \recurselevel ;
>                         path p ;
>                         p := (0u,sin(omega*(mylength/100)*tt)*u) for i = 1 upto 100 : 
>                                                         .. (((mylength/100)*i)*u,sin(omega*(mylength/100)*(i + tt))*u) 
>                                         endfor ;
>                         draw p withpen pencircle scaled .5pt withcolor darkred ;
>                 \stopMPcode
>                 \stopframe}
>                 }
> \stopanimation
> \stopTEXpage
> \stoptext
> % end wave-sine.tex
> 
> Best regards: OK
> 
> > On 21 Jul 2021, at 19:44, Jeroen <contextntg@gmail.com <mailto:contextntg@gmail.com>> wrote:
> > 
> > I am looking for a sine animation as the one file f.pdf on this site
> > 
> > http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm <http://www.12000.org/my_notes/Mathematica_animation_into_PDF_using_latex/index.htm>
> > 
> > Jeroen
> > 
> > Op wo 21 jul. 2021 om 17:54 schreef Fabrice L <fabrice.alpha@gmail.com <mailto:fabrice.alpha@gmail.com>>:
> > Hi,
> > 
> >> Le 21 juill. 2021 à 10:08, Jeroen <contextntg@gmail.com <mailto:contextntg@gmail.com>> a écrit :
> >> 
> >> I use this small animation to enlarge a circle
> >> 
> >> 
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >>     \startMPcode
> >>     path p;
> >>     numeric n, u;
> >>     u := 1cm;
> >>     n:=\recurselevel*u;
> >>     p := fullcircle scaled n;
> >>     draw p;
> >>     \stopMPcode
> >>   \stopframe}}
> >> \stopanimation
> >> \stoptext
> >> 
> >> 
> >> This I use to draw a sine
> >> 
> >> 
> >> \starttext
> >> \startMPcode
> >>   draw(-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i)))endfor;
> >> \stopMPcode
> >> \stoptext
> >> 
> >> 
> >> When I put it together to animate the sine as following, it does not entirely create the sine animation I am looking for
> >> 
> >> 
> >> \usemodule[animation]
> >> \setupinteraction[state=start]
> >> \starttext
> >> \startanimation[menu=yes,framerate=10]
> >> \dorecurse{7}{\expanded
> >>   {\startframe
> >>     \startMPcode
> >>     path p;
> >>     numeric n, u;
> >>     u := 1cm;
> >>     n:=\recurselevel*u;
> >>     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >>     draw p;
> >>     \stopMPcode
> >>     \stopframe}}
> >> \stopanimation
> >> \stoptext
> >> 
> >> 
> >> What better way can I create a sine animation with Metapost?
> >>  
> >> 
> > 
> > Here is another way to do your animation. This is doing something, but I guess not what you want. Could you describe what do you have in mind ?
> > 
> > \starttext
> > \dorecurse{7}{ % 3180
> > \startMPpage
> >       myvariable := #1 ;
> >       path p;
> >     numeric n, u;
> >     u := 1cm;
> >     n:=myvariable*u;
> >     p := (-90/360*1.5cm,-0.9cm) for i = -90 upto 630: .. (i/360*1.5cm,0.9cm*(sind(i))) endfor shifted (n,0);
> >     draw p;
> > \stopMPpage
> > }
> > \stoptext
> > 
> > Fabrice.
> > 
> > 
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> > 
> > maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
> > webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
> > archive  : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
> > wiki     : http://contextgarden.net <http://contextgarden.net/>
> > ___________________________________________________________________________________
> > ___________________________________________________________________________________
> > If your question is of interest to others as well, please add an entry to the Wiki!
> > 
> > maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
> > webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
> > archive  : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
> > wiki     : http://contextgarden.net <http://contextgarden.net/>
> > ___________________________________________________________________________________
> 
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl <mailto:ntg-context@ntg.nl> / http://www.ntg.nl/mailman/listinfo/ntg-context <http://www.ntg.nl/mailman/listinfo/ntg-context>
> webpage  : http://www.pragma-ade.nl <http://www.pragma-ade.nl/> / http://context.aanhet.net <http://context.aanhet.net/>
> archive  : https://bitbucket.org/phg/context-mirror/commits/ <https://bitbucket.org/phg/context-mirror/commits/>
> wiki     : http://contextgarden.net <http://contextgarden.net/>
> ___________________________________________________________________________________
> ___________________________________________________________________________________
> If your question is of interest to others as well, please add an entry to the Wiki!
> 
> maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
> webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________


[-- Attachment #1.2: Type: text/html, Size: 13975 bytes --]

[-- Attachment #2: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
If your question is of interest to others as well, please add an entry to the Wiki!

maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context
webpage  : http://www.pragma-ade.nl / http://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2021-07-22 20:38 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-07-21 14:08 Metapost Animation of Sine Jeroen
2021-07-21 15:54 ` Fabrice L
2021-07-21 17:44   ` Jeroen
2021-07-21 21:26     ` Otared Kavian
2021-07-22 12:28       ` Jeroen
2021-07-22 20:38         ` Otared Kavian
2021-07-21 21:45     ` Otared Kavian

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).