Hi there.
As I'm still working on my 3D engine, this is an example I just made to draw the simplest interpolation ever possible and find the y value for an x one.
I know it's confusing stated like this, but just try the snippet and see for yourself:
Using this, you can now draw arc-based splines (no control points yet) and get the Y value along the curve by an X offset.
The code illustrates a simple animation, the got point moves a step at a time.
It's made out in 10 minutes and it's really poor, but an interesting start point.
set display mode 640, 480, 32
set window on
sync on
x1 = 320
y1 = 65
x2 = 135
y2 = 233
x3 = 0
do
cls
x2 = mousex()
y2 = mousey()
drawArc(x1, y1, x2, y2, spacekey())
arcPoint(x1, y1, x2, y2, spacekey(), x3)
x3 = x3 + 1
if x3 > (x2 - x1) then x3 = 0
circle x1, y1, 3
circle x2, y2, 3
sync
loop
function drawArc(lx1 as integer, ly1 as integer, lx2 as integer, ly2 as integer, straight as integer)
if straight
for a = 180 to 270
dot lx2 + sin(a) * (lx2 - lx1), ly1 + -1 * cos(a) * (ly2 - ly1)
next a
else
for a = 0 to 90
dot lx1 + sin(a) * (lx2 - lx1), ly2 + -1 * cos(a) * (ly2 - ly1)
next a
endif
endfunction
function arcPoint(lx1 as integer, ly1 as integer, lx2 as integer, ly2 as integer, straight as integer, xo as integer)
if straight
for a = 180 to 270
if ((lx2 + sin(a) * (lx2 - lx1)) > (xo + lx1)) and ((lx2 + sin(a + 1) * (lx2 - lx1)) < (xo + lx1))
circle lx2 + sin(a) * (lx2 - lx1), ly1 + -1 * cos(a) * (ly2 - ly1), 3
endif
next a
else
for a = 0 to 90
if ((lx1 + sin(a + 1) * (lx2 - lx1)) > (xo + lx1)) and ((lx1 + sin(a) * (lx2 - lx1)) < (xo + lx1))
circle lx1 + sin(a) * (lx2 - lx1), ly2 + -1 * cos(a) * (ly2 - ly1), 3
endif
next a
endif
endfunction
Share comments

(suggestions _highly_ welcome)
.
Bye, Berserk.
.