What's New in Director 8.5 > Controlling the 3D World > Vector math > Vector commands

 

Vector commands

Use these commands to work with vectors:

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.

getNormalized()

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)orcrossProduct(vector2)orperpendicularTo(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.