PDFdev is a service provided by PDFzone.com | http://www.pdfzone.com _____________________________________________________________

I'm just going to cut and paste some snippets from my C++ source. This source if for an elliptical arc. If anyone has a better algorithm I'd love to see it!

Kappa is a constant that is multiplied times the radius of a circle to calculate the length of control vector required to approximate a quarter circle (or quarter ellipse) with a Bezier curve.

#define KAPPA 0.5522848.

 sinP = 0.0;
 cosP = primary;    // length of ellipse primary axis
 sinS = secondary;   // length of  ellipse secondary axis
 cosS = 0.0;

 sinPK = KAPPA * secondary;
 cosPK = 0.0;
 sinSK = 0.0;
 cosSK = KAPPA * primary;

double fraction = fabs(end - start) / HALF_PI; // 'start' and 'end' are the starting and
// ending angle of the arc;
// 'fraction' is the percentage of a quarter arc


 // calculate point 'a' on the ellipse
 a.x = primary * cos(start);
 a.y = secondary * sin(start);

// calculate the radius at start, but swap the axes
double radius = pow(pow(secondary * cos(start), 2.0) + pow(primary * sin(start), 2.0), 0.5);


 // calculate the tangent angle at point 'a'
 double slope = -((pow(secondary, 2.0) * a.x) / (pow(primary, 2.0) * a.y));
 double tanAngle;
 if (quad < 2)
   tanAngle = atan2(-slope, -1.0);
 else
   tanAngle = atan2(slope, 1.0);

   // 'ac' is the control point
 ac = a;
 ac.x += KAPPA * radius * cos(tanAngle) * fraction;
 ac.y += KAPPA * radius * sin(tanAngle) * fraction;

Calculation of point 'b' and 'bc' are similar.

Good luck!

Alan

Dennis Myr�n wrote:

Hi.

Sorry if this might be off the topic.

Given a size(diameter), a center position,
a start angle and a sweep angle, i need to compute the bezier control points for a pie shape.


I know how to calculate the starting point as well as the ending point, but i cant figure out how to calculate the first and the second control points to "magnetize" the pie.

Any help is greatly appreciated.

Regards,
Dennis





Regards,

**Dennis Myr�n**

Developer

GREY Digital Oslo

(+47) 21 60 33 63

(+47) 98 00 11 92

mailto:[EMAIL PROTECTED]

www. greydigital.no





--

D. Alan Stewart
Senior Software Developer
Layton Graphics, Inc.
155 Woolco Drive
Marietta, GA 30065
Voice: 770/973-4312
Fax: 800/367-8192
http://www.layton-graphics.com



To change your subscription:
http://www.pdfzone.com/discussions/lists-pdfdev.html



Reply via email to