samskivert / pythagoras

A portable library of geometry classes for Java
Apache License 2.0
44 stars 14 forks source link

Vector subtract overload missing #11

Closed bootstraponline closed 12 years ago

bootstraponline commented 12 years ago

add (float x, float y) exists, however there's no corresponding version for subtraction.

@Override // from interface IVector
public Vector subtract (float x, float y) {
  return subtract(x, y, new Vector());
}
samskivert commented 12 years ago

That's because you can call Vector.add(-x, -y) if you already have the components.

That is minutely more expensive than direct subtraction, but clearly performance is not an issue if you're asking for the version that creates a new Vector in which to store the result.

I could see the value of expanding the API to include Vector.subtract(x, y, Vector result). Anyway, I'll add them both, it's not a big deal.