Most appropriate sub-area of p5.js?
p5.js version
2.0.5
Web browser and version
Chrome
Operating system
Windows
Steps to reproduce this
Steps:
- Create a vector without arguments.
- Create a 2D vector and subtract the vector you prepared earlier.
- The third component will be NaN. Furthermore, If you apply rotate() to it, all components will become NaN.
Snippet:
function setup() {
createCanvas(400,400);
const v=createVector(100,0);
const w=createVector();
v.sub(w);
console.log(v.toString());
v.rotate(1);
console.log(v.toString());
}
If you explicitly make it two-dimensional with two zeros, there is no problem.
This issue has been occurring since version 2.0.0. It has not occurred in version 1.x.
Specifying a value without arguments is a common practice when creating a default vector, whether in two or three dimensions, so I thought this could be inconvenient in some cases.