[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Odp: LOGO-L> hilbert again



----------
> From: Olga Tuzova <olgatu@ort.spb.ru>
> To: logo-l@gsn.org

[snip]

> BTW, Andrzej, why do you call it W-curve?
>  
I remember this figure from Niklaus Wirth book. It was included as an exercise and named W-curve by the author. I'm not sure, Mr Wirth is the one who invented this figure, but it it quite possible. I think, this figure has the same meaning for Swiss as Koch snowflake for the Israelis - on level 1 (or 0) it looks like their national flag.

> The problem is, I can't find the method of changing size parameter to 
> make the line  always stay inside a square while filling it.
> 
> Any comments will be appreciated.
> 

For the W-curve You may calculate it's dimension as follows:

to w.dim :k :b
 if :k=0 [output :b]
 output sum :b 2*(:b + w.dim (:k-1) :b)
end

; and this is modified W curve which starts from a middle

to w.figure :k :b :pos
 pu setxy (first :pos) + (-10-0.5*w.dim :k :b) (last :pos) + (0.5*w.dim :k :b) pd 
 repeat 4 [w.angle w.connect :k]
 pu setpos :pos pd
end

to w.angle
 rt 90 fd :b lt 90 fd :b rt 90
end

to w.connect :k
 if :k=0 [fd :b stop]
 w.connect :k-1
 w.angle
 w.connect :k-1
 lt 90 fd :b lt 90
 w.connect :k-1
 w.angle
 w.connect :k-1
end

;; example of use: 
; w.figure 2 12 pos
; fill


Regards.
Andrzej B.

PS Olga, the old paraboloid is almost ready and it got a new shape. 

Swiss.jpg (JPEG Image)

hyperswiss.jpg (JPEG Image)



Global SchoolNet Foundation - Linking Kids Around the World!
Copyright GSN - All Rights Reserved - Comments & Questions
Visit GSN's Global Schoolhouse for more exciting learning resources!
Search our Site - Home