User Guide
398 Chapter 17: Controlling the 3D World
Vector methods
Use these methods to work with vectors:
Vector binary operations
Use these syntaxes to perform additional vector math calculations:
Note: JavaScript does not support these operations for vector objects. In JavaScript, you must write
the code to perform the vector math calculations using the vectors’ x, y, and z coordinates.
Method Description Returns
normalize()
Normalizes the vector by modifying it into a unit vector of
length 1. This is done by dividing each component of the
vector by the vector’s original length. That original length
is the square root of the sum of the squares of each
component.
Nothing. Vector is
modified.
get
Normalized()
Returns a normalized version of the vector. A new vector object.
dot(vector2)
Returns the dot (inner) product of the first vector and the
second vector (
vector2). If both vectors are of unit
length, the result is the cosine of the angle between the
two vectors.
Dot product of the
two vectors.
angleBetween
(vector2)
Returns the angle between vector and vector2, in
degrees.
Value of the angle in
degrees.
cross(vector2)
or
crossProduct
(vector2)
or
perpendicular
To(vector2)
Returns a vector perpendicular to the original vector and
to
vector2.
A new vector object.
distanceTo
(vector2)
Returns the distance between vector and vector2. If
these vectors represent positions in the 3D world, this is
the distance between them.
Floating-point value
of distance.
duplicate()
A copy of the vector. A new vector object.
Operator Description Returns
vector1 +vector2
Returns a new vector equaling vector1 +vector2 for x
equaling 1 through 3.
A new vector object
vector1 -vector2
Returns a new vector equaling
vector1 -vector2 for x equaling 1 through 3.
A new vector object
vector1*
vector2
Returns the product of the two vectors. A floating-point value
vector1/vector2
Not supported.
0
vector2*scalar
Returns a new vector equaling
vector2 * scalar for x equaling 1 through 3.
A new vector object