File Exchange

image thumbnail

Approximation of Circle Using Cubic Bezier Curve

version 1.1.0.0 (118 KB) by Dr. Murtaza Khan
Approximation of unit radius circle with four parametrix bezier curves

4 Downloads

Updated 09 Jul 2009

View License

(1) CubicBezier1.m : Evaluates Cubic Bezier Curve for given four Control Points and interval.

(2) PlotBezier1.m : Plots Bezier Curve, Control Points, Control Polygon

(3) TestCircleApproxByCubicBezier.m : Test Program. Pass Control Points that approximate unit radius circle using cubic Beizer curves.

(4) ApproxofCirclebyCubicBezier.pdf: Explains theroy.

Comments and Ratings (7)

payam pourali

plz send me.

fung hinbon

M Kommant

great. example in C for PDF Postscript:
pdf_circle(float midY, float midY, float radius)
{ // incomplete C example
float BX1, BY1, BX2, BY2, Xs, Ys, Xe, Ye, kappa;
fprintf(pdffile, "q\n"); // postscript content in pdf
// init line type etc. with /GSD gs G g (grey) RG rg (RGB) w=line witdh etc.
fprintf(pdffile, "1 j\n"); // line join
// translate ("move") circle to midY, midY
fprintf(pdffile, "1 0 0 1 %f %f cm", midX, midY);
kappa=0.5522847498307933984022516322796;
/* Quadrant 1 */
Xs=0.0; /* 12 o'clock */
Xs=0.0 + radius;
Xe=0.0 + radius; /* 3 o'clock */
Ye=0.0;
fprintf(pdffile "%f %f m\n", Xs, Ys); /* move to 12 o'clock */
/* cubic bezier control point 1, start height and kappa * radius to the right */
BX1=Xs + (radius * kappa);
BY1=Ys;
/* cubic bezier control point 2, end and kappa * radius above */
BX2=Xe;
BY2=Ye + (radius * kappa);
// draw cubic bezier from current point to Xe/Ye with BX1/BY1 and BX2/BY2 as bezier control points
fprintf(pdffile, "%f %f %f %f %f %f c\n", BX1, BY1, BX2, BY2, Xe, Ye);
/* Quadrant 2 */
Xs=Xe; Ys=Ye; /* 3 o'clock */
Xe=0.0; Ye=0.0 - radius; /* 6 o'clock */
BX1=Xs; /* cubic bezier point 1 */
BY1=Ys - (radius * kappa);
BX2=Xe + (radius * kappa); /* cubic bezier point 2 */
BY2=Ye;
fprintf(pdffile, "%f %f %f %f %f %f c\n", BX1, BY1, BX2, BY2, Xe, Ye);
/* Quadrant 3 */
Xs=Xe; Ys=Ye; /* 6 o'clock */
Xe=0.0 - radius; Ye=0.0; /* 9 o'clock */
BX1=Xs - (radius * kappa); /* cubic bezier point 1 */
BY1=Ys;
BX2=Xe; /* cubic bezier point 2 */
BY2=Ye - (radius * kappa);
fprintf(pdffile, "%f %f %f %f %f %f c\n", BX1, BY1, BX2, BY2, Xe, Ye);
/* Quadrant 4 */
Xs=Xe; Ys=Ye; /* 9 o'clock */
Xe=0.0; Ye=0.0 + radius; /* 12 o'clock */
BX1=Xs; /* cubic bezier point 1 */
BY1=Ys + (radius * kappa);
BX2=Xe - (radius * kappa); /* cubic bezier point 2 */
BY2=Ye;
fprintf(pdffile, "%f %f %f %f %f %f c\n", BX1, BY1, BX2, BY2, Xe, Ye);
fprintf(pdffile, "s\n"); /* stroke circle, do not fill and close path */
// for filling etc. b, b*, f, f*
fprintf(pdffile, "Q\n"); // finish postscript in PDF
}

bharat chauhan

good

chandra sekahr

youngnam kang

Thank you

Updates

1.1.0.0

BSD License

1.0.0.0

more compact

remove grammatical error in description

MATLAB Release Compatibility
Created with R14SP1
Compatible with any release
Platform Compatibility
Windows macOS Linux