alexbol99 / flatten-js

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

Add translate, rotate and other affine transformations to all classes #119

Closed mscofield0 closed 1 year ago

mscofield0 commented 2 years ago

I'm trying to use a Box as a sort of underlying entity representation which has its own position and rotation, but I can see that Box, and many other classes do not have such methods on them. Would you be willing to add them?

AimForNaN commented 1 year ago

Would like to see this implemented as well. The lack of this feature is the only thing preventing me from using this library.

alexbol99 commented 1 year ago

Hi, @mscofield0 Shapes in this library represent math abstractions rather then entities in some scene. Then segment.translate creates a new segment object, and not set a position of a segment entity in the scene. Box.rotate() method cannot be implemented because box defined as axis-aligned box, rotated box will become a polygon, this is not what you intended, I guess. But I agree, some classes lack of transformation methods