2D Vectors
In what follows are various notes and equations dealing with 2D vectors.
Magnitude
\(\lvert a \rvert = \sqrt{a_x^2 + a_y^2}\)
Distance Between Two Points
\(\lvert B - A \rvert = \sqrt{(B_x - A_x)^2 + (B_y - A_y)^2}\)
Dot Product
\(a \cdot b = a_xb_x + a_yb_y\)
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 = a_xb_y - a_yb_x\)
Notes:
- \(a \times b = 0\) iff \(a\) and \(b\) are parallel
- \(a \times b = \lvert a \rvert\lvert 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)^2 = (a_x^2 + a_y^2)(b_x^2 + b_y^2)\)
- 8 multiplications
- 3 additions
- \(a \times b = 0\) iff \(a\) and \(b\) are parallel
- \(a_xb_y - a_yb_x = 0\)
- 2 multiplications
- 1 subtraction
Perpendicular
- \(a \cdot b = 0\) iff \(a\) and \(b\) are perpendicular
- \(a_xb_x + a_yb_y = 0\)
- 2 multiplications
- 1 addition
- \(a \times b = \lvert a \rvert\lvert b \rvert\) iff \(a\) and \(b\) are perpendicular
- \((a \times b)^2 = \lvert a \rvert^2\lvert b \rvert^2\)
- \((a_xb_y - a_yb_x)^2 = (a_x^2 + a_y^2)(b_x^2 + b_y^2)\)
- 8 multiplications
- 3 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}{\sqrt{a_x^2 + a_y^2}\sqrt{b_x^2 + b_y^2}}\right)\)
- 1 inverse trig
- 2 square roots
- 1 division
- 7 multiplications
- 3 additions
- \(\theta = \sin^{-1}\left(\dfrac{\lvert a \times b\rvert}{\lvert a \rvert\lvert b \rvert}\right)\)
- \(\theta = \sin^{-1}\left(\dfrac{a_xb_y - a_yb_x}{\sqrt{a_x^2 + a_y^2}\sqrt{b_x^2 + b_y^2}}\right)\)
- 1 inverse trig
- 2 square roots
- 1 division
- 7 multiplications
- 3 additions
Rotate
- \(R_{90^\circ}(x, y) = (-y, x)\)
- \(R_{180^\circ}(x, y) = (-x, -y)\)
- \(R_{270^\circ}(x, y) = (y, -x)\)
- \(s = \sin \theta\)
- \(c = \cos \theta\)
- \(R_\theta(x, y) = (xc - ys, xs + yc)\)