본문으로 건너뛰기

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 C1C^1 planar curve segments γ1:[0,1] ⁣ ⁣R2\gamma_1:[0,1]\!\to\!\mathbb{R}^2 and γ2:[0,1] ⁣ ⁣R2\gamma_2:[0,1]\!\to\!\mathbb{R}^2 that meet at a vertex PP (with incoming unit tangent t1\mathbf{t}_1 and outgoing unit tangent t2\mathbf{t}_2), construct a transition curve C:[0,1] ⁣ ⁣R2C:[0,1]\!\to\!\mathbb{R}^2 such that:

  • Positional continuity: C(0)=P1C(0)=P_1, C(1)=P2C(1)=P_2 for trimmed points P1γ1P_1\in\gamma_1, P2γ2P_2\in\gamma_2,
  • Tangent continuity (G¹): C(0)t1C'(0)\parallel \mathbf{t}_1 and C(1)t2C'(1)\parallel \mathbf{t}_2,
  • Curvature continuity (G²): κC(0)=κ1(P1)\kappa_C(0)=\kappa_1(P_1) and κC(1)=κ2(P2)\kappa_C(1)=\kappa_2(P_2), where κ\kappa denotes signed curvature.

A normalized smoothing parameter s[0,1]s\in[0,1] controls the trim distances along γ1,γ2\gamma_1,\gamma_2 (and/or a shape parameter), mapping UI intent to geometry. Typical ranges: s0.3 ⁣ ⁣0.7s\approx 0.3\!-\!0.7.

Terminology. CkC^k denotes equality of derivatives in a fixed parameterization. GkG^k denotes geometric continuity (tangent/curvature agreement irrespective of parameterization). For corner blending, G2G^2 is the target.


2. Curvature formulas used in constraints

For a parametric curve r(u)\mathbf{r}(u):

  • T=rr\mathbf{T}=\dfrac{\mathbf{r}'}{\|\mathbf{r}'\|},  κ=r×rr3\kappa=\dfrac{\|\mathbf{r}'\times \mathbf{r}''\|}{\|\mathbf{r}'\|^3} (in 2D, treat ×\times as scalar x1y2x2y1x_1y_2-x_2y_1).

For a cubic Bézier B(u)=i=03(3i)(1u)3iuiPiB(u)=\sum_{i=0}^3 \binom{3}{i}(1-u)^{3-i}u^i P_i:

  • B(0)=3(P1P0)B'(0)=3(P_1-P_0),  B(0)=6(P02P1+P2)B''(0)=6(P_0-2P_1+P_2)κB(0)=(P1P0)×(P22P1+P0)P1P03\displaystyle \kappa_{B}(0)=\frac{|(P_1-P_0)\times (P_2-2P_1+P_0)|}{\|P_1-P_0\|^3}.
  • Analogously at u=1u=1: replace (P0,P1,P2)(P_0,P_1,P_2) with (P3,P2,P1)(P_3,P_2,P_1).

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:

xan+ybn=1,n2.\left|\frac{x}{a}\right|^n+\left|\frac{y}{b}\right|^n=1,\qquad n\ge 2.
  • Parameters a,b>0a,b>0 are trim distances along the two edges; pick n>2n>2 for vanishing curvature at the endpoints.
  • Splice property: at (a,0)(a,0) and (0,b)(0,b) the tangent aligns with the axes, and for n>2n>2 the curvature tends to 00, matching the straight‑edge curvature. Thus the splice to straight edges is C2C^2 (hence G2G^2).
  • Special cases: n=2n=2 (circular fillet); n5n\approx 5 reproduces Apple‑style “icon” corners.

Parametrization (first quadrant):

x(t)=acost2/n,y(t)=bsint2/n,t[0,π2].x(t)=a\,|\cos t|^{2/n},\quad y(t)=b\,|\sin t|^{2/n},\quad t\in[0,\tfrac{\pi}{2}].

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 G1G^1; with additional constraints one can equalize curvature at the internal join to approach G2G^2, 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 G2G^2 requirements.


3.3 Cubic Bézier G2G^2 corner blend (general, Bézier‑native)

Construct two cubics B1,B2B_1, B_2 meeting at a join point MM:

  • Set end points: B1(0)=P1B_1(0)=P_1, B1(1)=MB_1(1)=M,  B2(0)=MB_2(0)=M, B2(1)=P2B_2(1)=P_2.
  • Align tangents with trimmed edge directions: P1+=P1+αt1P_1^+=P_1+\alpha\,\mathbf{t}_1,  P2=P2βt2P_2^- = P_2-\beta\,\mathbf{t}_2, with α,β>0\alpha,\beta>0.
  • Choose an internal tangent direction tM\mathbf{t}_M (e.g., angle‑bisector) and set M=MμtMM^- = M - \mu\,\mathbf{t}_M, M+=M+νtMM^+ = M + \nu\,\mathbf{t}_M.
  • Enforce G1G^1 at MM: B1(1)tMB2(0)B_1'(1)\parallel \mathbf{t}_M \parallel B_2'(0).
  • Enforce equal curvature at MM using the endpoint formulas in §2 to solve for (μ,ν)(\mu,\nu) (and optionally relate α,β\alpha,\beta to match endpoint curvature to the incident edges).

This yields a strictly G2G^2 Bézier‑only construction compatible with editors whose primitive is cubic Bézier.

Practical recipe. Given a smoothing amount ss, set trim distances d1=sL1d_1=s\,L_1, d2=sL2d_2=s\,L_2 along the incident segments (lengths LiL_i). Take α=k1d1\alpha=k_1 d_1, β=k2d2\beta=k_2 d_2 with constants tuned for visual uniformity (e.g., k1=k223k_1=k_2\approx \tfrac{2}{3}). Solve for (μ,ν)(\mu,\nu) so that κB1(1)=κB2(0)\kappa_{B_1}(1)=\kappa_{B_2}(0).


3.4 Clothoid (Euler‑spiral) blends (analytic G2G^2 with linear curvature)

A clothoid has curvature varying linearly with arc length: κ(s)=κ0+λs\kappa(s)=\kappa_0+\lambda s.

  • Connect two trimmed points by a pair (or a single) clothoid segment(s) meeting G2G^2 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 G2G^2, but involve special functions.


4. Smoothing parameterization

Expose a UI parameter s[0,1]s\in[0,1] and map it to geometric quantities:

  • Trim lengths: di=smin(αLi,dmax)d_i = s\,\min(\alpha L_i,\, d_{\max}) (clamped for short edges).
  • Superelliptic nn (optional): a monotone heuristic such as n(s)=2+8s2n(s)=2+8s^2 (documented as heuristic; not a standard).
  • Angle adaptivity: reduce ss 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, ss, mode) and per common angle buckets.

6. Relationship to common terms

  • Rounded corners (circular fillet): G1G^1 only, constant radius.
  • Superellipse / squircle: a global analytic curve; the quarter‑superellipse in §3.1 provides an analytic CC^\infty fillet for orthogonal edges.
  • “Figma corner smoothing”: a Bézier‑based G2G^2 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.