ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Numerical Calculations
@ 2012-12-19 18:09 Troy Henderson
  2012-12-19 18:16 ` Thomas A. Schmitz
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Troy Henderson @ 2012-12-19 18:09 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Is there a way to for ConTeXt to do basic arithmetic operations?  For
example,

\calc{1+2} and have it return 3 or

\calc{1/3.8} and have it return 0.263157894736842 (or rounded)

Troy

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
  2012-12-19 18:09 Numerical Calculations Troy Henderson
@ 2012-12-19 18:16 ` Thomas A. Schmitz
  2012-12-19 18:18 ` Hans Hagen
  2012-12-19 18:19 ` Hans Hagen
  2 siblings, 0 replies; 17+ messages in thread
From: Thomas A. Schmitz @ 2012-12-19 18:16 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/19/2012 07:09 PM, Troy Henderson wrote:
> Is there a way to for ConTeXt to do basic arithmetic operations?  For
> example,
>
> \calc{1+2} and have it return 3 or
>
> \calc{1/3.8} and have it return 0.263157894736842 (or rounded)
>
> Troy

http://wiki.contextgarden.net/Programming_in_LuaTeX#Examples

___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-19 18:09 Numerical Calculations Troy Henderson
  2012-12-19 18:16 ` Thomas A. Schmitz
@ 2012-12-19 18:18 ` Hans Hagen
  2012-12-19 18:19 ` Hans Hagen
  2 siblings, 0 replies; 17+ messages in thread
From: Hans Hagen @ 2012-12-19 18:18 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/19/2012 7:09 PM, Troy Henderson wrote:
> Is there a way to for ConTeXt to do basic arithmetic operations?  For
> example,
>
> \calc{1+2} and have it return 3 or
>
> \calc{1/3.8} and have it return 0.263157894736842 (or rounded)

\luaexpr{1+2}

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-19 18:09 Numerical Calculations Troy Henderson
  2012-12-19 18:16 ` Thomas A. Schmitz
  2012-12-19 18:18 ` Hans Hagen
@ 2012-12-19 18:19 ` Hans Hagen
  2012-12-19 18:43   ` Troy Henderson
  2 siblings, 1 reply; 17+ messages in thread
From: Hans Hagen @ 2012-12-19 18:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/19/2012 7:09 PM, Troy Henderson wrote:

> \calc{1/3.8} and have it return 0.263157894736842 (or rounded)

\ctxcommand{format("@0.3f",1/3.8)}

@ as well as % ... just lua format but @ is more tex friendly

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-19 18:19 ` Hans Hagen
@ 2012-12-19 18:43   ` Troy Henderson
  2012-12-19 19:19     ` Roland Thiers
                       ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Troy Henderson @ 2012-12-19 18:43 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users


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

Do \luaexpr{1/3.8} and \ctxcommand{format("@0.3f",1/3.8)} return numbers or
strings?  That is, I would like to use these results in a \if or \ifnum
command to exit a \doloop.

Troy

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
  2012-12-19 18:43   ` Troy Henderson
@ 2012-12-19 19:19     ` Roland Thiers
  2012-12-19 19:26       ` Hans Hagen
  2012-12-19 19:25     ` Hans Hagen
  2012-12-19 19:32     ` Philipp Gesang
  2 siblings, 1 reply; 17+ messages in thread
From: Roland Thiers @ 2012-12-19 19:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Le 20 déc. 12 à 05:43, Troy Henderson a écrit :

> Do \luaexpr{1/3.8} and \ctxcommand{format("@0.3f",1/3.8)} return  
> numbers or strings?  That is, I would like to use these results in a  
> \if or \ifnum command to exit a \doloop.
>
> Troy
  Bonjour,
\ctxlua{context(type(\luaexpr{1/3.8}))} gives : number
Roland


> ___________________________________________________________________________________
> 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://tex.aanhet.net
> archive  : http://foundry.supelec.fr/projects/contextrev/
> 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-19 18:43   ` Troy Henderson
  2012-12-19 19:19     ` Roland Thiers
@ 2012-12-19 19:25     ` Hans Hagen
       [not found]       ` <CAFP+xFK89EWiM7SbhVvZKPe1Hv2UKNGAgo6B8kaJNaE363dWpA@mail.gmail.com>
  2012-12-19 19:32     ` Philipp Gesang
  2 siblings, 1 reply; 17+ messages in thread
