vec_cross (VECTOR* vector,
VECTOR* vector1,
VECTOR* vector2);
Sets vector to the cross product of vector1 and vector2. The cross product is a vector perpendicular to both vector1 and vector2, with a magnitude equivalent to the area of the parallelogram that the two vectors span.
Parameters:
vector1 - first vector.
vector2 - second vector.
Returns:
vector
Modifies:
vector = vector1 x vector2
Speed:
FastExamples:
var a[3];
var b[3] = { 1,0,0 };
var c[3] = { 0,1,0 };
vec_cross(a,b,c); // sets a to { 0,0,1 }
// align an entity axis to a normal vector
function ent_align(ANGLE* ang, VECTOR* to, VECTOR* axis)
{
VECTOR rot;
vec_normalize(axis,1);
vec_normalize(to,1);
vec_cross(rot,to,axis);
ang_for_axis(ang,rot,-acosv(vec_dot(to,axis)));
}
...
// align an entity to the floor normal
c_trace(my.x,vector(my.x,my.y,my.z-1000),IGNORE_ME); // set floor normal hit.nx
ang_align(my.pan,hit.nx,vector(0,0,1)); // align vertical axis to the floor normal
ang_rotate(my.pan,vector(angle,0,0)); // rotate pan angle
...
See also:
Vectors, vec_add, vec_sub,
vec_scale, vec_set,
vec_inverse, vec_diff, vec_dot,
vec_mul
► latest
version online