Programming Tessellation in BASIC
Richard Ashbery (8349) 42 posts |
I’m experimenting with tessellations and discovered that the pentagon creates a superb pattern but having problems programming the third ring. This tessellation ring doesn’t follow a circular pattern as 5 of the pentagons require to be off-centered. The artwork and example code (which creates 2 of the concentric rings accurately) can be seen at… http://www.riscosbasic.uk/problems/Tessellation_Code.zip Any solutions would be welcome preferably with example code. |
GavinWraith (26) 1563 posts |
Of course you cannot tessellate the plane with pentagons, but you can tessellate the sphere with them. So draw a dodecahedron in 3D and then project that onto a plane. Perhaps you should talk to Martin Hansen (MatheMagic?). |
Richard Ashbery (8349) 42 posts |
Completely lost on that one Gavin. My illustration shows what I’m trying to draw but only in 2D. This has nothing to do with complicated 3D dodecahedrons or anything like that. I would like to chat to Martin but suspect family commitments and school work may have taken him off the RISC OS scene. |
Clive Semmens (2335) 3276 posts |
You can’t tesselate the plane with regular pentagons, but you can most certainly tesselate the plane with irregular pentagons, even identical irregular pentagons. Some of the most interesting of these kinds of tesselations are due to Roger Penrose. |
Clive Semmens (2335) 3276 posts |
These probably don’t help at all, Richard… and I don’t think I’ll release the program that generates them because it’s truly appallingly badly written… http://clive.semmens.org.uk/RISCOS/RandPats.html |
Steve Drain (222) 1620 posts |
I think the problem is that the pentangon centres do not actually fall on circles, but on the sides of pentagons. For the inner rings that is the same thing. I cannot see a simple way to calculate them, but I might return to this. ;-) |
GavinWraith (26) 1563 posts |
Sorry. I meant regular pentagons. I was unreading – unnecessarily inserting something into the topic that was not there. |
Clive Semmens (2335) 3276 posts |
We all – or most of us, certainly – do that a lot, Gavin. I think you’ve made a similar point elsewhere recently… 8~) |
Richard Ashbery (8349) 42 posts |
@Steve Drain Have another look at my DRAW file and you will see that the inner rings ‘DO’ fall on pentagon centres as shown by the dotted circles. The third ring is different in that groups of 2 pentagons fall on circles, followed by one that doesn’t – this sequence is repeated 4 times. My program (putting code quality aside) illustrates this point precisely. @Clive Semmens Interesting site Clive. |
GavinWraith (26) 1563 posts |
@Richard Have a look at the graphic on the right hand side |
Clive Semmens (2335) 3276 posts |
Not all my programming is truly dreadful. It’s almost all pretty bad. On occasion I have polished bits up to a good standard for publication, and I’ve published some that was pretty bad but sort of comprehensible to the initiated; but at its worst (and this particular example is pretty much that) it’s incomprehensible even to me, within a few days of completion. That’ll do for stuff that really doesn’t matter a toss… |
Steve Drain (222) 1620 posts |
Sorry, Richard, we were at crossed purposes and it is not important to sort that out. Here is an adaptation to your program that seems to do what you want: REM 15 pentagon group n%=0 FOR t=PI/15 TO 2*PI STEP PI/7.5 s=120 IF n% MOD 3=1 THEN x1=SIN(t)*507 : y1=COS(t)*507 ELSE x1=SIN(t)*557 : y1=COS(t)*557 ENDIF ORIGIN 1920+x1,1080+y1 PROCpentagon n%+=1 NEXT t |
Richard Ashbery (8349) 42 posts |
Thanks Steve. Brilliant, compact and does the job. I can see how obvious it is when shown by a competent programmer. I’ve often got into a muddle when dealing with the MOD statement. So only when (n%MOD3)=1 will the SIN/COS multiplication factor position the pentagon nearer to the tessellation centre. I have another program (think from BBC BASIC for Windows) that featured IF (x AND 1)=0 THEN PRINT “1” ELSE PRINT “0” Because it generates alternate 1’s and 0’s when used in a FOR-NEXT statement I adapted it in a graphic animation to rotate a shape c/w and then cc/w. I’m curious – how does this work? |
Steve Drain (222) 1620 posts |
Well, I would judge that if I could work out what it is for. ;-) |
David Feugey (2125) 2709 posts |
x=1-x |
Steve Fryatt (216) 2105 posts |
By masking out all but the bottom bit of
Is that relevant? I’m assuming (based on no context) that Richard means something like
…which means that |
Richard Ashbery (8349) 42 posts |
After implementing Steve Drain’s routine I’m able to create pentagon rings 3 and 4. The procedure works because there are only 2 different positions occupied by each pentagon in their respective rings. I’ve now added a fifth ring but now there are 3 different positions to cope with. Have a look at the drawing and you can see the problem. Is there some way of modifying your code Steve to create this outer ring? The zip file at http://www.riscosbasic.uk/problems/Tess2.zip contains the illustration of the problem and the BASIC program that creates the 4 rings. |