no need to recreate the wheel again:
use Vector hermite, CattMullRom, Barrycentric, Interpolation:
Hrmite, Catmollrum are used as well in 2D graphics software to create curves.
compile the following 2 examples then use arrowkeys to see the results:
set display mode 1024, 768, 32
sync on : sync rate 60
#constant P0 1
#constant P1 2
#constant P2 3
#constant P3 4
#constant P 5
make vector2 P0
make vector2 P1
make vector2 P2
make vector2 P3
make vector2 P
Set Vector2 P0, 400, 300
Set Vector2 P1, 400, 450 `power point
Set Vector2 P2, 700, 300
Set Vector2 P3, 700, 450 `power point
_x1# = 400
_y1# = 450
do
cls
ink 0xFFFFFFFF : circle 400, 300, 5
ink 0xFF00FF00 : circle _x1#, _y1#, 5 `power point
ink 0xFFFFFFFF : circle 700, 300, 5
ink 0xFF00FF00 : circle 700, 450, 5 `power point
`CatmullRom Vector2 P, P0, P1, P2, P3, t#
_x1# = _x1# + (rightkey() - leftkey())
_y1# = _y1# + (downkey() - upkey())
Set Vector2 P1, _x1#, _y1#
for t# = 0.0 to 1.0 step 0.02
Hermite Vector2 P, P0, P1, P2, P3, t#
dot X Vector2(P), Y Vector2(P), 0xFFFF0000
Next
sync
LOOP
set display mode 1024, 768, 32
sync on : sync rate 60
#constant P0 1
#constant P1 2
#constant P2 3
#constant P3 4
#constant P 5
make vector2 P0
make vector2 P1
make vector2 P2
make vector2 P3
make vector2 P
Set Vector2 P0, 100, 300
Set Vector2 P1, 400, 450
Set Vector2 P2, 700, 300
Set Vector2 P3, 1000, 450
t# = 1
do
ink 0xFFFFFFFF
circle 100, 300, 5
circle 400, 450, 5
circle 700, 300, 5
circle 1000, 450, 5
if upkey() then inc t#, 0.01
if downkey() then dec t#, 0.01
if t# > 1 then t# = 1
if t# < 0 then t# = 0
CatmullRom Vector2 P, P0, P1, P2, P3, t#
`Hermite Vector2 P, P0, P1, P2, P3, t#
ink 0xFFFF0000
circle X Vector2(P), Y Vector2(P), 5
`print t#
`print X Vector2(P)
`print Y Vector2(P)
sync
LOOP