G² Curve Blending
A.k.a. Curvature‑Continuous Corner Blending (design systems often call this “continuous corner smoothing”).
This document formalizes the problem of replacing a sharp join between two curve segments with a curvature‑continuous (G²) transition. It consolidates established techniques from CAGD (Computer Aided Geometric Design) and relates them to practical implementations used in modern editors.
1. Problem statement
Given two planar curve segments and that meet at a vertex (with incoming unit tangent and outgoing unit tangent ), construct a transition curve such that:
- Positional continuity: , for trimmed points , ,
- Tangent continuity (G¹): and ,
- Curvature continuity (G²): and , where denotes signed curvature.
A normalized smoothing parameter controls the trim distances along (and/or a shape parameter), mapping UI intent to geometry. Typical ranges: .
Terminology. denotes equality of derivatives in a fixed parameterization. denotes geometric continuity (tangent/curvature agreement irrespective of parameterization). For corner blending, is the target.
2. Curvature formulas used in constraints
For a parametric curve :
- , (in 2D, treat as scalar ).
For a cubic Bézier :
- , ⇒ .
- Analogously at : replace with .
These formulas make the G² constraints algebraic in the control points.
3. Canonical constructions
3.1 Superelliptic fillet (orthogonal or near‑orthogonal edges)
Use a quarter of the superellipse:
- Parameters are trim distances along the two edges; pick for vanishing curvature at the endpoints.
- Splice property: at and the tangent aligns with the axes, and for the curvature tends to , matching the straight‑edge curvature. Thus the splice to straight edges is (hence ).
- Special cases: (circular fillet); reproduces Apple‑style “icon” corners.
Parametrization (first quadrant):
Notes. This is analytic and extremely stable for rectangles/frames; for highly acute or obtuse angles, prefer §3.2/§3.3.
3.2 Biarc blends (two circular arcs)
A biarc joins two trimmed points by two circular arcs that share a point and tangent.
- Always achieves ; with additional constraints one can equalize curvature at the internal join to approach , but this is not guaranteed for all angles/lengths.
- Efficient and robust; widely used in CAD/CAM.
Use biarcs when performance and robustness trump strict requirements.
3.3 Cubic Bézier corner blend (general, Bézier‑native)
Construct two cubics meeting at a join point :
- Set end points: , , , .
- Align tangents with trimmed edge directions: , , with .
- Choose an internal tangent direction (e.g., angle‑bisector) and set , .
- Enforce at : .
- Enforce equal curvature at using the endpoint formulas in §2 to solve for (and optionally relate to match endpoint curvature to the incident edges).
This yields a strictly Bézier‑only construction compatible with editors whose primitive is cubic Bézier.
Practical recipe. Given a smoothing amount , set trim distances , along the incident segments (lengths ). Take , with constants tuned for visual uniformity (e.g., ). Solve for so that .
3.4 Clothoid (Euler‑spiral) blends (analytic with linear curvature)
A clothoid has curvature varying linearly with arc length: .
- Connect two trimmed points by a pair (or a single) clothoid segment(s) meeting conditions.
- Position is expressed via Fresnel integrals. This is a classic choice in road/rail design and robotics for fair transitions.
Clothoids are highly aesthetic and strictly , but involve special functions.
4. Smoothing parameterization
Expose a UI parameter and map it to geometric quantities:
- Trim lengths: (clamped for short edges).
- Superelliptic (optional): a monotone heuristic such as (documented as heuristic; not a standard).
- Angle adaptivity: reduce for very acute/concave corners to prevent self‑intersection.
5. Robustness & implementation notes
- Concave corners. Place the blend along the interior bisector; clamp trim to avoid inversion/self‑intersection.
- Curved inputs. Either flatten to a polyline (fast), or compute blends in the tangent frames of the original curves (higher fidelity).
- Stroking. Offset by re‑tessellating the blended fill outline at stroke width; do not assume parallel curves.
- Caching. Cache per (path hash, , mode) and per common angle buckets.
6. Relationship to common terms
- Rounded corners (circular fillet): only, constant radius.
- Superellipse / squircle: a global analytic curve; the quarter‑superellipse in §3.1 provides an analytic fillet for orthogonal edges.
- “Figma corner smoothing”: a Bézier‑based corner blend akin to §3.3 (two cubics per corner with a smoothing factor).
7. Modes (for engines)
pub enum CornerBlendMode {
/// General-purpose, Bézier-native G² construction (two cubics).
BezierG2,
/// Analytic superelliptic fillet for (near) orthogonal edges.
Superelliptic,
/// Biarc (fast, robust G¹; near-G² with tuning).
Biarc,
/// Clothoid-based (analytic G²; uses Fresnel integrals).
Clothoid,
}
8. References (selected)
- Farin, Curves and Surfaces for CAGD — curve continuity and Bézier endpoint curvature.
- Hoschek & Lasser, Fundamentals of Computer Aided Geometric Design — blending and fairness.
- Meek & Walton, “Approximating smooth planar curves by arc splines,” J. Comput. Appl. Math., 1994 — biarcs.
- Ahn et al., “Interpolating clothoid splines,” Graphical Models, 2011 — clothoid blends and Fresnel integrals.
- Lamé, “Memoire sur la théorie des surfaces isothermes,” 1818 — superellipse.