Jump to content
Sign in to follow this  
super-truite

factor and interpolate

Recommended Posts

I am making some particle effects and I need to use engine defined variables to define some parameters. Like in this example:

interval = "0.001 * (damage interpolate [0,2.5,1,8])";

I am a bit confused about the functions "factor" and "interpolate" (https://community.bistudio.com/wiki/Simple_Expression).

Shouldn't it be something like this instead:

a factor [x,y] =  a<=x: 0
                 a>=y: 1
                 x<a<y: (a-x)/(y-x)

So that:

a interpolate [p,q,r,s] = a<=p:r
                         a>q:s
                         x<a<y: [(a-p)/(q-p)]*(s-r) +r

This way it actually is a linear interpolation between the 2D points (p,r) and (q,s)?

I could in principle test this, but this is really painful to do since I can use this only in configs and I have to exit/launch the game after each changes...

Edited by super-truite

Share this post


Link to post
Share on other sites

Yeah, you are right. There is just typo in your explanation of interpolate. It is:

a interpolate [p,q,r,s] = a<=p:r
                         a>=q:s
                         p<a<q: [(a-p)/(q-p)]*(s-r) +r

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×