drawing an ellipse at an arbitrary angle
Author Message drawing an ellipse at an arbitrary angle

I need a routine to generate a polygonal boundary (ie a series of points) of
a rotated ellipse. Does anyone have a routine for that ?

Mon, 24 May 2004 01:49:31 GMT  drawing an ellipse at an arbitrary angle
On Wed, 5 Dec 2001 09:49:31 -0800, "Stephen Fogarasi"

[Sorry for the x-post followup everone]

Quote:
>I need a routine to generate a polygonal boundary (ie a series of points) of
>a rotated ellipse. Does anyone have a routine for that ?

Try the newsgroup FAQ's of:

comp.graphics.algorithms

That'll keep you busy for a few hours :)

Jim M

Mon, 24 May 2004 04:52:55 GMT  drawing an ellipse at an arbitrary angle
An ellipse is given by:

SQ(X) + SQ(Y) = 1
-------    -------
SQ(RX) SQ(RY)

(somthing like that anyway)

To rotate it, take every point and transform it.

*OR*

Go to codeproject.com or codeguru.com and find the aricle on drawing rotated
ellipses using bezier curves.
Much easier

Robin

Quote:
> I need a routine to generate a polygonal boundary (ie a series of points)
of
> a rotated ellipse. Does anyone have a routine for that ?

Mon, 24 May 2004 05:07:15 GMT  drawing an ellipse at an arbitrary angle
Transforms the points before calling PolyBezier (see below).

Feng Yuan (Check www.fengyuan.com for source code update  for Windows
Graphics Programming: Win32 GDI and DirectDraw)

This posting is provided "AS IS" with no warranties, and confers no rights.

===========================
// Drawing a full ellipse using 4 Bezier curves
BOOL EllipseToBezier(HDC hDC, int left, int top, int right, int bottom)
{
const double M = 0.55228474983;

POINT P;

int dx = (int) ((right - left) * (1-M) / 2);
int dy = (int) ((bottom - top) * (1-M) / 2);

P[ 0].x = right;     //  .   .   .   .   .
P[ 0].y = (top+bottom)/2;   //       4   3   2
P[ 1].x = right;     //
P[ 1].y = top + dy;         //   5               1
P[ 2].x = right - dx;       //
P[ 2].y = top;      //   6              0,12
P[ 3].x = (left+right)/2;   //
P[ 3].y = top;      //   7               11
//
P[ 4].x = left + dx;     //       8   9   10
P[ 4].y = top;
P[ 5].x = left;
P[ 5].y = top + dy;
P[ 6].x = left;
P[ 6].y = (top+bottom)/2;

P[ 7].x = left;
P[ 7].y = bottom - dy;
P[ 8].x = left + dx;
P[ 8].y = bottom;
P[ 9].x = (left+right)/2;
P[ 9].y = bottom;

P.x = right - dx;
P.y = bottom;
P.x = right;
P.y = bottom - dy;
P.x = right;
P.y = (top+bottom)/2;

return PolyBezier(hDC, P, 13);

Quote:
}

Quote:
> I need a routine to generate a polygonal boundary (ie a series of points)
of
> a rotated ellipse. Does anyone have a routine for that ?

Mon, 24 May 2004 12:56:58 GMT

 Page 1 of 1 [ 4 post ]

Relevant Pages