/** * Change a vector into a vector with magnitude of one. * * @param vector 3d vector */ static double[] unitVector(double[] vector) { if (vector.length != 3) throw new IllegalArgumentException("Argument not a 3-D vector <dim=" + vector.length + ">."); double magnitude = vectorMagnitude(vector); double[] resultingVector = {vector[0] / magnitude, vector[1] / magnitude, vector[2] / magnitude}; return (resultingVector); }
/** * Change a vector into a vector with magnitude of one. * * @param vector 3d vector */ static double[] unitVector(double[] vector) { if (vector.length != 3) throw new IllegalArgumentException("Argument not a 3-D vector <dim=" + vector.length + ">."); double magnitude = vectorMagnitude(vector); double[] resultingVector = {vector[0] / magnitude, vector[1] / magnitude, vector[2] / magnitude}; return (resultingVector); }
/** * Change a vector into a vector with magnitude of one. * * @param vector 3d vector */ static double[] unitVector(double[] vector) { if (vector.length != 3) throw new IllegalArgumentException("Argument not a 3-D vector <dim=" + vector.length + ">."); double magnitude = vectorMagnitude(vector); return (new double[]{vector[0] / magnitude, vector[1] / magnitude, vector[2] / magnitude}); }
/ Math.pow(VectorMath.vectorMagnitude(surfaceNormal), 2.0);
/ Math.pow(VectorMath.vectorMagnitude(surfaceNormal), 2.0);
/ Math.pow(VectorMath.vectorMagnitude(surfaceNormal), 2.0);