Most appropriate sub-area of p5.js?
p5.js version
2.3.0
Web browser and version
Brave 1.90.122
Operating system
Linux Mint 22.1
Steps to reproduce this
Steps:
- Create two 4D vectors
- Use lerp() to interpolate between the two
- Note the result only works for the first three dimensions
Snippet:
function setup() {
let v1 = createVector(0, 1, 0, 1);
let v2 = createVector(1, 0, 1, 0);
v1.lerp(v2, 0.5);
// v1 should be vector[0.5, 0.5, 0.5, 0.5], but is actually vector[0.5, 0.5, 0.5, 1]
print(v1.toString());
}
Discussion
lerp() currently computes x, y, and z individually. To extend to vectors of any dimension, other vector methods can be used, like p5.Vector.add(v1, p5.Vector.sub(v2, v1).mult(c)). Of course, this needs to be adapted to both the instance and static methods.
Most appropriate sub-area of p5.js?
p5.js version
2.3.0
Web browser and version
Brave 1.90.122
Operating system
Linux Mint 22.1
Steps to reproduce this
Steps:
Snippet:
Discussion
lerp()currently computes x, y, and z individually. To extend to vectors of any dimension, other vector methods can be used, likep5.Vector.add(v1, p5.Vector.sub(v2, v1).mult(c)). Of course, this needs to be adapted to both the instance and static methods.