From: Hans Hagen @ 2012-12-19 19:25 UTC (permalink / raw)
  To: Troy Henderson; +Cc: mailing list for ConTeXt users

On 12/19/2012 7:43 PM, Troy Henderson wrote:
> Do \luaexpr{1/3.8} and \ctxcommand{format("@0.3f",1/3.8)} return numbers
> or strings?  That is, I would like to use these results in a \if or
> \ifnum command to exit a \doloop.

they return tokens i.e.

\ifnum\luaexpr{math.round(1/3.8)}>1\relax

should work ok; it all depends on what you do, but you could also set a 
counter ans use that:

\ctxlua{tex.count.scratchcounter=math.round(1/3.8)}

\ifnum\scratchcounter>0




-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-19 19:19     ` Roland Thiers
@ 2012-12-19 19:26       ` Hans Hagen
  0 siblings, 0 replies; 17+ messages in thread
From: Hans Hagen @ 2012-12-19 19:26 UTC (permalink / raw)
  To: mailing list for ConTeXt users

On 12/19/2012 8:19 PM, Roland Thiers wrote:
>
> Le 20 déc. 12 à 05:43, Troy Henderson a écrit :
>
>> Do \luaexpr{1/3.8} and \ctxcommand{format("@0.3f",1/3.8)} return
>> numbers or strings?  That is, I would like to use these results in a
>> \if or \ifnum command to exit a \doloop.
>>
>> Troy
>   Bonjour,
> \ctxlua{context(type(\luaexpr{1/3.8}))} gives : number

sure, but the context command pipes it back to tex as characters that 
get tokenized

Hans

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-19 18:43   ` Troy Henderson
  2012-12-19 19:19     ` Roland Thiers
  2012-12-19 19:25     ` Hans Hagen
@ 2012-12-19 19:32     ` Philipp Gesang
  2 siblings, 0 replies; 17+ messages in thread
From: Philipp Gesang @ 2012-12-19 19:32 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

···<date: 2012-12-19, Wednesday>···<from: Troy Henderson>···

> Do \luaexpr{1/3.8} and \ctxcommand{format("@0.3f",1/3.8)} return numbers or
> strings?  That is, I would like to use these results in a \if or \ifnum
> command to exit a \doloop.

Fwiw there are Lua-side conditionals available as well:

  http://www.ntg.nl/pipermail/ntg-context/2012/068673.html

with these maybe you won’t need TeX for the tests.

Regards
Philipp


-- 
()  ascii ribbon campaign - against html e-mail
/\  www.asciiribbon.org   - against proprietary attachments

