liveBook · Manning

Curve flatness

As explained in How Computers Make Books

Curve flatness is a measure of how closely a curve follows a straight line between its endpoints.

Curve flatness measures how closely a curve follows the straight line joining its endpoints. It provides a practical stopping rule when drawing Bézier curves. section 2.2

A renderer can use flatness to decide when subdivision has gone far enough:

  • Subdivide the Bézier curve repeatedly with de Casteljau’s procedure. section 2.2
  • Estimate the curve’s deviation from its endpoint line using the height of the curve. section 2.2
  • Replace the section with a straight line when the estimate is below a chosen tolerance, such as half a pixel. section 2.2

Adaptive line approximation

A fixed number of subdivision stages treats open and tight parts unevenly. A flatness test instead gives each part as many straight segments as needed; one curve may require 1 segment, another 25. section 2.2

Figure 2.10 An approximate measure of the flatness of a Bézier curve

Use the flatness diagram to see how the lengths A and B provide an easy upper-bound estimate for deviation from the endpoint line. section 2.2

How How Computers Make Books covers it

How deep it goes
Defines an approximate height-based test and pixel tolerance, without developing an exact geometric measure.
Examples
Uses Figure 2.9’s 1-to-25-segment approximations and Figure 2.10’s A-plus-B height estimate.
What it assumes
Assumes Bézier curves and subdivision, while motivating the stopping decision through concrete rendering behavior.
What you can do after
Apply an adaptive flatness threshold to replace sufficiently flat Bézier sections with straight lines.
How it connects
Connects Bézier curves with de Casteljau subdivision and straight-line approximation.

This explainer was generated by Manning's knowledge graph from the text of How Computers Make Books. The section links point to the parts of the book it draws on.