A collection of useful mathematical functions for manipulation of vectors.
Methods
length(vector) |
Returns the magnitude of a single vector (float). |
distance(vector,vector) |
Returns the distance between two points (float). |
dot(vector,vector) |
Returns the dot product of two vectors (float). |
cross(vector,vector) |
Returns the cross product of two vectors (vector). |
normalize(vector) |
Returns a normalized vector with the same direction as the given vector and a length of 1. |
add(vector,vector) |
Returns a vector that is the sum of the two given vectors. |
subtract(vector,vector) |
Returns a vector that is the first vector minus the second vector. |
scale(vector,scale) |
Returns a vector scaled by the floating point value 'scale'. |
rotate(vector, rotation) |
Rotates the given Vector by the Rotation. |
orbitPosHeading(point, anglearound, angleevelation, distance) |
Returns a Vector position around a Vector defining a central point, then three floating point values defining the angle around the point (degrees), the elevation above the point (degrees) and the distance from the point. Used with RotationMath.orbitRot to set the rotation. If anglearound is zero you're looking along the Z axis. Note: This replaces orbitPos. |
min(vector,vector) |
Returns a Vector such that the x/y/z are the lowest individual x/y/z of the two supplied Vectors. |
max(vector,vector) |
Returns a Vector such that the x/y/z are the highest individual x/y/z of the two supplied Vectors. |
Examples
var myvector=new Vector(120,150,45);
var mag=VectorMath.length(myvector);
print("Magnitude of vector is "+mag);
See Also


