Functions | |
void | Compute_Cross_Product (const HC_POINT *vector1, const HC_POINT *vector2, HC_POINT *out_vector) |
void Compute_Cross_Product | ( | const HC_POINT * | vector1, |
const HC_POINT * | vector2, | ||
HC_POINT * | out_vector | ||
) |
vector1 | - input 3D vectors. |
vector2 | - input 3D vectors. |
out_vector | - output 3D vector returned to the caller. Can point to the same place as vector1 or vector2 |
Compute_Cross_Product() takes two 3-D vectors and computes their vector cross-product.
For a bit of linear algebra review, the way to compute a cross product is to calculate the determinant of the following matrix:
| i j k | | x1 y1 z1 | | x2 y2 z2 |Where i,j and k are the unit vectors along the X, Y and Z axes, respectively. That works out to be equal to
i*(y1*z2 - z1*y2) - j*(x1*z2 - z1*x2) + k*(x1*y2 - y1*x2)The result is always perpendicular to both inputs, and of length equal to the length(vector1) * length(vector2) * sin(angle between vector1 and vector2). The order of the inputs matters. Switching the inputs will reverse the result.