liveBook · Manning

Orientation

As explained in Geometry for Programmers

Orientation is the ordered directional arrangement of geometric points, vectors, or vertices, such as clockwise versus counterclockwise order.

Orientation records directional order: geometric points or triangle vertices may run clockwise or counterclockwise. In 2D, a cross product supplies both a signed area and this directional test. section 9.3.3

Orientation becomes useful when an algorithm needs consistent geometric direction:

  • Test whether a point lies inside a consistently ordered triangle by checking that it stays on the same side of every directed edge. section 9.3.3
  • Replace larger area calculations with cross-product comparisons; omit the common division by two when only relative areas matter. section 9.3.3
  • Use an initial orientation as a tangent direction for a moving object, allowing a spline to start smoothly even from a stationary point. section 7.2.2

Point-in-triangle test

For a clockwise-oriented triangle, an interior point lies to the right of all three directed sides. Compute each 2D cross-product sign and require all three tests to agree; a failed test places the point outside. section 9.3.3

Figure 9.17 If points of the triangle are clockwise-oriented, the point that lies inside the triangle must lie on the right side of all the triangle’s side vectors. If this check fails for any of the side vectors—in the figure on the right, that’s for the (x3 - x2, x3 - y2) side—the point is lying outside.
09-17

The figure makes the same-side rule visual by showing how one failed edge test identifies a point outside the triangle. section 9.3.3

How Geometry for Programmers covers it

How deep it goes
Defines clockwise and counterclockwise signs, applies cross-product tests, and connects tangent direction to spline control.
Examples
Uses a point-in-triangle function, directed triangle edges, signed areas, and a boat path controlled by tangent vectors.
What it assumes
Assumes vectors, triangle areas, and coordinate arithmetic while deriving practical tests from the 2D cross product.
What you can do after
Apply orientation through cross-product comparisons to classify triangle containment and choose spline tangent directions.
How it connects
Connects orientation with cross product, signed area, triangle containment, tangent vectors, and quadratic splines.

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.