Path: csiph.com!usenet.pasdenom.info!news.albasani.net!newsfeed.freenet.ag!takemy.news.telefonica.de!telefonica.de!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="UTF-8" Message-ID: <3347742.XQ3BYjxHdU@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 02 Nov 2013 21:31:55 +0100 User-Agent: KNode/4.10.5 Content-Transfer-Encoding: 8Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. MIME-Version: 1.0 Lines: 74 NNTP-Posting-Date: 02 Nov 2013 21:31:58 CET NNTP-Posting-Host: fe85a87e.newsspool1.arcor-online.net X-Trace: DXC=AbZ31WOn?EZ\PS5Xo=M[RVic==]BZ:af^4Fo<]lROoRQnkgeX?EC@@P:B3KFXJVReRDZm8W4\YJN\YUVHKH;GI^Wb`YH7>Ffd\XN>UYN?>aiVT X-Complaints-To: usenet-abuse@arcor.de Xref: csiph.com comp.lang.javascript:21856 Michael Haufe (TNO) wrote: > Since there have been complaints about lack of questions and activity in > the group, I've decided to ask a question once in awhile to hopefully > spark some more activity. These will probably be questions I already know > the answer to or something which is in the realm of opinion/style and a > point of conflict in the JS community in general. On the former kind of > questions I'll feign ignorance in order to draw out some hopefully useful > discussions and aspects. Don’t. And watch your Subject header fields. > So if you're willing to play along, here is my first question: > > I have a element upon which I draw shapes and lines. To abstract > away the dirty details, I've created a small language with which I use to > draw the desired shapes: > > F: Draw Forward > f: Move Forward > [: Push State > ]: Pop State > -: Rotate Left > +: Rotate Right > > An example of usage would be: > > defSystem({ > name:"Levy C Curve", > start: "F", > x: 450, > y: 300, > depth:11, > stepSize: 5, > angle: Math.PI, > stepAngle: Math.PI/4, > rules: { > "F": "+F--F+" > } > }) > > […] > Currently my program works by initially performing the replacements and > expanding the drawing commands out as far as necessary before executing > the final string (which as you've seen, can be quite large). > > How would you approach this problem and prevent the exponential expansion > of the string while still being able to execute the drawing rules? I am not sure what you are asking here. AIUI, the very point of the L(indenmayer)-system construction of Lévy C curves and other self-similar fractal curves is iterative simultaneous application of production rules. String values are probably the most efficient way in ECMAScript implementations to represent the resulting turtle graphics operations (with String values consisting of 16-bit units, and Number values each being 64 bit in memory instead; add to that the complexity of substitute Array operations), and the Canvas API is a way to draw turtle graphics. I also see the alternative to represent the resulting operations as a trinary number (e.g., “F” ≡ 0, “+” ≡ 1, “−” ≡ 2). However, producing the operations value this way would not only be less time-efficient, but would also quickly reach the limit of IEEE-754 integer precision (at 2⁵³ [1]), probably allowing for fewer iterations than with a string value. [1] -- PointedEars Twitter: @PointedEars2 Please do not Cc: me. / Bitte keine Kopien per E-Mail.