User Guide
Controlling the 3D World 525
Vector creation commands
Use these functions to create vectors:
Vector properties
Use these properties to work with vectors:
Vector commands
Use these commands to work with vectors:
Function Description Returns
vector
(x,y,z)
Creates a vector from arguments representing all axes. A vector object
random
Vector()
Creates a vector describing a randomly chosen point on the
surface of a unit sphere. Differs from
vector(random(10)/
10.0
, random(10)/10.0, random(10)/10.0) because
the
randomVector() method always results in a unit vector.
A unit vector
Property Access Description
magnitude Get The magnitude of the vector. Equivalent to the length of the
vector.
length Get The length of the vector. Equivalent to the magnitude of the
vector.
[index] Get and set Returns the value of a vector at a specified point in an index
between 1 and 3.
x Get and set The x component of a vector.
y Get and set The y component of a vector.
z Get and set The z component of a vector.
Command 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.