Fixed minor issues, moved some classes.

This commit is contained in:
sk89q
2011-01-23 02:03:49 -08:00
parent 2bb9a9390f
commit af1acd42b8
5 changed files with 111 additions and 37 deletions

View File

@@ -434,6 +434,18 @@ public class Vector {
return new Vector(x / n, y / n, z / n);
}
/**
* Get the length of the vector.
*
* @param pt
* @return distance
*/
public double length() {
return Math.sqrt(Math.pow(x, 2) +
Math.pow(y, 2) +
Math.pow(z, 2));
}
/**
* Get the distance away from a point.
*
@@ -458,6 +470,16 @@ public class Vector {
Math.pow(pt.z - z, 2);
}
/**
* Get the normalized vector.
*
* @param pt
* @return vector
*/
public Vector normalize() {
return divide(length());
}
/**
* Checks to see if a vector is contained with another.
*