## Maurer roses

For finished programs
Dutchman
Posts: 151
Joined: Tue Aug 06, 2019 4:47 pm
Location: Netherlands

### Maurer roses

An example of the use of complex numbers in polar notation.
This example concerns the Rhodonea curves which were named by the Italian mathematician Guido Grandi between 1723 and 1728 because they looked like roses. See http://mathworld.wolfram.com/Rose.html
In the Maurer rose, points with distance 'd' on the Rhodonea are connected via lines. See https://en.wikipedia.org/wiki/Maurer_rose

Code: Select all

``````'Maurer rose
'by Ton Nillesen, Septemner 2019
'See https://en.wikipedia.org/wiki/Maurer_rose
'and http://mathworld.wolfram.com/Rose.html
'
'==== User settings ====
pause=2 ' pause between polygons
roses=5 ' number of roses per Rhodonea

'==== Constants ====
x0,y0=SCRCENTER|2
Font\$="Arial Rounded MT Bold"
Fsize=20
DIM Prime()=17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97
Primes=SIZE OF Prime
'
'==== Initialise ====
GOSUB SetSign
RANDOMIZE
'
'==== Graphics ====
FOR n=2 TO 7
DRAWCLEAR 1,1,0
'---- Rhodonea
GOSUB DrawRhodonea
DELAY Pause
'---- Maurer roses
FOR nn=1 TO roses
d=Prime(RNDI primes-1)
GOSUB DrawRose
DELAY Pause
IF nn<roses
DRAW CLEAR 1,1,0
GOSUB DrawRhodonea ' prepare for next d
ENDIF
NEXT'nn
NEXT'n
END
'
'==== Functions and subroutines ====
DEF Rhodonea(n,a) 'angle a in degrees
'See http://mathworld.wolfram.com/Rose.html
Rh=SIN(n*a)*EXP(-1i*a)
RETURN REAL(Rh),IMAG(Rh)
END DEF
'
DrawRose:
txt0\$="Maurer rose, "
txt\$="n="+STRTEXT(n)+", d="+STRTEXT(d)
INSIGN TEXT capt txt0\$+txt\$
DRAWCOLOR 0,0,1
DRAWSIZE 1
DRAW AT x0,y0
FOR i=0 to 360 ' degrees
x y = Rhodonea|2(n,d*i)
NEXT'i
RETURN
'
DrawRhodonea:
txt0\$="Rhodonea, "
DRAWCOLOR 1,0,0
DRAWSIZE 5
INSIGN TEXT capt txt0\$+"n="+STRTEXT n
DRAW AT x0,y0
FOR i=0 to 360 ' degrees
x y = Rhodonea|2(n,i)
NEXT'i
RETURN
'
SetSign
capt=1 ' object ident for captions sign
INSIGN FCOLOR capt 0,0,1
INSIGN SET capt,"",fsize,0,x0,1.7*fsize
INSIGN FONT capt Font\$,Fsize
RETURN
``````
.
Maurer rose.png (328.13 KiB) Viewed 1513 times
It is still a long way to go

kibernetik
Posts: 147
Joined: Tue Aug 06, 2019 3:03 pm

### Re: Maurer roses

It is safe to write:

Code: Select all

``````FOR n=2 TO 7
FOR nn=1 TO roses
NEXT nn
NEXT n``````
Any text after NEXT is allowed and it has no meaning. So there is no need to put it in comment.