Skip to content

Complex Numbers in Geometry

Identify \(\mathbb{R}^2\) with \(\mathbb{C}\): point \((x, y) \leftrightarrow z = x + iy\). Addition is vector sum; multiplication rotates and scales about the origin.

C++ std::complex

#include <complex>
using namespace std;

typedef complex<double> C;

double dot(C a, C b) { return real(conj(a) * b); }
double cross(C a, C b) { return imag(conj(a) * b); }

// Rotate z around origin by angle theta (radians)
C rotate(C z, double theta) {
    return z * polar(1.0, theta);
}

// Rotate z around pivot p
C rotateAround(C z, C pivot, double theta) {
    return pivot + (z - pivot) * polar(1.0, theta);
}

Common uses

  • Rotation of polygons or vectors without trig matrices.
  • Angles: \(\arg(z) = \text{atan2}(y, x)\); angle from \(a\) to \(b\) can use \(\arg(b/a)\).
  • Circles / arcs: center c, radius r → points c + r * exp(i * t).

Keep epsilon comparisons when checking collinearity or equality after many operations.