alexbol99 / flatten-js

Javascript library for 2d geometry
MIT License
551 stars 58 forks source link

Adding Point to Vector #156

Closed edemaine closed 9 months ago

edemaine commented 10 months ago

It seems that it's not possible to add a Point to a Vector (which should produce a Point).

One natural interface would be to add Point.prototype.add with a Vector argument. Ideally we could also support an override on Vector.prototype.add.

Another natural interface would be to add Point.prototype.translate with a Vector argument. This is perhaps more in line with e.g. Polygon.prototype.translate.

Or we could support both. I'm happy to work on a PR if that's helpful.

alexbol99 commented 10 months ago

Hi, @edemaine , Shape.translate accepts Vector argument, and Point extend Shape. I think this is good enough, no need for special add method for point.

edemaine commented 10 months ago

Ahh indeed. Is this in the types? I somehow missed it, but maybe because it's not listed in the docs under Point...

alexbol99 commented 10 months ago

Not listed in Point because it is not in Point. Docs are auto generated.