liveBook · Manning

Signed area

As explained in Geometry for Programmers

Signed area is an oriented two-dimensional area whose sign records the ordering and orientation of the spanning vectors.

Signed area is an oriented area: its magnitude measures the parallelogram spanned by two vectors, while its sign records their ordering. For vectors a = (a1, a2) and b = (b1, b2), compute a1b2 − a2b1. Counterclockwise ordering gives a positive result; clockwise ordering gives a negative result. section 9.3.3 section 9.5.2

Signed area supports several practical geometric decisions:

  • Classify which side of an oriented edge contains a point by inspecting the sign. section 9.3.3
  • Test triangle containment by requiring consistent side-of-edge signs for all three edges. section 9.3.3
  • Convert signed area into signed distance from a point to a line by dividing by the base segment’s length. section 10.1.4

A compact implementation

The core operation can be written as `box2d(x1, y1, x2, y2) = x1*y2 - x2*y1`. For a point and an oriented line segment, compute `box2d(x-x1, y-y1, x2-x1, y2-y1) / distance_p2p(x1, y1, x2, y2)` to obtain signed point-to-line distance. A rectangle’s signed distance function then uses the closest edge’s unsigned distance and restores its sign from that edge’s line. section 10.1.4

Figure 9.16 The third coordinate of the 2D cross product changes sign as a crosses b.
09-16

Visualize the sign changing as one vector crosses the other, making orientation easier to connect with the determinant formula. section 9.3.3

How Geometry for Programmers covers it

How deep it goes
Derives the 2D determinant meaning and applies it in geometric algorithms, stopping short of broader linear algebra theory.
Examples
Demonstrates vector orientation, triangle containment, point-to-line distance, segment distance, and a rectangle signed distance function.
What it assumes
Assumes comfort with 2D coordinates and vectors while developing the determinant calculation through geometric intuition.
What you can do after
Apply it via coordinate formulas to implement orientation predicates, triangle tests, and signed point-to-line distances.
How it connects
Connects signed area to cross products, determinants, parallelograms, point-in-triangle tests, and signed distance functions.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Geometry for Programmers. The section links point to the parts of the book it draws on.