Re: [NTG-context] Numerical Calculations

2012-12-21 Thread Andre Caldas
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!

Re: [NTG-context] Numerical Calculations

2012-12-21 Thread Troy Henderson
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

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Thomas A. Schmitz
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

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Hans Hagen
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}

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Hans Hagen
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 -

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread 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. Troy ___ If your question is of interest to

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Roland Thiers
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 :

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Hans Hagen
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

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Hans Hagen
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,

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Philipp Gesang
···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:

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Hans Hagen
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.01)}{\exitloop}{\edef\q{\luaexpr{\q+1 Yes, you need to think more

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Troy Henderson
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)

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Marco Patzer
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

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Troy Henderson
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 ___ If your question is of interest to others as

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Troy Henderson
Here's the animated (video) version. http://www.youtube.com/watch?v=2_OZ-yKMd7g Troy ___ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl /

Re: [NTG-context] Numerical Calculations

2012-12-19 Thread Marco Patzer
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.