LOGO-L> random generated penta fractal 
Author Message
 LOGO-L> random generated penta fractal

;Hello John Gough
;Here is the code for a (Sierpinski) pentagon drawn by the same
;aproach you have posted for the sierpinski triangle. the only
;change is that the list contains the verticies of the pentagon,
;the origin is shifted to -100 -100. this code is written in UCBLogo
;if your interpreter does not support pensize delete it,you can also
;change fd 0 to fd 1 to increase the intensity.
;Best Regards.
;Mhelhefni.
;-------------------------------------------------------------  

to get.point :lev
if :lev =0 [stop]
make "T.pt item 1 + random 5 [[0 0] [400 0] [520 380] [200 616] [-124 380]]
plot.midpoint :z  :T.pt
make "z pos
get.point :lev-1
end

to go ;start
make "z list random 600 random 600 cs ht
setpensize [2 2]
get.point 10000
end

to plot.midpoint :Pt.1 :Pt.2
pu setx -100+ ((first :Pt.1) + (first :Pt.2)) / 3
sety -100+ ((last :Pt.1) + (last :Pt.2)) / 3
pd fd 0 pu
end
;--------------------------------------------------------------

John Gough wrote :-
I have tried some of the obvious adaptations of this "game" to see if I
could generate a Sierpinski "square", also known as a "carpet" where the
triangle is known as a "gasket". Start with four points instead of three,
and roll as before, then move to the midpoint between where you last were
and the new rolled point. But so far none of my attempts have worked.
Similarly, changing from midpoint constructions to trisection constructions
does not result in anything except a random filling in of the entire
triangle.
Maybe someone out there can suggest other chaotic "games" which generate
surprising fractal images. The book discusses a set of transformations
which result in the fern fractal, but I haven't been able to identify a
suitable set of four transformations. Maybe I'm missing something in my
reading of the book.

---------------------------------------------------------------





Fri, 07 Apr 2000 03:00:00 GMT  
 LOGO-L> random generated penta fractal

Note the only real change needed was to replace "pd fd 0 pu" with
"setpixel [0 0 0]"
for MSWLogo. But I decided to play with it a tad. Instead of choosing
the raw number
of interations it now stops when it meets the criteria of "coverage"
based on the
probability of hitting n pixels that have been already hit. n Is called
MissInARow
and the user is prompted for the value.

The code uses PIXEL which returns the color under the turtle (Other
logos use a
different name). PIXEL gives you access to a 1 megabyte array in 8bit
color and
a 3 megabyte array in 24bit color (assuming the default graphics
workspace of
1000x1000). This is basically for free (i.e. it's already there so why
not use it).

Erich's "rug's" also took advantage of it.

to get.point :lev
; Using a loop made it easier to add the "hit" flag
; I could of just put a "Global" flag in plot.midpoint
; But I try to avoid globals when possible.
; It certainly could of still been done recursively.
localmake "Hit "False
repeat :lev ~
   [
   make "T.pt item 1 + random 5 [[0 0] [400 0] [520 380] [200 616] [-124
380]]
   if plot.midpoint :z :T.pt [make "Hit "True]
   make "z pos
   ]
output :Hit
end

to go
cs ht
setpensize [2 2]
make "z list random 600 random 600
pu
localmake "TotalPoints 0
localmake "MissInARow First QuestionBox [] [Enter Number of Hits in a
Row to stop at (e.g. 10)]
; Keep running until we get MissInARow
do.while ~
   [
   Print :TotalPoints
   make "TotalPoints :TotalPoints + :MissInARow
   ] [get.point :MissInARow]
end

to plot.midpoint :Pt.1 :Pt.2
; Using SetXY is slight more efficient
setxy -100+ ((first :Pt.1) + (first :Pt.2)) / 3 ~
      -100+ (( last :Pt.1) + ( last :Pt.2)) / 3
; If this XY has not been hit before we are still making progress
if not pixel = [0 0 0] ~
   [
   setpixel [0 0 0]
   output "True
   ]
; We already hit that one
output "False
end

Quote:

> ;Hello John Gough
> ;Here is the code for a (Sierpinski) pentagon drawn by the same
> ;aproach you have posted for the sierpinski triangle. the only
> ;change is that the list contains the verticies of the pentagon,
> ;the origin is shifted to -100 -100. this code is written in UCBLogo
> ;if your interpreter does not support pensize delete it,you can also
> ;change fd 0 to fd 1 to increase the intensity.
> ;Best Regards.
> ;Mhelhefni.
> ;-------------------------------------------------------------

> to get.point :lev
> if :lev =0 [stop]
> make "T.pt item 1 + random 5 [[0 0] [400 0] [520 380] [200 616] [-124 380]]
> plot.midpoint :z  :T.pt
> make "z pos
> get.point :lev-1
> end

> to go ;start
> make "z list random 600 random 600 cs ht
> setpensize [2 2]
> get.point 10000
> end

> to plot.midpoint :Pt.1 :Pt.2
> pu setx -100+ ((first :Pt.1) + (first :Pt.2)) / 3
> sety -100+ ((last :Pt.1) + (last :Pt.2)) / 3
> pd fd 0 pu
> end
> ;--------------------------------------------------------------

> John Gough wrote :-
> I have tried some of the obvious adaptations of this "game" to see if I
> could generate a Sierpinski "square", also known as a "carpet" where the
> triangle is known as a "gasket". Start with four points instead of three,
> and roll as before, then move to the midpoint between where you last were
> and the new rolled point. But so far none of my attempts have worked.
> Similarly, changing from midpoint constructions to trisection constructions
> does not result in anything except a random filling in of the entire
> triangle.
> Maybe someone out there can suggest other chaotic "games" which generate
> surprising fractal images. The book discusses a set of transformations
> which result in the fern fractal, but I haven't been able to identify a
> suitable set of four transformations. Maybe I'm missing something in my
> reading of the book.

> ---------------------------------------------------------------




--
===============================================================
George Mills

http://www.softronix.com
The www page contains some very powerful educational software.
Our single most important investment is our kids.
---------------------------------------------------------------





Sat, 08 Apr 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. LOGO-L> random based hexa fractal

2. LOGO-L> generate random number in MSWLogo

3. LOGO-L> Logo fractal 3: flower

4. LOGO-L> logo fractal 2: snowflake

5. LOGO-L> logo fractal

6. LOGO-L> Re: logo and sentence generating

7. LOGO-L> What is a Fractal

8. LOGO-L> Dragon Fractal

9. LOGO-L> animated fractal gifs

10. LOGO-L> octastar fractal

11. LOGO-L> Animated Koch's Fractal

12. LOGO-L> Shortest Fractal

 

 
Powered by phpBB® Forum Software