Vector lerp() function now takes in generalized dimensions - #8994
Vector lerp() function now takes in generalized dimensions#8994mawerb wants to merge 15 commits into
Conversation
perminder-17
left a comment
There was a problem hiding this comment.
Everything else looks good so far!
| * // META:norender | ||
| * function setup() { | ||
| * // Create a p5.Vector object. | ||
| * let v = createVector(1, 1, 1); | ||
| * | ||
| * // Interpolate with an array. | ||
| * v.lerp([3, 3, 3], 0.5); | ||
| * | ||
| * // Prints "p5.Vector Object : [2, 2, 2]" to the console. | ||
| * print(v.toString()); |
There was a problem hiding this comment.
One thought: if someone reads these examples, they have to open the console to see the output. Since multiple examples use the console, the messages can get mixed up. What do you think about using the text() function instead, so the output is shown directly on the canvas?
There was a problem hiding this comment.
thanks, agreed, switched the lerp examples to show the result on the canvas with text() so readers don’t need the console.
627e97a to
ec21120
Compare
|
This is looking really good, thanks both! |
|
Hey! I was just curious regarding the next steps for getting my pr approved. This is my first time contributing to p5.js so I’m unsure how it works |
|
@perminder-17 @ksen0 bump. How do i move forward with getting this PR approved? |
|
Hi @mawerb! Before merging we make sure that the branch is up-to-date with main, but when I did so, I think maybe a test was added elsewhere (or possibly if it was removed before git was confused about the update and it's back?) and is now failing: Do you think you could take a look at that test and help resolve the merge? Other than that, @perminder-17 anything else need updating in the code before merging? |
perminder-17
left a comment
There was a problem hiding this comment.
Really sorry for the delay, everything looks good to me! Approved!
Just the same concern on the test failure,
|
Thanks for catching that @davepagurek ! That test came back when merging with main. It was checking the old 3D behavior where v.lerp(vector, amt) got rewritten to four numeric arguments (x, y, z, amt). With the N-D update that rewrite is gone, since lerp now takes (values, amt) instead, so the assertion was outdated. I removed that test. The vector form is already covered by the behavior test that checks the resulting components. The suite is passing again on my end. |
Resolves #8927
Changes:
lerp()to take in generalized dimensions allowing for function to be called on vectors with more than 3 dimensions and mismatched._validatedVectorOperationdecorator to be able to take in trailingArgs in order to fit the case oflerp()where it follows the pattern of validating parameters its taking with ...args like themult(),add(),sub()functions but requiring the extra argumentamtlerp()works as intended on mismatched dimensions and vectors with dimensions > 3Screenshots of the change:

the 1 failed test was present before changes were made (it's the typography test)
PR Checklist
npm run lintpasses