Node Wish List

 From:  bemfarmer
9581.212 In reply to 9581.211 
Michael's randomize script defines two simple Lerp functions.

code:
function Lerp( low, high, t )
{
	return low + (high-low)*t;
}

function RandLerp( low, high )
{
	return Lerp( low, high, Math.random() );
}


Wikipedia has a more accurate return formula, for floating point. (?)

Need to define Lerp function for vectors, (x, y, z points).

Linearly interpolate between vector v1, and vector v2.

lerpVectors ( v1, v2, interpolationFactor )
v1 - the starting vectpr.
v2 - the vector to interpolate towards.
interpolation factor, typically in the closed interval [0, 1].

- Brian

So regular javascript does not have a lerp function (?)
So the 3d lerp function must be defined in terms of simpler javascript commands.

Found 2d lerp function here:
https://www.redblobgames.com/grids/line-drawing.html

code:
1d: function lerp(start, end, t) {
    return start + t * (end-start);
}

function lerp_point(p0, p1, t) {
    return new Point(lerp(p0.x, p1.x, t),
                     lerp(p0.y, p1.y, t));
}


Note: to do 3d vector lerp, add
code:
 lerp(p0.z, p1.z, t) 
to the redblob code.

(Use vectorLerp() (?))


This vectorLerp is a bit confusing...negative numbers? low > high, clamping t? angleLerp vs quaternionLerp, floating point problems...


But I think that this proposed node is relatively easy to do, once understood.

Then smooth motion Move of an object could be done...

t is usually between [0, 1], but does not have to be.
negative t might be a problem?
Negative low and high, and low > high might be problems?

A good link: https://danielilett.com/2019-09-08-unity-tips-3-interpolation/

EDITED: 16 Aug 2020 by BEMFARMER