Animating with the Channel Editor > Expressions > Function Reference >

# Vector Functions

Use the following functions for performing various vector-related operations.

length

Returns the euclidean length (magnitude) of a given vector. The euclidian length is equivalent to the expression sqrt(pow(Vector.x, 2) + pow(Vector.y, 2) + pow(Vector.z, 2)).

Syntax: | length(Vector)
Arguments: | Vector is the vector of which you want the euclidean length.
Examples: | length((2, 0, 0)) returns 2. length((1, 1, 0)) returns 1.4142. length((-1, -1, -1)) returns 1.7321. length(axis1.position - axis2.position) returns the distance between axis1 and axis2.

dot

Returns the scalar dot-product of two given vectors. The dot-product is the product of the lengths of two vectors and the cosine of the angle between them. If the two vectors are at a right angle (90 degrees), their dot-product is 0.

If the product of their lengths equals 1 and they point in opposite directions (180 degrees), their dot-product is -1. The dot-product is equivalent to the expression V1.x * V2.x + V1.y * V2.y + V1.z * V2.z.

Syntax: | dot(V1, V2)
Arguments: | V1 and V2 are the vectors of which you want the dot-product.
Examples: | dot((1, 1, 0), (0, 0, 1)) returns 0. dot((2, 0, 0), (0.5, 0, 0)) returns 1. dot((0, 2, 0), (0, -0.5, 0)) returns -1. dot((2, 0, 1), (4, 5, 5)) returns 13.

cross

Returns the vector cross-product of two given vectors. The cross-product is the vector perpendicular to the plane containing the two vectors. In effect, there will be a right angle between the returned vector and the first given vector, as well as a right angle between the returned vector and the second given vector. The length of the resulting vector is equal to the product of the two vectors and the sine of the angle between them. The cross-product is equivalent to the vector (V1.y * V2.z - V1.z *V2.y, V1.z * V2.x - V1.x * V2.z, V1.x * V2.y - V1.y * V2.x).

Syntax: | cross(V1, V2)
Arguments: | V1 and V2 are the vectors of which you want the cross-product.
Examples: | cross((1, 0, 0), (0, 1, 0)) returns (0, 0, 1). cross((1, 1, 0), (0, 1, 1)) returns (1, -1, 1). cross((2, 0, 0), (0, 0.5, 0)) returns (0, 0, 1).