vec_diff ( VECTOR* vector, VECTOR* vector1, VECTOR* vector2)

Sets the vector to the difference of vector1 and vector2. After the instruction, vector gives the direction from vector2 to vector1.

Parameters:

vector - result vector, or NULL for returning a temporary vector.
vector1 - first vector; use nullvector to set vector to the negative of vector2.
vector2 - second vector .

Returns:

vector, or a temporary vector when vector == NULL.

Algorithm:

vector = vector1 - vector2

Speed:

Fast

Example:

// let the camera look at the 'my' entity position
function look_at_me()
{
  vec_to_angle(camera.pan,vec_diff(NULL,my.x,camera.x));
}

See also:

Vectors, vec_add, vec_sub, vec_scale, vec_set, vec_inverse, vec_normalize, ang_diff

► latest version online