/** * this may be called for vectors `a' with extremely small magnitude, for * example the result of a cross product on two nearly perpendicular vectors. * we must be robust to these small vectors. to prevent numerical error, * first find the component a[i] with the largest magnitude and then scale * all the components by 1/a[i]. then we can compute the length of `a' and * scale the components by 1/l. this has been verified to work with vectors * containing the smallest representable numbers. */ public void normalize() { if (!safeNormalize6()) throw new IllegalStateException( "Normalization failed: " + this); } }
/** * this may be called for vectors `a' with extremely small magnitude, for * example the result of a cross product on two nearly perpendicular vectors. * we must be robust to these small vectors. to prevent numerical error, * first find the component a[i] with the largest magnitude and then scale * all the components by 1/a[i]. then we can compute the length of `a' and * scale the components by 1/l. this has been verified to work with vectors * containing the smallest representable numbers. */ public void normalize() { if (!safeNormalize6()) throw new IllegalStateException( "Normalization failed: " + this); } }