Lissajous Curve TableAuthor:
@FellippeHeitorSource: qb64.org Forum
URL:
https://www.qb64.org/forum/index.php?topic=683.0Version: « Reply #8 on: October 09, 2018, 02:48:07 PM »
Tags: [2D], [Graphics], [Mathematics]
Description:
Graphical Lissajou's Figures. For added eye-candy-ness, I've changed the plot line to paint using HSB colors so that ink color will vary according to the current rotational angle.Source Code:
_TITLE "Lissajous Curve Table"
setup:
angle = 0
w = 80
d = w - 0.2 * w
r = d / 2
cx = w + i * w + w / 2
cy = w / 2
x
= r
* COS(angle
* (i
+ 1) - _PI(.5)) y
= r
* SIN(angle
* (i
+ 1) - _PI(.5))
CircleFill cx
+ x
, cy
+ y
, 4, _RGB32(28, 222, 50) CircleFill cx
+ x
, cy
+ y
, 2, _RGB32(11, 33, 249)
dot(j, i).x = cx + x
cx = w / 2
cy = w + i * w + w / 2
x
= r
* COS(angle
* (i
+ 1) - _PI(.5)) y
= r
* SIN(angle
* (i
+ 1) - _PI(.5))
CircleFill cx
+ x
, cy
+ y
, 4, _RGB32(28, 222, 50) CircleFill cx
+ x
, cy
+ y
, 2, _RGB32(11, 33, 249)
dot(i, j).y = cy + y
CircleFill dot
(j
, i
).x
, dot
(j
, i
).y
, 1, hsb
(_R2D(angle
), 127, 127, 255)
angle = angle + 0.01
x0 = R
y0 = 0
e = -R
y0 = y0 + 1
LINE (x
- x0
, y
+ y0
)-(x
+ x0
, y
+ y0
), C
, BF
LINE (x
- x0
, y
- y0
)-(x
+ x0
, y
- y0
), C
, BF
e = e + 2 * y0
LINE (x
- y0
, y
- x0
)-(x
+ y0
, y
- x0
), C
, BF
LINE (x
- y0
, y
+ x0
)-(x
+ y0
, y
+ x0
), C
, BF
x0 = x0 - 1
e = e - 2 * x0
LINE (x
- R
, y
)-(x
+ R
, y
), C
, BF
FUNCTION map!
(value!
, minRange!
, maxRange!
, newMinRange!
, newMaxRange!
) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!
H = map(__H, 0, 255, 0, 360)
S = map(__S, 0, 255, 0, 1)
B = map(__B, 0, 255, 0, 1)
hsb~&
= _RGBA32(B
* 255, B
* 255, B
* 255, A
)
fmx = B - (B * S) + S
fmn = B + (B * S) - S
fmx = B + (B * S)
fmn = B - (B * S)
H = H - 360
H = H / 60
H
= H
- (2 * INT(((iSextant
+ 1) MOD 6) / 2))
fmd = (H * (fmx - fmn)) + fmn
fmd = fmn - (H * (fmx - fmn))