I've tried to make a useful distinction between Point and Vector, but sometimes
you just want to use a Vector as a Point. I'm not going to add Point3 and try
to push this distinction into the third dimension, so I'll accommodate using
Vector as Point in 2D, and we'll just use Vector3 as a 3D point when needed.
We need SBT to publish to the local Ivy repository, so that we can reference
snapshots from other SBT projects. Pulling a snapshot from the local Maven
repository just doesn't seem to work with SBT+Ivy.
- Moved Vector.direction to Point.direction as that makes more sense. If you
want to know the angle of the vector between two points, you should do that
on points, not vectors.
- Added Vector.angle() which returns the angle of the vector (in polar
coordinates), which matches Vector.length() which returns the magnitude of
the vector (in polar coordinates).
- Added Vectors.fromPolar to create a vector from polar coordinates, and added
Vector.setLength and Vector.setAngle to set the one whilst preserving the
other.
As Tim points out, vector multiplication implies dot or cross products. These
methods are scaling, not multiplying. Cross product coming in a future commit.
FloatMath contains only shim methods that convert double Math methods to float,
but extends MathUtil so that library users can easily access everything via one
class. MathUtil is used internally so that I can convert pythagoras.f to
pythagoras.d with a few sed expressions. And MathUtil would be what users of
pythagoras.d would want to use for their lerping, clamping and stringifying.
In anticipation of the saying of nay, I offer this: these are value classes,
and in a civilized language, I wouldn't have setters either. "foo.x = x" would
call a setter method over which I had control. However, rather than throwing my
hands up and saying "Gee, I have to have verbose setters, so I guess I better
have verbose getters," I say, "I'll take what I can get."
Methods that verb can be verbs, and we can all agree to understand that methods
that are nouns are getters. foo.width() does not width my foo, it's my foo's
width. foo.invert() inverts up my foo, it is not some attribute of my foo's
nonsensically named invert. I don't want to add my foo's getWidth and
getHeight, I want to add my foo's width and height. So why should I have to
type get over and over again just because I want to protect myself from future
representation change? (Or in this case, to offer immutable views of my value
classes.)