code: private static Double3D normalizeDouble3D(Double3D vector) {
          double invertedlen = 1.0D / Math.sqrt(vector.x * vector.x + vector.y
                  * vector.y + vector.z * vector.z);
          if ((invertedlen == (1.0D / 0.0D)) || (invertedlen == (-1.0D / 0.0D))
                  || (invertedlen == 0.0D) || (invertedlen != invertedlen))
              throw new ArithmeticException("Vector length is "
                      + Math.sqrt(vector.x * vector.x + vector.y * vector.y
                              + vector.z * vector.z) + ", cannot normalize");
          return new Double3D(vector.x * invertedlen, vector.y * invertedlen,
                  vector.z * invertedlen);
      }
docs: Normalize a Double3D object
  
  @param vector
  @return the normalized vector