Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / lagrange interpolation

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 5th Apr 2013 02:26 Edited at: 5th Apr 2013 02:28
I finally managed to implement one of the many spline movements I was looking into and lagrange is the one I think will work best for me. However, I have a problem with reversing the prediction.

The lagrange works on a set of waypoints (my use of this is waypoints) but when I want to reverse the system, it "bounces" rather than reverses the wave.

I thought it would be easy to make a variation for a reverse case, but it has stumped me. I'm sure others will benefit from this great interpolation system, but I really need it to be reversible... can anyone help?

Here's an implementation:

I set up an array of co-ordinates which works ok until I need to return in the other direction.



You can see I set up another version of the function to test reverse scenarios

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 5th Apr 2013 09:48
you can better see what happens if you paint the positions:


Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 5th Apr 2013 21:37 Edited at: 5th Apr 2013 21:39
Looks to work ok to me.

(offsetting the return journey by 100 so it doesn't hide the green)


or am I not understanding the problem. (or indeed did Markus fix the problem with the recode?)

Edit: wait are you wanting it to continue down as it comes back?

Attachments

Login to view attachments
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 5th Apr 2013 21:48
Yes, I think painting them misses the point.
Look at my first one again and see that the movement bounces back.
I would want the return journey to be a smooth interpolation, so when going through the last point, it should curve back up.

I think this might be impossible with lagrange now, as it uses the whole set of points, so the solution may be to replot the points for the reverse journey.

I would want to do this anyway if I was going to use it in pathing, but I think messing with the points would interfere with the flow as soon as you did it?

nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 6th Apr 2013 01:58
On further investigation, this isn't any good for what I want. The lagrange formula is useful if you *must* intersect the points, but it has a couple of fails:

can't use the same Y value on the set or it breaks
uses the whole set of X to plot the Y.

After messing with beziers, this seems to be better and more flexible (but harder to implement)

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 6th Apr 2013 11:06 Edited at: 6th Apr 2013 11:55
maybe you can add a last point that the curve go flat.

here a bezier interpolation in agk example but the control points are different.

Login to post a reply

Server time is: 2024-11-24 11:46:29
Your offset time is: 2024-11-24 11:46:29