The Universe of Discourse | |||||||||||||||||||||||||||||||||||||||||||
12 recent entries Archive:
Comments disabled |
Tue, 26 Dec 2006
Linogram development: 20061226 Update
define regular_polygon[N] closed { param number radius, rotation=0; point vertex[N], center; line edge[N]; constraints { vertex[i] = center + radius * cis(rotation + 360*i/N); edge[i].start = vertex[i]; edge[i].end = vertex[i+1]; } }The stuff in green is working just right; the stuff in red is not. The following example works just fine:
number p[3]; number q[3]; constraints { p[i] = q[i]; q[i] = i*2; }What's still missing? Well, if you write number p[3]; number q[3]; constraints { p[i] = q[i+1]; }This should imply three constraints on elements of p and q:
p_{0} = q_{1} The third of these is defective, because there is no q_{3}. If the figure is "closed" (which is the default) the subscripts should wrap around, turning the defective constraint into p_{2} = q_{0} instead. If the figure is declared "open", the defective constraint should simply be discarded. The syntax for parameterized definitions (define regular_polygon[N] { ... }) is still a bit up in the air; I am now leaning toward a syntax that looks more like define regular_polygon { param index N; ... } instead. The current work on the "arrays" feature is in the CVS repository on the branch arrays; get the version tagged tests-pass to get the most recent working version. Most of the interesting work has been on the files lib/Chunk.pm and lib/Expression.pm.
[Other articles in category /linogram] permanent link |
||||||||||||||||||||||||||||||||||||||||||