euclid.js icon indicating copy to clipboard operation
euclid.js copied to clipboard

Add a convenient way to set (mutate) the value of a Point

Open davjhan opened this issue 2 years ago • 1 comments

Currently, if I have a circle, there is no way to change the origin of the point to a given point.

There is translate(Point) and shift(x,y), but translate just invokes shift, and it moves the point, not sets it at the new point.

The current solution is to use the verbose constructor and go myCircle = new Circle(new Point(x,y),myCircle.radius).

Either offer a new interface method like Circle.setOrigin(Point) or Circle.setOrigin(x,y) or offer a Point.set(x,y) which will mutate the x and y variables in place.

davjhan avatar Mar 03 '22 05:03 davjhan

Thanks for suggesting this, @davjhan! Right now, all geometry objects are intentionally immutable, to make it easier to work with observable utilities and watching for changes. However, we'll definitely keep this in mind as we continue working on it.

plegner avatar Mar 04 '22 17:03 plegner