# Cross product

## Formula

The cross product of two vectors (not to be confused with dot product) is a vector which is perpendicular plane containing them. The cross product of vector $$\vec{V}$$ and $$\vec{U}$$ can be calculated thanks to the following formula:

$$\vec{V} \times \vec{U} = \left ( \begin{matrix} V_y.U_z - V_z.U_y \\ V_z.U_x - V_x.U_z \\ V_x.U_y - V_y.U_x \end{matrix} \right )$$

## Properties

Properties
If $$\vec{V}$$ and $$\vec{U}$$ are collinear, $$\vec{V} \times \vec{U}$$ is a null vector.
If $$\vec{V}$$ is null, $$\vec{V} \times \vec{U}$$ is a null vector.
If $$\vec{U}$$ is null, $$\vec{V} \times \vec{U}$$ is a null vector.
$$\vec{V} \times \vec{U}$$ is normal to the plane containing the vectors $$\vec{V}$$ and $$\vec{U}$$.
$$\vec{V} \times \vec{U}=-(\vec{U} \times \vec{V}) = (-\vec{U}) \times \vec{V}$$.

## C++ source code

The following C++ function return the cross product of two vectors :

/*!
* \brief   Compute the cross product of two vectors (this x V)
*          The current vector is the first operand
* \param   V is the second operand
* \return  a vector = the cross product of the current vector by V
*/
inline rOc_vector rOc_vector::cross(const rOc_vector V)
{
rOc_vector Res;
Res.x()=this->y()*V.z() - this->z()*V.y();
Res.y()=this->z()*V.x() - this->x()*V.z();
Res.z()=this->x()*V.y() - this->y()*V.x();
return Res;
}


## MATLAB cross product

With MATLAB, the cross product can easily be computed with the function cross(A, B) :

>> u=[1,2,3];
>> v=[4,5,6];
>> cross (u,v)

ans =

-3     6    -3