[-- Attachment #1.2: Type: application/pgp-signature, Size: 198 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
       [not found]         ` <CAFP+xFJqt=j-3B1y2LpYj6Xuu19viGScjEea=rN5FtVsotd3yw@mail.gmail.com>
@ 2012-12-19 20:30           ` Hans Hagen
  2012-12-19 20:54             ` Troy Henderson
  0 siblings, 1 reply; 17+ messages in thread
From: Hans Hagen @ 2012-12-19 20:30 UTC (permalink / raw)
  To: Troy Henderson, mailing list for ConTeXt users

On 12/19/2012 9:13 PM, Troy Henderson wrote:
> I got this to work.  There's probably a better method though ;)
>
> \edef\r{\luaexpr{1/3.8}}
> \edef\q{1}\doloop{\ctxlua{commands.doifelse(math.abs(\q*\r -
> math.floor(\q*\r+0.5))<0.000001)}{\exitloop}{\edef\q{\luaexpr{\q+1}}}}

Yes, you need to think more hybrid .. two variants:

\startluacode
     local r = 1 / 3.8
     local q = 1
     while true do
         if math.abs(q*r - math.floor(q*r+0.5)) < 0.000001 then
             break
         else
             q = q + 1
         end
     end
     context.setvalue("MyQ",q)
\stopluacode

\startluacode
     userdata = userdata or { }
     function userdata.CalculateQ(r)
         local q = 1
         while true do
             if math.abs(q*r - math.floor(q*r+0.5)) < 0.000001 then
                 break
             else
                 q = q + 1
             end
         end
         context(q)
     end
\stopluacode

\edef\MyOtherQ{\ctxlua{userdata.CalculateQ(1/3.8)}}

\starttext

     q: \MyQ

     q: \MyOtherQ

\stoptext



-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | voip: 087 875 68 74 | www.pragma-ade.com
                                              | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-19 20:30           ` Hans Hagen
@ 2012-12-19 20:54             ` Troy Henderson
  2012-12-19 22:05               ` Marco Patzer
  0 siblings, 1 reply; 17+ messages in thread
From: Troy Henderson @ 2012-12-19 20:54 UTC (permalink / raw)
  To: Hans Hagen; +Cc: mailing list for ConTeXt users


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

In case anyone cares, here is the "finished" product which is a
frame-by-frame animation of a hypocycloid.  The following code will produce
a 190 page PDF where each page is an individual frame of the animation.

Troy

\edef\r{\luaexpr{1/3.8}} % Radius of smaller circle (larger circle has
radius 1)
\edef\N{10} % Number of frames in animation per hypocycloid "branch"

\edef\K{1}\doloop{\ctxlua{commands.doifelse(math.abs(\K*\r -
math.floor(\K*\r+0.5))<0.000001)}{\exitloop}{\edef\K{\luaexpr{\K+1}}}}
\startMPinclusions[+]
    r:=\r; % Radius of smaller circle (larger circle has radius 1)
    u:=70; % Scaling factor for the graphics
    K:=\K; % Number of "branches" per period (computed automatically)
    M:=8; % Number of points in the Bezier curve for each "branch"
    N:=\N; % Number of frames in animation per hypocycloid "bran
    path p; % p is the "first branch" of the hypocycloid
    p:=(1,0) for m=1 upto (M-1): ..
(r*cosd(360*(r-1)/(M-1)*m)-(r-1)*cosd(360*r/(M-1)*m),r*sind(360*(r-1)/(M-1)*m)-(r-1)*sind(360*r/(M-1)*m))
endfor;
    W:=ceiling(u/32*65); % Width of each figure's bounding box
    H:=W; % Height of each figure's bounding box
    path q;
\stopMPinclusions
\starttext
    \dorecurse{\luaexpr{\K*\N}}{
        \startMPpage
            m:=floor((\recurselevel-1)/N);
            n:=\recurselevel-m*N-1;
            numeric s[];
            t:=n/N;

q:=(((1-r)*cosd(360*r*t),(1-r)*sind(360*r*t))--((1+r)*cosd(360*(r-1)*t)-(r-1)*cosd(360*r*t),(1+r)*sind(360*(r-1)*t)-(r-1)*sind(360*r*t)));
            (s1,s2) = p intersectiontimes reverse q;
            for j=0 upto (m-1): draw p scaled u rotated (360*r*j) withcolor
red; endfor;
            draw subpath (0,s1) of p scaled u rotated (360*r*m) withcolor
red;
            draw fullcircle scaled (2*u);
            draw fullcircle scaled (2*r*u) shifted
((1-r)*u*cosd(360*r*t),(1-r)*u*sind(360*r*t)) rotated (360*r*m);
            draw subpath (s2,length q) of (reverse q) scaled u rotated
(360*r*m);
            setbounds currentpicture to
(-W/2,-H/2)--(W/2,-H/2)--(W/2,H/2)--(-W/2,H/2)--cycle;
        \stopMPpage
    }
\stoptext

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
  2012-12-19 20:54             ` Troy Henderson
@ 2012-12-19 22:05               ` Marco Patzer
  2012-12-19 22:10                 ` Troy Henderson
  0 siblings, 1 reply; 17+ messages in thread
From: Marco Patzer @ 2012-12-19 22:05 UTC (permalink / raw)
  To: ntg-context


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

On 2012–12–19 Troy Henderson wrote:

> In case anyone cares, here is the "finished" product which is a
> frame-by-frame animation of a hypocycloid.  The following code will produce
> a 190 page PDF where each page is an individual frame of the animation.
> 
> […]

Very nice work, indeed. It reminds me of a drawing toy I had when I
was a kid. Thanks a lot for sharing.

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
  2012-12-19 22:05               ` Marco Patzer
@ 2012-12-19 22:10                 ` Troy Henderson
  2012-12-19 23:03                   ` Troy Henderson
  2012-12-19 23:20                   ` Marco Patzer
  0 siblings, 2 replies; 17+ messages in thread
From: Troy Henderson @ 2012-12-19 22:10 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

>
> Very nice work, indeed. It reminds me of a drawing toy I had when I
> was a kid. Thanks a lot for sharing.
>

Spirograph?

http://en.wikipedia.org/wiki/Spirograph

Troy

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
  2012-12-19 22:10                 ` Troy Henderson
@ 2012-12-19 23:03                   ` Troy Henderson
  2012-12-21 12:22                     ` Andre Caldas
  2012-12-19 23:20                   ` Marco Patzer
  1 sibling, 1 reply; 17+ messages in thread
From: Troy Henderson @ 2012-12-19 23:03 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

Here's the animated (video) version.

http://www.youtube.com/watch?v=2_OZ-yKMd7g

Troy

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
  2012-12-19 22:10                 ` Troy Henderson
  2012-12-19 23:03                   ` Troy Henderson
@ 2012-12-19 23:20                   ` Marco Patzer
  1 sibling, 0 replies; 17+ messages in thread
From: Marco Patzer @ 2012-12-19 23:20 UTC (permalink / raw)
  To: ntg-context


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

On 2012–12–19 Troy Henderson wrote:

> >
> > Very nice work, indeed. It reminds me of a drawing toy I had when I
> > was a kid. Thanks a lot for sharing.
> >
> 
> Spirograph?
> 
> http://en.wikipedia.org/wiki/Spirograph

Exactly, that's it.

Plenty of beautiful patterns with just small change in parameters.
Maybe this can be adapted for (non-circular) ornaments as well,
which could be used for text decorations. It would make for a nice
module.

Marco

[-- Attachment #1.2: Digital signature --]
[-- Type: application/pgp-signature, Size: 490 bytes --]

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Numerical Calculations
  2012-12-19 23:03                   ` Troy Henderson
@ 2012-12-21 12:22                     ` Andre Caldas
  2012-12-21 12:56                       ` Troy Henderson
  0 siblings, 1 reply; 17+ messages in thread
From: Andre Caldas @ 2012-12-21 12:22 UTC (permalink / raw)
  To: mailing list for ConTeXt users

> Here's the animated (video) version.
>
> http://www.youtube.com/watch?v=2_OZ-yKMd7g

How did you produce a video out of the PDF?
___________________________________________________________________________________
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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________


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

* Re: Numerical Calculations
  2012-12-21 12:22                     ` Andre Caldas
@ 2012-12-21 12:56                       ` Troy Henderson
  0 siblings, 0 replies; 17+ messages in thread
From: Troy Henderson @ 2012-12-21 12:56 UTC (permalink / raw)
  To: mailing list for ConTeXt users


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

>
> How did you produce a video out of the PDF?
>

I wrote a BASH script to automate this process, but essentially it involves
converting each "frame"/page of the PDF to JPG and then combining the JPG
sequence into a MP4 movie.

The hypocycloid example has 191 frames, and so I did something like:

let n=0;
while [ $n -lt 191 ]
do
   convert -density 720 hypocycloid.pdf[$n] -resize "x720" -flatten
-gravity center -extent "1280x720" -quality 100 hypocycloid-$n.jpg
done
ffmpeg -r 13 -i hypocycloid-%d.jpg -b 5000k -vcodec libx264 -y
hypocycloid.mp4

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

[-- Attachment #2: Type: text/plain, Size: 485 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://tex.aanhet.net
archive  : http://foundry.supelec.fr/projects/contextrev/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2012-12-21 12:56 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-12-19 18:09 Numerical Calculations Troy Henderson
2012-12-19 18:16 ` Thomas A. Schmitz
2012-12-19 18:18 ` Hans Hagen
2012-12-19 18:19 ` Hans Hagen
2012-12-19 18:43   ` Troy Henderson
2012-12-19 19:19     ` Roland Thiers
2012-12-19 19:26       ` Hans Hagen
2012-12-19 19:25     ` Hans Hagen
     [not found]       ` <CAFP+xFK89EWiM7SbhVvZKPe1Hv2UKNGAgo6B8kaJNaE363dWpA@mail.gmail.com>
     [not found]         ` <CAFP+xFJqt=j-3B1y2LpYj6Xuu19viGScjEea=rN5FtVsotd3yw@mail.gmail.com>
2012-12-19 20:30           ` Hans Hagen
2012-12-19 20:54             ` Troy Henderson
2012-12-19 22:05               ` Marco Patzer
2012-12-19 22:10                 ` Troy Henderson
2012-12-19 23:03                   ` Troy Henderson
2012-12-21 12:22                     ` Andre Caldas
2012-12-21 12:56                       ` Troy Henderson
2012-12-19 23:20                   ` Marco Patzer
2012-12-19 19:32     ` Philipp Gesang

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