3D Vectors
In what follows are various notes and equations dealing with 3D vectors.
Magnitude
\(\lvert a \rvert = \sqrt{a_x^2 + a_y^2 + a_z^2}\)
Distance Between Two Points
\(\lvert b - a \rvert = \sqrt{(b_x - a_x)^2 + (b_y - a_y)^2 + (b_z - a_z)^2}\)
Dot Product
\(a \cdot b = a_xb_x + a_yb_y + a_zb_z\)
Notes:
- \(a \cdot b = 0\) iff \(a\) and \(b\) are perpendicular
- \(a \cdot b = \lvert a \rvert\lvert b \rvert\) iff \(a\) and \(b\) are parallel
Cross Product
- \(a \times b = \begin{bmatrix}
a_yb_z - a_zb_y\\
a_zb_x - a_xb_z\\
a_xb_y - a_yb_x
\end{bmatrix}\)
Notes:
- \(a \times b = 0\) iff \(a\) and \(b\) are parallel
- \(\vert a \times b \rvert = \vert a \rvert\vert b \rvert\) iff \(a\) and \(b\) are perpendicular
Parallel
- \(a \cdot b = \lvert a \rvert\lvert b \rvert\) iff \(a\) and \(b\) are parallel
- \((a \cdot b)^2 = \lvert a \rvert^2\lvert b \rvert^2\)
- \((a_xb_x + a_yb_y + a_zb_z)^2 = (a_x^2 + a_y^2 + a_z^2)(b_x^2 + b_y^2 + b_z^2)\)
- 11 multiplications
- 6 additions
- \(a \times b = 0\) iff \(a\) and \(b\) are parallel
- \(\begin{bmatrix}
a_yb_z - a_zb_y\\
a_zb_x - a_xb_z\\
a_xb_y - a_yb_x
\end{bmatrix} = 0\)
- 6 multiplications
- 3 subtractions
Perpendicular
- \(a \cdot b = 0\) iff \(a\) and \(b\) are perpendicular
- \(a_xb_x + a_yb_y + a_zb_z = 0\)
- 3 multiplications
- 2 addition
- \(\lvert a \times b \rvert = \lvert a \rvert\lvert b \rvert\) iff \(a\) and \(b\) are perpendicular
- \(\lvert a \times b \rvert^2 = \lvert a \rvert^2\lvert b \rvert^2\)
- \(\begin{aligned}
&(a_yb_z - a_zb_y)^2 + (a_zb_x - a_xb_z)^2 + (a_xb_y - a_yb_x)^2 =\\
&(a_x^2 + a_y^2 + a_z^2)(b_x^2 + b_y^2 + b_z^2)
\end{aligned}\)
- 16 multiplications
- 9 additions
Angle Between Two Vectors
- \(\theta = \cos^{-1}\left(\dfrac{a \cdot b}{\lvert a \rvert\lvert b \rvert}\right)\)
- \(\theta = \cos^{-1}\left(\dfrac{a_xb_x + a_yb_y + a_zb_z}{\sqrt{a_x^2 + a_y^2 + a_z^2}\sqrt{b_x^2 + b_y^2 + b_z^2}}\right)\)
- 1 inverse trig
- 2 square roots
- 1 division
- 10 multiplications
- 6 additions
- \(\theta = \sin^{-1}\left(\dfrac{\lvert a \times b\rvert}{\lvert a \rvert\lvert b \rvert}\right)\)
- \(\theta = \sin^{-1}\left(\dfrac{\sqrt{(a_yb_z - a_zb_y)^2 + (a_zb_x - a_xb_z)^2 + (a_xb_y - a_yb_x)^2}}{\sqrt{a_x^2 + a_y^2}\sqrt{b_x^2 + b_y^2}}\right)\)
- 1 inverse trig
- 3 square roots
- 1 division
- 14 multiplications
- 7 additions