Thanks for the fixes!
Well, for normalize(), the base Vector class does this:
public final Vector normalize() {
float len = length();
if (len != 0.0f) {
float l = 1.0f / len;
return scale(l);
} else {
assert false;
return this;
}
}
So it's probably best to follow suit. Assert false for those in debug mode, continue with as sane data as possible otherwise.
As for angle, not sure. An Exception is the
really correct result - but you don't want that! Use whatever you think is best, whether it be faking a zero result, or still returning NaN in that situation - using NaN at least lets the user take some action. Whichever you choose, add it to Javadoc as a special case and maybe check the lengths first - you can shortcut a dot-product and an acos that way?
Regarding 4D vectors - I just have no idea what I'd use them for...! :wink: