Algorithm Description:
For a general position ellipse, for example, you can pan the center to the coordinate origin, determine the ellipse pixel point set at the standard position of the center at the origin, and then pan to the position, transforming the problem into a standard position of the ellipse's drawing problem.
If the long and short axes of an ellipse are not parallel to the axis x and y, then the rotation coordinate transformation can be used to transform the problem into a standard position of the ellipse drawing
That
Define the discriminant of the following ellipse midpoint algorithm:
The
- If < 0, the description is within the ellipse boundary;
- if = 0, it is indicated on the ellipse boundary;
- If > 0, the description is outside the ellipse boundary;
Due to the symmetry of the ellipse, only the generation of the first quadrant elliptical arc is discussed here.
In the process of this elliptical arc, it is further divided into two parts: the upper and the lower parts, with the slope of the arc 1 points as the demarcation.
In the upper part, the unit step is taken in the x direction, and the position of the next pixel is determined;
In the lower part of the slope less than 1, the unit step is taken in the Y direction to determine the position of the next pixel.
The midpoint generation of the ellipse is similar to the midpoint generation algorithm of the line and circle.
Detailed code: Computer Graphics-code_1
Build Result:
Computer graphics-midpoint generation algorithm for Ellipse