Replaced assertion with proper exception in Vector.java

This commit is contained in:
Elias Naur 2004-08-20 08:58:50 +00:00
parent 309ef6b06e
commit 68e4faf560
1 changed files with 20 additions and 22 deletions

View File

@ -64,12 +64,12 @@ public abstract class Vector implements Serializable, ReadableVector {
*/ */
public abstract float lengthSquared(); public abstract float lengthSquared();
/** /**
* Load this vector from a FloatBuffer * Load this vector from a FloatBuffer
* @param buf The buffer to load it from, at the current position * @param buf The buffer to load it from, at the current position
* @return this * @return this
*/ */
public abstract Vector load(FloatBuffer buf); public abstract Vector load(FloatBuffer buf);
/** /**
* Negate a vector * Negate a vector
@ -87,27 +87,25 @@ public abstract class Vector implements Serializable, ReadableVector {
if (len != 0.0f) { if (len != 0.0f) {
float l = 1.0f / len; float l = 1.0f / len;
return scale(l); return scale(l);
} else { } else
assert false; throw new IllegalStateException("Zero length vector");
return this;
}
} }
/** /**
* Store this vector in a FloatBuffer * Store this vector in a FloatBuffer
* @param buf The buffer to store it in, at the current position * @param buf The buffer to store it in, at the current position
* @return this * @return this
*/ */
public abstract Vector store(FloatBuffer buf); public abstract Vector store(FloatBuffer buf);
/** /**
* Scale this vector * Scale this vector
* @param scale The scale factor * @param scale The scale factor
* @return this * @return this
*/ */
public abstract Vector scale(float scale); public abstract Vector scale(float scale);