Victor.js – 2D Vectors for JavaScript
victorjs.org
victorjs.org
I'm afraid you have to calculate the intersections yourself though. I know there is a Processing(.org) plugin that does that kind of thing (might be called "intersection") and Processing can export to JS. I hope this helps at least a little bit.
I was thinking of the use of a JS sugaring compiler that splits the vector up into into 2 numbers (2 arguments for functions, 2 variables when declaring, etc). Alternatively some way to combine the two numbers into one and splitting them again each time the vector is used. Both give you an immutable vector implementation that also has 0 allocations.
This can make a big difference in usability and performance for game-like applications. Any ideas?
.subtractY(vector)
.multiplyY(scalar)
that bothers me a bit .rotate(angle)
.rotateBy(angle)
that seems to be a bit... of a weird default? rotate and rotateTo would be more expected personallyIt clearly shows how silly downvoting is.
Yet your documentation rocks. And I thought it had to be said.