Icosahedron (3d)

Help Contents Examples Icosahedron (3d)
House (3d) Integral (simple 3d)

Icosahedron (3d)

This 3d example constructs an Icosahedon.

run "graphix

to norm :p
	output sqrt (:p.x*:p.x+:p.y*:p.y+:p.z*:p.z)
end

make "onbeforedraw.fog fog "true 75 65 0.1 black
make "onbeforedraw.clearcolor clearcolor 0 0 0

make "t 45

;to changeview
;
;	make "t :t+3
;
;	(lookat 
;		point 60*(cos :t) 60*(sin :t) 40 
;		point 0 0 0 
;		point 0 0 1
;	)
;end

;changeview

make "N 10
make "K :N*(1+(sqrt 5))/2

make "P11 point :N :K 0
make "P12 point 0-:N :K 0
make "P13 point :N 0-:K 0
make "P14 point 0-:N 0-:K 0

make "P21 point :K 0 :N
make "P22 point 0-:K 0 :N
make "P23 point :K 0 0-:N
make "P24 point 0-:K 0 0-:N

make "P31 point 0 :N :K
make "P32 point 0 0-:N :K
make "P33 point 0 :N 0-:K
make "P34 point 0 0-:N 0-:K

to poly :points

	run bf :polygon

	make local "mode 1
	make local "color grey
	make local "width 3
	make local "smooth "true
end

(make "p1 
	(styled 
		polygon (set :P11 :P12 :P14 :P13) 
		(set "color red "mode 2 "pattern [xo ox])
	)
)
(make "p2 
	(styled 
		polygon (set :P21 :P22 :P24 :P23) 
		(set "color lime "mode 2 "pattern [xo ox])
	)
)
(make "p3 
	(styled
		polygon (set :P31 :P32 :P34 :P33) 
		(set "color blue "mode 2 "pattern [xo ox])
	)
)

make "q01 poly (set :P11 :P31 :P21)
make "q02 poly (set :P11 :P12 :P31)
make "q03 poly (set :P12 :P22 :P31)
make "q04 poly (set :P21 :P31 :P32)
make "q05 poly (set :P22 :P32 :P31)
make "q06 poly (set :P14 :P22 :P32)
make "q07 poly (set :P14 :P13 :P32)
make "q08 poly (set :P13 :P21 :P32)
make "q09 poly (set :P12 :P22 :P24)
make "q10 poly (set :P14 :P22 :P24)

make "q11 poly (set :P11 :P33 :P23)
make "q12 poly (set :P11 :P12 :P33)
make "q13 poly (set :P12 :P24 :P33)
make "q14 poly (set :P23 :P33 :P34)
make "q15 poly (set :P24 :P33 :P34)
make "q16 poly (set :P14 :P24 :P34)
make "q17 poly (set :P14 :P13 :P34)
make "q18 poly (set :P13 :P34 :P23)
make "q19 poly (set :P11 :P21 :P23)
make "q20 poly (set :P13 :P21 :P23)

;repeat 1000 [changeview]

run "zoomRotate

House (3d) Integral (simple 3d)