Added Point.subtract, for creating a vector from endpoints.
This commit is contained in:
@@ -52,6 +52,21 @@ public abstract class AbstractPoint implements IPoint
|
||||
return result.set(x() + x, y() + y);
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public Vector subtract (double x, double y) {
|
||||
return subtract(x, y, new Vector());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector subtract (double x, double y, Vector result) {
|
||||
return result.set(x() - x, y() - y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector subtract (IPoint other, Vector result) {
|
||||
return subtract(other.x(), other.y(), result);
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public Point rotate (double angle) {
|
||||
return rotate(angle, new Point());
|
||||
|
||||
@@ -43,6 +43,18 @@ public interface IPoint extends Cloneable
|
||||
* @return a reference to the result, for chaining. */
|
||||
Point add (double x, double y, Point result);
|
||||
|
||||
/** Subtracts the supplied point from {@code this}.
|
||||
* @return a new vector containing the result. */
|
||||
Vector subtract (double x, double y);
|
||||
|
||||
/** Subtracts the supplied point from {@code this} and stores the result in {@code result}.
|
||||
* @return a reference to the result, for chaining. */
|
||||
Vector subtract (double x, double y, Vector result);
|
||||
|
||||
/** Subtracts the supplied point from {@code this} and stores the result in {@code result}.
|
||||
* @return a reference to the result, for chaining. */
|
||||
Vector subtract (IPoint other, Vector result);
|
||||
|
||||
/** Rotates this point around the origin by the specified angle.
|
||||
* @return a new point containing the result. */
|
||||
Point rotate (double angle);
|
||||
|
||||
@@ -52,6 +52,21 @@ public abstract class AbstractPoint implements IPoint
|
||||
return result.set(x() + x, y() + y);
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public Vector subtract (float x, float y) {
|
||||
return subtract(x, y, new Vector());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector subtract (float x, float y, Vector result) {
|
||||
return result.set(x() - x, y() - y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector subtract (IPoint other, Vector result) {
|
||||
return subtract(other.x(), other.y(), result);
|
||||
}
|
||||
|
||||
@Override // from IPoint
|
||||
public Point rotate (float angle) {
|
||||
return rotate(angle, new Point());
|
||||
|
||||
@@ -43,6 +43,18 @@ public interface IPoint extends Cloneable
|
||||
* @return a reference to the result, for chaining. */
|
||||
Point add (float x, float y, Point result);
|
||||
|
||||
/** Subtracts the supplied point from {@code this}.
|
||||
* @return a new vector containing the result. */
|
||||
Vector subtract (float x, float y);
|
||||
|
||||
/** Subtracts the supplied point from {@code this} and stores the result in {@code result}.
|
||||
* @return a reference to the result, for chaining. */
|
||||
Vector subtract (float x, float y, Vector result);
|
||||
|
||||
/** Subtracts the supplied point from {@code this} and stores the result in {@code result}.
|
||||
* @return a reference to the result, for chaining. */
|
||||
Vector subtract (IPoint other, Vector result);
|
||||
|
||||
/** Rotates this point around the origin by the specified angle.
|
||||
* @return a new point containing the result. */
|
||||
Point rotate (float angle);
|
||||
|
||||
Reference in New Issue
Block a user