![]() ![]() Rewriting rule "F" -> "F+F-F+F", and angle. System with initial string "F-F-F", string The Koch snowflake can be simply encoded as a Lindenmayer Triangle at the location where the side was removed, and then repeating the process Removing the inner third of each side, building another equilateral It is builtīy starting with an equilateral triangle, Hey, at least it works - which, considering it's Befunge, is something to be thankful for on its own.The Koch snowflake is a fractal curve, also known as the Koch island, which was first described by Helge von Koch in 1904. I'm not super familiar with SVG, so I don't know what the preferred method is for viewing those files (especially when they're really big). IrfanView seems to work decently if you have the right plugins. some number n that's 2 or greater, then it is expanded on the stack to n-1, -1, n-1, 0, n-1, -1, n-1.įor n = 10, this process takes a very long time (a couple of minutes on my system), and the resulting SVG is ~10MB in size and invisible when viewed in the browser because you can't adjust the size of the brush using TURT.1, it moves forward (by 15 pixels here, but you can change it by modifying the f on the last line).-1, the turtle turns counterclockwise 60 degrees.On each pass, if the top number on the stack is: I know, right?īasically, this works by using the stack as a sort of makeshift L-system and expanding it on the fly. There has to be a newline at the end for CCBI to run it without hanging (this is included with the character count).Maybe someday there will be a better interpreter out there that has a graphical display for the turtle, but for now. This is the closest I could come to "print a graphical representation of the snowflake to the screen" with available Funge interpreters I could find. If you run this in CCBI without the command-argument -turt-line=PATH, it will come out as a file named CCBI_TURT.svg by default. I tested this using CCBI 2.1, whose implementation of TURT (the turtle graphics fingerprint) makes I "print" the image to a SVG file.>j$ space makes me get some implementation details out of the way first: Now, only recently, I figured out a way to do it without using self-modification! And so. I knew I'd want to try implementing this in Befunge-98 using TURT, but I couldn't figure out how to go about it and I sat on it for several months. Take a triangle (magenta in this case) and overplot with 6 triangles 1/3 of the base. The colours are just for fun and to show the way it is constructed. This answer was inspired by xnor's comment. IFa FORj=-1TO1 FORi=-1TO1:z=FNt(x+24*a*i,y+j*14*a*(i*i*3-2),i,j,-j*a/3):NEXT:NEXTĪccording to the OP's answer to filled in snowflakes are OK. REM i loops through the three triangles of each orientation, from left to right. ![]() REM j determines if the triangle will be upright, inverted or (if j=0) infinitely small. ![]() REM if the absolute magnitude of a is sufficient to be truthy, recurse to the next level. REM using the specified point (top of the triangle) and the last two points visited (those used to draw the line.) REM first draw a line at the bottom of the triangle. REM loop variables i,j are only passed in order to make them local, not global. REM call function and throw return value away to z Not a winner, despite the fact that doing it ths way avoids the need for a special treament for n=1. Gone for the approach of starting with the three initial edges, then recursing through each edge and replacing them with 4 edges for each level. Even though this will never be a contender, I had to see if I could get it done in T-SQL.
0 Comments
Leave a Reply. |