Closed Smilebags closed 7 years ago
I am trying to implement n dimensional lerp function, but it is really quite hard when the equation for it is this:
That does indeed look quite complicated. I'll have a closer look at the p5.Vector lerp and see if there is an easier way to implement it. I have a feeling simply adding a certain percentage of the new vector to the existing one might work, but maybe that's not mathematically correct;
v1 = new nVector(1,1,1,1); v2 = new nVector(1,2,3,4);
v1.nLerp(v2, 0.5); // should set v1 to 1, 1.5, 2, 2.5 I think. Maybe my understanding of the function is incorrect.
For your understanding, lerp or Linear interpolation, is the midpoint between two vectors. Example:
Not necessarily the midpoint, but just some position along the line between the two points. for example:
v1 = new nVector(1,1,1,1); v2 = new nVector(1,2,3,4); v1.nLerp(v2, 0.1); // should set v1 to 1, 1.1, 1.2, 1.3
I've committed an initial implementation of nLerp. I'll do some testing to see if it behaves correctly.
You can remove normalize and setMag off the list.
Yes, most of these are complete now.
We have completed all the initial functions from p5.Vector. Great work! Next I think we should work on adding this.nAdd(v2) functionality, which should behave the same as nAdd(v1,v2) I have tried adding that functionality to a few functions but I don't believe it is working.
I think it would be good if all possible standard vector functions in p5.Vector.js were also implemented here in the same manner. Currently I'm adding 'n' to the start of the functions but this convention could change.
The ones I can see which are missing from p5.Dimensions are:
These might be not as useful/not easy to implement. fromAngle heading rotate angleBetween