How to draw a rotated ellipse at a specific angle (Views: 338)


I'm looking for an algorithm that draws an ellipse, but is not based on the Bresenham mid-point method. I want to specify the bounding box and the algorithm should draw the ellipse. As I need to do things for each pixel on the line of the ellipse, I can not use the Windows.Ellipse(dc...) function. Does anyone have such an algorithm?


The procdure draws an rotated ellipse at a specific angle:

procedure TForm1.EllipseAngle(ACanvas: TCanvas; XCenter, YCenter,
  XRadius, YRadius: Integer; Angle: Integer);
  Step = 49;
  RX, RY: Integer;
  i: Integer;
  Theta: Double;
  SAngle, CAngle: Double;
  RotAngle: Double;
  XC, YC: Integer;
  Kf: Double;
  X, Y: Double;
  XRot, YRot: Integer;
  Points: array[0..Step] of TPoint;
  RotAngle := Angle * PI / 180;
  Kf := (360 * PI / 180) / Step;
  SAngle := Sin(RotAngle);
  CAngle := Cos(RotAngle);
  for i := 0 to Step do
    Theta := i * Kf;
    X := XCenter + XRadius * Cos(Theta);
    Y := YCenter + YRadius * Sin(Theta);
    XRot := Round(XCenter + (X - XCenter) * CAngle - (Y - YCenter) * SAngle);
    YRot := Round(YCenter + (X - XCenter) * SAngle + (Y - YCenter) * CAngle);
    Points[i] := Point(XRot, YRot);

<< Back to main page