Hi Dan,
Thanks for your Channel, I am learning so much out of it.
Here, I'll be referring to your video "Processing / p5.js Tutorial: What is lerp? (Linear Interpolation)" on YT.
Although the smoothing effect is really (really) cool, and although most people actually use Lerp like this (thus I'm sure I'll be heavily criticized for this message! I hope I'll still manage to get my point across), my understanding is that it's not actually what it is meant to be doing (I mean generally speaking, outside Processing).
In the video linearity is indeed used from the current position to the next... ok, fine!, point taken... (by the way, on a side note, the current position will "mathematically" never reach the target, it will tend to it). But is this really linearity?
Shouldn't lerp be used to move from a starting position to the target with the intermediate positions linearly distributed along the path? (i.e with a constant "linear" speed).
Modifying the code from the video, here's what I'm trying to say:
float start = 0;
float curr;
float target = 300;
float lerpamount;
void setup() {
size(600,400);
lerpamount = 0;
}
void draw() {
curr = lerp(start, target, constrain(lerpamount, 0, 1));
lerpamount += 0.02;
background(51);
stroke(255);
fill(255, 0, 175);
ellipse(target, 200, 64, 64);
fill(175, 0, 255);
ellipse(curr, 200, 64, 64);
}
Again, I know lerp is often used to smooth the way, I am not arguing about that (and that doesn't make it right), but that should maybe be the goal of another function (the Vector3 moveTowards in Unity3D for instance) where we could have the speed accelerate or decelerate as needed.
I actually found another video (about Unity3D) that probably will explain it better than me (at least the first half is great : "Unity3D Learn to Lerp... Correctly!" ).
This is just my humble understanding (being only an amateur coder!) and I would be happily be proven wrong as long as I learn something out of it.
Thanks for the great work!
FredL
Hi Dan,
Thanks for your Channel, I am learning so much out of it.
Here, I'll be referring to your video "Processing / p5.js Tutorial: What is lerp? (Linear Interpolation)" on YT.
Although the smoothing effect is really (really) cool, and although most people actually use Lerp like this (thus I'm sure I'll be heavily criticized for this message! I hope I'll still manage to get my point across), my understanding is that it's not actually what it is meant to be doing (I mean generally speaking, outside Processing).
In the video linearity is indeed used from the current position to the next... ok, fine!, point taken... (by the way, on a side note, the current position will "mathematically" never reach the target, it will tend to it). But is this really linearity?
Shouldn't lerp be used to move from a starting position to the target with the intermediate positions linearly distributed along the path? (i.e with a constant "linear" speed).
Modifying the code from the video, here's what I'm trying to say:
Again, I know lerp is often used to smooth the way, I am not arguing about that (and that doesn't make it right), but that should maybe be the goal of another function (the Vector3 moveTowards in Unity3D for instance) where we could have the speed accelerate or decelerate as needed.
I actually found another video (about Unity3D) that probably will explain it better than me (at least the first half is great : "Unity3D Learn to Lerp... Correctly!" ).
This is just my humble understanding (being only an amateur coder!) and I would be happily be proven wrong as long as I learn something out of it.
Thanks for the great work!
FredL