romgrk / 2d-geometry

Performant & ergonomic 2D geometry in Typescript
MIT License
30 stars 2 forks source link

Feature Request add Vector.add(x:number, y:number) methods #2

Open davjhan opened 2 months ago

davjhan commented 2 months ago

Currently, Vector methods like .add and .subtract take as input, a vector object. This means that one may be forced to create a new Vector object unnecessarily. It would be great to have a method that takes in x and y scalars directly to improve memory performance.

romgrk commented 2 months ago

Very open to it, I've been removing allocations as much as possible, as well as adding mutable methods where it makes sense. You can submit a PR for it or I'll probably get to it once I have another pass at vector.ts.