Reflection

Help Contents Examples Reflection
Projection (3d advanced) Rose (3d)

Reflection

Example:    Reflection.eli
Modified:   June 2, 2000
Version:    2.0
Author:     Bojidar Sendov
E-mail:     bojo@fmi.uni-sofia.bg

Copyright © 2000 Elica Group

This program simulates ray reflection.

run "geomland
run "geomex

make "w 2
make "h 1

make "a point -200 -30
make "b :a+100*(point :w 0)° -15
make "c :b+100*(point :w 0)°  70
make "d :a+100*(point :h 0)°   0

make "sa segment :a :b
make "sb segment :b :c
make "sc segment :c :d
make "sd segment :d :a

make [hidden] "t point 0 0         ; initial point
make [hidden] "r ray :t random 360 ; initial direction

to move :p1 :p2

	make "pp :p1
	make local "i 0

	repeat 11
	[
		make [hidden] "qq :pp
		make "pp ((10-:i)*:p1+:i*:p2)/10
		make "y segment :qq :pp [traced]

		if :traces.lasttrace > 15
		[
			delete word "traces. :traces.lasttrace-15
		]
		repaint
		make "i :i+1
	]
end

to nextSide 

	local "newside
	make local "ss :sn

	while :ss<>[] 
	[
		make "newside first :ss

		if :side<>:newside
		[
			make "ns : (:newside)
			make local "z isec :r :ns

			if (pointon# :z :r) >= 0
			[
				make local "p2 pointon# :z :ns

				if (:p2>=0) and (:p2<=1)
				[
					make "t1 :z
					output :newside
				]
			]
		]
		make "ss bf :ss
	]
end

make "sn [sa sb sc sd]
make "side 
make "side nextSide

make [hidden] "t1
make [hidden] "t2

repeat 50
[
	make "t2 sympoint :t :ns
	make "r ray :t2 :t1

	move :t :t1

	make "t :t1
	make "side  nextSide
]

Projection (3d advanced) Rose (3d)