And what about a star with N points?
Try the following with some different :node's, best of all primes
(why?)
to a.star :nodes :module
draw.wg w2arr :nodes :module int quotient :nodes 2
end
to draw.wg :ww :k
make "n count :ww
bury [n]
pu setpos first :ww
pd
repeat :n [setpos item sum 1 remainder product :k repcount
:n :ww]
end
to w2arr :n :l
pu
make "arr []
bury [arr]
repeat :n [queue "arr pos fd :l lt 360/:n]
output :arr
end
; You may also try this
to and.whats.that :nodes :module
repeat int quotient :nodes 2 [draw.wg w2arr :nodes
:module repcount]
end
Isn't it cool that it works without calculating angles and distances?
Hello,
In continuation to Andrzej's last procedure:
The following program draws any n-sided polygon, together with all its diagonals:
=================================
to main ; Diagonals
cs ht setpc 4
pr[Input Number of Sides and Size]
pu draw collect [] rw rw 1
end
to collect :ll :n :size
repeat :n[
fd :size push "ll pos
bk :size rt 360/:n]
op :ll
end
to draw :ll :cnt
if :cnt=count :ll[stop]
rays :ll
draw fput last :ll bl :ll :cnt+1
end
to rays :ll
setpos last :ll
pd setpos first :ll
if 2<count :ll[rays bf :ll]
end
=================================
Enjoy,
Regards...
[[Yehuda]]
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