# Cross Product

The cross product is a special operation only serving a purpose in 3D.

$$
\vec{a}\times\vec{b}
====================

\begin{bmatrix}
a\_1 \ a\_2 \ a\_3
\end{bmatrix}
\times
\begin{bmatrix}
b\_1 \ b\_2 \ b\_3
\end{bmatrix}
=============

\begin{bmatrix}
a\_2 b\_3 - a\_3 b\_2\\
a\_3 b\_1 - a\_1 b\_3\\
a\_1 b\_2 - a\_2 b\_1
\end{bmatrix}
$$

We are mainly going to use the cross product to construct vectors which are linear independent from another. Other than that it's not too useful for our purposes. Take this example where we have 2 (linear independent) vectors and use the cross product to construct a 3rd vector which all together form a new coordinate system.

![](https://3012238209-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F3CiKZGX91xk3wTXNDkac%2Fuploads%2FkcfarLLsnSiAb7VMWPaV%2FCrossProduct_ManimCE_v0.15.0.gif?alt=media\&token=5d697330-0137-400d-b798-6def0ce55aee)

{% hint style="warning" %}
Note that this animation also uses vector projection, which is not explained here.
{% endhint %}

```java
Vector orangeVector = new Vector(3, 0, 1).normalize();
Vector tealVector = new Vector(-0.5, 2, 1).normalize();
Vector purpleVector = orangeVector.getCrossProduct(tealVector);
```
