Added Vector.subtract that takes individual components.

Closes #11.
This commit is contained in:
Michael Bayne
2012-04-30 15:14:26 -07:00
parent 7048d8231b
commit b7c2d6f420
2 changed files with 18 additions and 0 deletions
@@ -136,6 +136,16 @@ public abstract class AbstractVector implements IVector
return result.set(x() + x, y() + y);
}
@Override // from interface IVector
public Vector subtract (float x, float y) {
return subtract(x, y, new Vector());
}
@Override // from interface IVector
public Vector subtract (float x, float y, Vector result) {
return result.set(x() - x, y() - y);
}
@Override // from interface IVector
public Vector addScaled (IVector other, float v) {
return addScaled(other, v, new Vector());
+8
View File
@@ -115,6 +115,14 @@ public interface IVector
* @return a reference to the result, for chaining. */
Vector subtract (IVector other, Vector result);
/** Subtracts a vector from this one.
* @return a new vector containing the result. */
Vector subtract (float x, float y);
/** Subtracts a vector from this one and places the result in the supplied object.
* @return a reference to the result, for chaining. */
Vector subtract (float x, float y, Vector result);
/** Rotates this vector by the specified angle.
* @return a new vector containing the result. */
Vector rotate (float angle);