5.0

5.0 | 6 ratings Rate this file 7 Downloads (last 30 days) File Size: 117.51 KB File ID: #6844
image thumbnail

Approximation of Circle Using Cubic Bezier Curve

by Dr. Murtaza Khan

 

01 Feb 2005 (Updated 09 Jul 2009)

Approximation of unit radius circle with four parametrix bezier curves

| Watch this File

File Information
Description

(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.

MATLAB release MATLAB 7.0.1 (R14SP1)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Comments and Ratings (6)
06 Mar 2006 youngnam kang

Thank you

24 Mar 2006 chandra sekahr  
12 Apr 2006 bharat chauhan

good

02 Nov 2006 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
}

03 Dec 2007 fung hinbon  
16 Dec 2007 payam pourali

plz send me.

Please login to add a comment or rating.
Updates
03 Feb 2005

remove grammatical error in description

01 May 2006

more compact

09 Jul 2009

BSD License

Tag Activity for this File
Tag Applied By Date/Time
approximation Dr. Murtaza Khan 22 Oct 2008 07:40:31
interpolation Dr. Murtaza Khan 22 Oct 2008 07:40:31
circle Dr. Murtaza Khan 22 Oct 2008 07:40:31
cubic Dr. Murtaza Khan 22 Oct 2008 07:40:31
bezier Dr. Murtaza Khan 22 Oct 2008 07:40:31
points Dr. Murtaza Khan 22 Oct 2008 07:40:31
control Dr. Murtaza Khan 22 Oct 2008 07:40:31
curve Dr. Murtaza Khan 22 Oct 2008 07:40:31
interpolation SaraY 24 Feb 2009 22:17:24
points SaraY 24 Feb 2009 22:17:26

Contact us at files@mathworks.com