ApasScript.

Vectors

vec

Constructs a 2D vector from vec(x, y), or a 3D vector from vec(x, y, z) -- dispatches on argument count.

add

Adds two vectors of the same dimension (both 2D or both 3D). Also works on complex numbers (complex(3, 4)). Also works on quaternions. Also works on tensors. Also the exact sum of two algebraic numbers.

sub

Subtracts b from a, for two vectors of the same dimension. Also works on complex numbers (complex(3, 4)). Also works on quaternions. Also works on tensors.

scale

Multiplies a vector by a scalar. Also a number times a quaternion. Also works on tensors.

neg

Negates a vector, reversing its direction. Also works on complex numbers (complex(3, 4)). Also works on quaternions. Also works on tensors.

normalize

Scales a vector to unit length, keeping its direction. Also the unit quaternion q/|q|.

rotate

Rotates a 2D vector by an angle, in radians. Has no 3D form -- there is no single axis to rotate around. With a quaternion and a 3D vector: the vector rotated by q.

dot

The dot product of two vectors of the same dimension. Also the dot product of two quaternions.

mag

The magnitude (length) of a vector.

cross

The cross product of two vectors of the same dimension -- a scalar (the z-component) for two 2D vectors, a vector for two 3D vectors.

angle

The angle, in radians, a 2D vector makes with the x-axis. 2D only -- there is no single reference axis in 3D.

angleBetween

The angle, in radians, between two vectors of the same dimension.

projScalar

The scalar projection of a onto b -- the length of a's component along b.

projVector

The vector projection of a onto b -- a's component along b, as a vector.

reject

The vector rejection of a from b -- a's component perpendicular to b.

scalarTriple

The scalar triple product a . (b x c), for three 3D vectors -- the signed volume of the parallelepiped they span.

vectorTriple

The vector triple product a x (b x c), for three 3D vectors.