Request: interpolation

Discussion and feedback on Construct 2

Post » Sun Feb 24, 2013 8:24 pm

Lerp , ain't it ?
B
42
S
17
G
17
Posts: 2,247
Reputation: 17,461

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
94
S
33
G
33
Posts: 3,006
Reputation: 27,749

Post » Wed Jul 17, 2013 10:29 am

These would still be great to have, especially since Classic had them!
B
147
S
74
G
20
Posts: 1,786
Reputation: 22,527

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
97
S
32
G
15
Posts: 1,194
Reputation: 16,170

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
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Previous

Return to Construct 2 General

Who is online

Users browsing this forum: jobel, paxto22, tarek2 and 3 guests