Bezier path math (was: Does cocoa just leak?)
Bezier path math (was: Does cocoa just leak?)
- Subject: Bezier path math (was: Does cocoa just leak?)
- From: "Craig A. Mattocks" <email@hidden>
- Date: Mon, 1 Oct 2001 02:52:16 -0400
On Sunday, September 30 2001 22:50:06 +0200 j o a r <email@hidden> wrote:
Could any one point me in the direction for the documentation /
reference on the mathematics behind bezier paths?
Paraphrased from the documentation for curveto from Adobe's
Postscript Language Reference Manual (the "red book"):
Given a curve with end points at (x0,y0) and (x3,y3),
invisible control points at (x1,y1) and (x2,y2), and
tangent lines from (x0,y0) to (x1,y1) and (x2,y2) to (x3,y3).
The mathematical formulation of a Bezier cubic curve is derived from
a path of parametric cubic equations:
x(t) = at^3 + bt^2 + ct + x0
y(t) = dt^3 + et^2 + ft + y0
The cubic section produced is the path traced by x(t) and y(t) as t
ranges from 0 to 1. The Bezier control points corresponding to this
curve are:
x1 = x0 + c/3
x2 = x1 + (b+c)/3
x3 = x0 + a+b+c
y1 = y0 + f/3
y2 = y1 + (e+f)/3
y3 = y0 + d+e+f
Often a tension factor is applied to the 2nd derivatives (curvature)
at the endpoints. Setting tension = 0 allows a freely oscillating
cubic spline. Increasing the tension > 0 "tightens" the curve and
reduces the likelihood of spurious inflection points. Setting tension
= 1 (or infinity, depending on the formulation) flattens the curve
into a polygonal line. Perhaps the call to
"bezierPathByFlatteningPath" is enforcing a curvature constraint.
Does the API mention a tension factor?
- Craig
--------------------------------------------------------------------
"We all agree that your theory is crazy, but is it crazy enough?"
- Niels Bohr (1885-1962), Nobel physicist, founder of quantum theory
--------------------------------------------------------------------