Skip navigation.
 
mlRe: Quadratic curves in NSBezierPath
FROM : Graham Cox
DATE : Fri May 09 03:28:38 2008

If you can use Core Graphics, there is: CGPathAddQuadCurveToPoint

If using NSBezierPath, some simple maths will get you the needed 
control points, this googled up from http://fontforge.sourceforge.net/bezier.html

Any quadratic spline can be expressed as a cubic (where the cubic term 
is zero). The end points of the cubic will be the same as the 
quadratic's.

CP0 = QP0
CP3 = QP2
The two control points for the cubic are:

CP1 = QP0 + 2/3 *(QP1-QP0)
CP2 = CP1 + 1/3 *(QP2-QP0)


where the quadratic curve is QP0-QP1-QP2
and the cubic is CP0-CP1-CP2-CP3



hth,

G.

On 9 May 2008, at 2:51 am, Nick Zitzmann wrote:

>
> On May 8, 2008, at 7:33 AM, Graham Cox wrote:
>

>> A cubic bezier with the two control points set to the same value is 
>> equivalent to a quadratic bezier. In other words the cubic is a 
>> superset of the quadratic.
>>
>> Why do you need quadratics specifically?

>
>
> I'm reading in a file format that uses only a single control point 
> for curved edges.
>
> Nick Zitzmann
> <http://www.chronosnet.com/>
>
>
>
>

Related mailsAuthorDate
mlQuadratic curves in NSBezierPath Nick Zitzmann May 8, 10:06
mlRe: Quadratic curves in NSBezierPath Graham Cox May 8, 15:33
mlRe: Quadratic curves in NSBezierPath Nick Zitzmann May 8, 18:51
mlRe: Quadratic curves in NSBezierPath Kyle Sluder May 9, 03:26
mlRe: Quadratic curves in NSBezierPath Graham Cox May 9, 03:28
mlRe: Quadratic curves in NSBezierPath Graham Cox May 9, 03:29
mlRe: Quadratic curves in NSBezierPath Nick Zitzmann May 9, 03:47