QB64.org Forum
Samples Gallery & Reference => Samples => General, Math & Geometry => Topic started by: The Librarian on March 05, 2020, 11:26:24 pm
-
Chaotic Scattering: Gaspard-Rice system
Author: @_vince
Source: qb64.org Forum
URL: https://www.qb64.org/forum/index.php?topic=78.0 (https://www.qb64.org/forum/index.php?topic=78.0)
Version: 2018
Tags: [geometry], [ray reflections]
Description:
https://en.wikipedia.org/wiki/Chaotic_scattering (https://en.wikipedia.org/wiki/Chaotic_scattering)
Demo of the Gaspard-Rice system as described above. Left-click to change location.
Source Code:
sw = 640
sh = 480
pi = 3.141593
r = 150
rr = 100
xx = sw / 2
yy = sh / 2
LINE (0, 0)-(sw
, sh
), 0, BF
f = -1
IF (mx
- x1
) ^ 2 + (my
- y1
) ^ 2 < rr
* rr
THEN f
= 0 xx = mx
yy = my
f = -1
x0 = xx
y0 = yy
t = 0
t = t + 1
IF (x
- x1
) ^ 2 + (y
- y1
) ^ 2 < rr
* rr
THEN a2 = 2 * a1 - a - pi
x0 = x
y0 = y
a = a2
t = 0