2007年11月8日星期四

收录一篇技术文章(贝塞尔曲线-Bezier curve)

Bézier curve

From Wikipedia, the free encyclopedia

Jump to: navigationsearch
Cubic Bézier curve
Cubic Bézier curve
In the mathematical field of numerical analysis, a Bézier curve is a parametric curve important in computer graphics. Generalizations of Bézier curves to higher dimensions are called Bézier surfaces, of which the Bézier triangleis a special case.
Bézier curves were widely publicised in 1962 by the French engineer Pierre Bézier, who used them to designautomobile bodies. The curves were first developed in 1959 by Paul de Casteljau using de Casteljau's algorithm, anumerically stable method to evaluate Bézier curves.

Contents

[hide]

[edit] Examination of cases

[edit] Linear Bézier curves

Given points P0 and P1, a linear Bézier curve is just a straight line between those two points. The curve is given by
\mathbf{B}(t)=\mathbf{P}_0 + (\mathbf{P}_1-\mathbf{P}_0)t=(1-t)\mathbf{P}_0 + t\mathbf{P}_1 \mbox{ , } t \in [0,1]
and is equivalent to linear interpolation.

[edit] Quadratic Bézier curves

A quadratic Bézier curve is the path traced by the function B(t), given points P0P1, and P2,
\mathbf{B}(t) = (1 - t)^{2}\mathbf{P}_0 + 2t(1 - t)\mathbf{P}_1 + t^{2}\mathbf{P}_2 \mbox{ , } t \in [0,1].
TrueType fonts use Bézier splines composed of quadratic Bézier curves.

[edit] Cubic Bézier curves

Four points P0P1P2 and P3 in the plane or in three-dimensional space define a cubic Bézier curve. The curve starts at P0 going toward P1 and arrives at P3 coming from the direction of P2. Usually, it will not pass through P1 or P2; these points are only there to provide directional information. The distance between P0 and P1 determines "how long" the curve moves into direction P2 before turning towards P3.
The parametric form of the curve is:
\mathbf{B}(t)=(1-t)^3\mathbf{P}_0+3t(1-t)^2\mathbf{P}_1+3t^2(1-t)\mathbf{P}_2+t^3\mathbf{P}_3 \mbox{ , } t \in [0,1].
Modern imaging systems like PostScriptAsymptote and Metafont use Bézier splines composed of cubic Bézier curves for drawing curved shapes.

[edit] Generalization

The Bézier curve of degree n can be generalized as follows. Given points P0P1,..., Pn, the Bézier curve is
\mathbf{B}(t)=\sum_{i=0}^n {n\choose i}\mathbf{P}_i(1-t)^{n-i}t^i =\mathbf{P}_0(1-t)^n+{n\choose 1}\mathbf{P}_1(1-t)^{n-1}t+\cdots+\mathbf{P}_nt^n \mbox{ , } t \in [0,1].
For example, for n = 5:
\mathbf{B}(t)=\mathbf{P}_0(1-t)^5+5\mathbf{P}_1t(1-t)^4+10\mathbf{P}_2t^2(1-t)^3+10\mathbf{P}_3t^3(1-t)^2+5\mathbf{P}_4t^4(1-t)+\mathbf{P}_5t^5 \mbox{ , } t \in [0,1].
This formula can be expressed recursively as follows: Let \mathbf{B}_{\mathbf{P}_0\mathbf{P}_1\ldots\mathbf{P}_n}denote the Bézier curve determined by the points P0P1,..., Pn. Then
\mathbf{B}(t) = \mathbf{B}_{\mathbf{P}_0\mathbf{P}_1\ldots\mathbf{P}_n}(t) = (1-t)\mathbf{B}_{\mathbf{P}_0\mathbf{P}_1\ldots\mathbf{P}_{n-1}}(t) + t\mathbf{B}_{\mathbf{P}_1\mathbf{P}_2\ldots\mathbf{P}_n}(t)
In words, the degree n Bézier curve is a linear interpolation between two degree n − 1 Bézier curves.

图例示意

Quadratic curves

For quadratic Bézier curves one can construct intermediate points Q0 and Q1 such that as t varies from 0 to 1:
  • Point Q0 varies from P0 to P1 and describes a linear Bézier curve.
  • Point Q1 varies from P1 to P2 and describes a linear Bézier curve.
  • Point B(t) varies from Q0 to Q1 and describes a quadratic Bézier curve.
Construction of a quadratic Bézier curveAnimation of a quadratic Bézier curve, t in [0,1]
Construction of a quadratic Bézier curveAnimation of a quadratic Bézier curve, t in [0,1]

[edit] Higher-order curves

For higher-order curves one needs correspondingly more intermediate points. For cubic curves one can construct intermediate points Q0Q1 & Q2 that describe quadratic Bézier curves, and points R0 & R1 that describe linear Bézier curves:
Construction of a cubic Bézier curveAnimation of a cubic Bézier curve, t in [0,1]
Construction of a cubic Bézier curveAnimation of a cubic Bézier curve, t in [0,1]
For fourth-order curves one can construct intermediate points Q0Q1Q2 & Q3 that describe cubic Bézier curves, points R0R1 & R2 that describe quadratic Bézier curves, and points S0 & S1 that describe linear Bézier curves:
Construction of a quartic Bézier curveAnimation of a quartic Bézier curve, t in [0,1]
Construction of a quartic Bézier curveAnimation of a quartic Bézier curve, t in [0,1]

没有评论:

发表评论