The main idea of this program comes from the breseham algorithm,
The evolving thing is to increase rotation!
The algorithm description will not be written, so it is very tired to beat!
List the programs!
The MFC code is as follows:
//////////////////////////////////////// //////////////////////////////////////// ////
// Breellipse
// (XC, YC) ---------- elliptical Center
// FLA, flb ---------- radius of the horizontal and vertical axes
// Double ----------- Rotation Angle
//////////////////////////////////////// //////////////////////////////////////// ////
Void breellipse (CDC * PDC, float XC, float YC, float FLA, float flb, double angle)
{
Int I;
Float a, B, X, Y;
Double dx, Dy, Di, AA, BB, Sina, cosa;
Cosa = cos (angle );
Sina = sin (angle );
A = FLA;
B = flb;
AA = A *;
BB = B * B;
Float flx [4], fly [4];
X = 0;
Y = B;
DX = 0;
DY = 2 * AA * Y;
DI = BB-aa * B + AA/4;
Flx [0] = XC + x * cosa-y * Sina;
Flx [1] = XC + x * cosa + y * Sina;
Flx [2] = XC-x * cosa-y * Sina;
Flx [3] = XC-x * cosa + y * Sina;
Fly [0] = YC + y * cosa + x * Sina;
Fly [1] = YC-y * cosa + x * Sina;
Fly [2] = YC + y * cosa-x * Sina;
Fly [3] = YC-y * cosa-x * Sina;
I = 0;
While (DX <Dy)
{
I ++;
If (I = 5)
{
PDC-> moveTo (flx [0], fly [0]);
PDC-> lineto (XC + x * cosa-y * Sina, YC + y * cosa + x * Sina );
PDC-> moveTo (flx [1], fly [1]);
PDC-> lineto (XC + x * cosa + y * Sina, YC-y * cosa + x * Sina );
PDC-> moveTo (flx [2], fly [2]);
PDC-> lineto (XC-x * cosa-y * Sina, YC + y * cosa-x * Sina );
PDC-> moveTo (flx [3], fly [3]);
PDC-> lineto (XC-x * cosa + y * Sina, YC-y * cosa-x * Sina );
Flx [0] = XC + x * cosa-y * Sina;
Flx [1] = XC + x * cosa + y * Sina;
Flx [2] = XC-x * cosa-y * Sina;
Flx [3] = XC-x * cosa + y * Sina;
Fly [0] = YC + y * cosa + x * Sina;
Fly [1] = YC-y * cosa + x * Sina;
Fly [2] = YC + y * cosa-x * Sina;
Fly [3] = YC-y * cosa-x * Sina;
I = 0;
}
X ++;
Dx + = 2 * BB;
Di + = dx + BB;
If (Di> = 0)
{
Dy-= 2 * AA;
Di-= Dy;
Y --;
}
}
PDC-> moveTo (flx [0], fly [0]);
PDC-> lineto (XC + x * cosa-y * Sina, YC + y * cosa + x * Sina );
PDC-> moveTo (flx [1], fly [1]);
PDC-> lineto (XC + x * cosa + y * Sina, YC-y * cosa + x * Sina );
PDC-> moveTo (flx [2], fly [2]);
PDC-> lineto (XC-x * cosa-y * Sina, YC + y * cosa-x * Sina );
PDC-> moveTo (flx [3], fly [3]);
PDC-> lineto (XC-x * cosa + y * Sina, YC-y * cosa-x * Sina );
Di + = int (3*(AA-bb)-2*(DX-dy)/4 + 0.5 );
Flx [0] = XC + x * cosa-y * Sina;
Flx [1] = XC + x * cosa + y * Sina;
Flx [2] = XC-x * cosa-y * Sina;
Flx [3] = XC-x * cosa + y * Sina;
Fly [0] = YC + y * cosa + x * Sina;
Fly [1] = YC-y * cosa + x * Sina;
Fly [2] = YC + y * cosa-x * Sina;
Fly [3] = YC-y * cosa-x * Sina;
I = 0;
While (Y> 0)
{
I ++;
If (I = 5)
{
PDC-> moveTo (flx [0], fly [0]);
PDC-> lineto (XC + x * cosa-y * Sina, YC + y * cosa + x * Sina );
PDC-> moveTo (flx [1], fly [1]);
PDC-> lineto (XC + x * cosa + y * Sina, YC-y * cosa + x * Sina );
PDC-> moveTo (flx [2], fly [2]);
PDC-> lineto (XC-x * cosa-y * Sina, YC + y * cosa-x * Sina );
PDC-> moveTo (flx [3], fly [3]);
PDC-> lineto (XC-x * cosa + y * Sina, YC-y * cosa-x * Sina );
Flx [0] = XC + x * cosa-y * Sina;
Flx [1] = XC + x * cosa + y * Sina;
Flx [2] = XC-x * cosa-y * Sina;
Flx [3] = XC-x * cosa + y * Sina;
Fly [0] = YC + y * cosa + x * Sina;
Fly [1] = YC-y * cosa + x * Sina;
Fly [2] = YC + y * cosa-x * Sina;
Fly [3] = YC-y * cosa-x * Sina;
I = 0;
}
Y --;
Dy-= 2 * AA;
Di + = AA-dy;
If (di <0)
{
Dx + = 2 * BB;
Di + = DX;
X ++;
}
}
PDC-> moveTo (flx [0], fly [0]);
PDC-> lineto (XC + x * cosa-y * Sina, YC + y * cosa + x * Sina );
PDC-> moveTo (flx [1], fly [1]);
PDC-> lineto (XC + x * cosa + y * Sina, YC-y * cosa + x * Sina );
PDC-> moveTo (flx [2], fly [2]);
PDC-> lineto (XC-x * cosa-y * Sina, YC + y * cosa-x * Sina );
PDC-> moveTo (flx [3], fly [3]);
PDC-> lineto (XC-x * cosa + y * Sina, YC-y * cosa-x * Sina );
}