diff --git a/src/main/java/pythagoras/d/AbstractPoint.java b/src/main/java/pythagoras/d/AbstractPoint.java index b9e16ea..91ae5c3 100644 --- a/src/main/java/pythagoras/d/AbstractPoint.java +++ b/src/main/java/pythagoras/d/AbstractPoint.java @@ -57,17 +57,22 @@ public abstract class AbstractPoint implements IPoint return result.set(x() + x, y() + y); } + @Override // from IPoint + public Point add (XY other, Point result) { + return add(other.x(), other.y(), result); + } + @Override // from IPoint public Point subtract (double x, double y) { return subtract(x, y, new Point()); } - @Override + @Override // from IPoint public Point subtract (double x, double y, Point result) { return result.set(x() - x, y() - y); } - @Override + @Override // from IPoint public Point subtract (XY other, Point result) { return subtract(other.x(), other.y(), result); } diff --git a/src/main/java/pythagoras/d/IPoint.java b/src/main/java/pythagoras/d/IPoint.java index 58dfb4d..e5d2700 100644 --- a/src/main/java/pythagoras/d/IPoint.java +++ b/src/main/java/pythagoras/d/IPoint.java @@ -41,6 +41,10 @@ public interface IPoint extends XY, Cloneable * @return a reference to the result, for chaining. */ Point add (double x, double y, Point result); + /** Translates this point by the specified offset and stores the result in the object provided. + * @return a reference to the result, for chaining. */ + Point add (XY other, Point result); + /** Subtracts the supplied point from {@code this}. * @return a new point containing the result. */ Point subtract (double x, double y); diff --git a/src/main/java/pythagoras/f/AbstractPoint.java b/src/main/java/pythagoras/f/AbstractPoint.java index 7cdec75..f7b01af 100644 --- a/src/main/java/pythagoras/f/AbstractPoint.java +++ b/src/main/java/pythagoras/f/AbstractPoint.java @@ -57,17 +57,22 @@ public abstract class AbstractPoint implements IPoint return result.set(x() + x, y() + y); } + @Override // from IPoint + public Point add (XY other, Point result) { + return add(other.x(), other.y(), result); + } + @Override // from IPoint public Point subtract (float x, float y) { return subtract(x, y, new Point()); } - @Override + @Override // from IPoint public Point subtract (float x, float y, Point result) { return result.set(x() - x, y() - y); } - @Override + @Override // from IPoint public Point subtract (XY other, Point result) { return subtract(other.x(), other.y(), result); } diff --git a/src/main/java/pythagoras/f/IPoint.java b/src/main/java/pythagoras/f/IPoint.java index 86b9ada..fb2e05b 100644 --- a/src/main/java/pythagoras/f/IPoint.java +++ b/src/main/java/pythagoras/f/IPoint.java @@ -41,6 +41,10 @@ public interface IPoint extends XY, Cloneable * @return a reference to the result, for chaining. */ Point add (float x, float y, Point result); + /** Translates this point by the specified offset and stores the result in the object provided. + * @return a reference to the result, for chaining. */ + Point add (XY other, Point result); + /** Subtracts the supplied point from {@code this}. * @return a new point containing the result. */ Point subtract (float x, float y);