User Guide

Vector math 397
Vector math
A 3D vector describes both direction and location in 3D space. Vector objects include floating-
point values for position along each of the x-, y-, and z-axes. Vectors can be node-relative or
world-relative. If they are node-relative, their x, y, and z values are relative to the position of the
node. If they are world-relative, their x, y, and z directions are relative to the world.
Vector math operations perform calculations using each of the x, y, and z values. These
calculations are useful for performing intelligent movement and rotation of models.
Vector creation methods
Use these methods to create vectors:
Vector properties
Use these properties to work with vectors:
Method 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.