Request: interpolation

Discussion and feedback on Construct 2

Post » Sun Feb 24, 2013 8:24 pm

Lerp , ain't it ?
B
35
S
16
G
16
Posts: 2,222
Reputation: 16,589

Post » Mon Feb 25, 2013 4:21 pm

Thanks for the help guys, I'll look into the alternatives you posted if it doesn't get implemented.
Moderator
B
88
S
32
G
33
Posts: 3,005
Reputation: 27,422

Post » Wed Jul 17, 2013 10:29 am

These would still be great to have, especially since Classic had them!
B
134
S
65
G
16
Posts: 1,766
Reputation: 19,190

Post » Fri May 16, 2014 3:09 am

R0J0hound wrote: Here are the formulas:
qarp(a, b, c, t) = lerp(lerp(a,b,t), lerp(b,c,t), t)
cubic(a, b, c, d, t) = lerp(qarp(a,b,c,t), qarp(b,c,d,t), t)
cosp(a, b, t) = (a+b+(a-b)*cos(t*180))/2


thanks @R0J0hound

When I've use lerp to move sprites it seems to have built in "slow down" toward the end which is great. If I wanted this "slow down" at the beginning and the ending would I use qarp? (or your lerp(lerp(a,b,t), lerp(b,c,t), t)). I tried it when zooming out the layout and it doesn't seem to work like I expected...still feels like a regular old lerp.. since it starts zooming fast then gradually slows.

Code: Select all
Set Layout scale to lerp(lerp(LayoutScale,1,0.5*dt), lerp(1,4,0.5*dt), 0.5*dt)           


a=LayoutScale (which starts at 1.3)
b=1
c=4 (wasn't sure how steep to make the curve)
t=0.5*dt
B
52
S
13
G
7
Posts: 929
Reputation: 8,430

Post » Fri May 16, 2014 2:21 pm

jobel wrote:
R0J0hound wrote: Here are the formulas:
qarp(a, b, c, t) = lerp(lerp(a,b,t), lerp(b,c,t), t)
cubic(a, b, c, d, t) = lerp(qarp(a,b,c,t), qarp(b,c,d,t), t)
cosp(a, b, t) = (a+b+(a-b)*cos(t*180))/2


thanks @R0J0hound

When I've use lerp to move sprites it seems to have built in "slow down" toward the end which is great. If I wanted this "slow down" at the beginning and the ending would I use qarp? (or your lerp(lerp(a,b,t), lerp(b,c,t), t)). I tried it when zooming out the layout and it doesn't seem to work like I expected...still feels like a regular old lerp.. since it starts zooming fast then gradually slows.

Code: Select all
Set Layout scale to lerp(lerp(LayoutScale,1,0.5*dt), lerp(1,4,0.5*dt), 0.5*dt)           


a=LayoutScale (which starts at 1.3)
b=1
c=4 (wasn't sure how steep to make the curve)
t=0.5*dt


The "built in slowdown" comes from the use of lerp you are using, a is the variant in your case, so you have a "suite arithmétique" (not sure of the english term for that), that will go slower and slower towards the point. (it shouldn't even reach it, I never understood why people are using lerp like this)

To be exact, lerp(a, b, x) return the value between a and b, corresponding to the percentage (reminder of math: 1 = 100%) x, from a to b

lerp(a,b, 0) will return a, lerp(a, b, 1) will return b, lerp(a, b, 0.5) will return (a+b)/2.

The intended use is to make x varie (generally from 0 to 1, but it can go over that), for your zoom, you can have lerp(min value, max value, zoom percentage), and make the zoom percentage varying from 0 to 1 or 1 to 0 as you want it.

The qarp will be the same logic, but applied not in a linear fashion (a quadratic one, which I think means that a and c will be min and max, but b will be affecting the way it evolves with each values of t)

qarp (a, b, c, 0) will return a, qarp(a, b, c, 1) will return c, qarp (a, b, c, 0.5) will return ((a+b)/2+(b+c)/2)/2 = ((a+c)/2+b)/2 I think
https://www.scirra.com/forum/viewtopic.php?t=152506

And that is why you shall respect the bug reports guidelines, not only giving a capx is making the bug reproductible in one click in a situation they can work with (less time wasted trying to reproduce vague instructions) but also it helps filtering false positives.

Game design is all about decomposing the core of your game so it becomes simple instructions.
B
42
S
17
G
16
Posts: 2,094
Reputation: 15,355

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 8 guests