code: public static Vector3d normalizeSafe(Vector3d v) {
          try {
              return v.normalize();
          } catch (ArithmeticException ex) {
              return Vector3d.ZERO;
          }
      }
docs: Attempts to normalize a vector. If this fails, the method catches the exception and return a zero vector of the same dimension instead.
  
  @param v The vector to attempt to normalize
  @return The normalized vector, or the zero vector if it couldn't be normalized.