Study smarter with Fiveable
Get study guides, practice questions, and cheatsheets for all your subjects. Join 500,000+ students with a 96% pass rate.
Every algorithm in computational geometry—from collision detection to mesh generation to spatial indexing—builds on a small set of fundamental primitives. When you're implementing a convex hull algorithm, designing a ray tracer, or solving intersection problems, you're really manipulating points, lines, and polygons in precise mathematical ways. Understanding these primitives isn't just about definitions; it's about knowing how they're represented, what operations they support, and when to use each one.
You're being tested on your ability to choose the right primitive for a given problem, convert between representations efficiently, and understand the mathematical properties that make certain algorithms work. Don't just memorize that a line segment has two endpoints—know why parametric representation makes intersection tests elegant, why convex polygons simplify so many algorithms, and how vectors enable the transformations that power computer graphics. Master the primitives, and the algorithms will follow.
These primitives represent positions and directions—the atomic units from which all other geometric objects are constructed. Points define "where," while vectors define "which way" and "how far."
Compare: Points vs. Vectors—both are coordinate tuples, but points represent locations while vectors represent displacements. In code, the distinction matters: adding two points is meaningless, but subtracting them yields a vector. If an interview asks about geometric transformations, vectors are your answer.
Lines and their bounded variants form the backbone of intersection algorithms, visibility computations, and geometric queries. The key distinction is extent: infinite, semi-infinite, or finite.
Compare: Rays vs. Line Segments—both are bounded versions of lines, but rays extend infinitely in one direction () while segments are finite (). Ray-object intersection returns "does it hit and where," while segment intersection asks "do these two finite edges cross."
Planes define the 2D surfaces embedded in 3D space that partition regions and enable surface computations. In 2D problems, lines play the analogous role.
Compare: Lines (2D) vs. Planes (3D)—both partition space into half-spaces using signed distance. The implicit equation in 2D generalizes to in 3D. Algorithms like BSP trees work identically in both dimensions.
Polygons are the workhorses of computational geometry—they approximate curves, define regions, and form the basis of mesh representations. Convexity is the key property that determines algorithmic complexity.
Compare: Triangles vs. General Polygons—triangles are always convex and have constant-time point-in-polygon tests; general polygons require ray casting or winding number tests. When in doubt, triangulate: any simple polygon can be decomposed into triangles.
Circles represent the fundamental curved primitive, enabling smooth boundaries and distance-based queries. Most curved geometry in computational applications is approximated by polygons, but circles have special-case algorithms.
Compare: Circles vs. Convex Polygons—both define convex regions, but circles have infinite symmetry while polygons have discrete vertices. Collision detection between circles is ; between convex polygons it's with preprocessing. Use circles for bounding volumes when rotation invariance matters.
| Concept | Best Examples |
|---|---|
| Position representation | Points, Homogeneous coordinates |
| Direction and magnitude | Vectors, Rays |
| Linear extent | Lines, Line segments, Rays |
| Space partitioning | Planes, Lines (2D), Half-spaces |
| Bounded regions | Polygons, Triangles, Circles |
| Convexity properties | Convex hulls, Triangles, Circles |
| Parametric representation | Line segments , Rays |
| Implicit representation | Lines , Planes, Circles |
Representation choice: You need to test whether a point lies to the left or right of a directed line. Which representation of a line makes this easiest, and what mathematical operation do you use?
Compare and contrast: Both rays and line segments are bounded versions of lines. Explain how their parametric representations differ and give one algorithm that specifically requires rays rather than segments.
Convexity matters: Why do convex hull algorithms produce useful output even when the input is already a polygon? What property of the output guarantees simpler subsequent computations?
Primitive selection: You're implementing a 2D physics engine and need to detect collisions between rotating objects. Compare the tradeoffs between using circles versus convex polygons as bounding shapes.
Cross-primitive operations: Given three points , , and , describe how you would use vector operations to determine (a) whether they are collinear, and (b) if not, whether lies to the left or right of the directed line from to .