Algorithm series (13) Ellipse generation algorithm

Source: Internet
Author: User

Ellipse is a common figure in the field of graphics, and the generation algorithm of ellipse (raster conversion algorithm) is one of the most common generation algorithms in graphics software. In the plane analytic geometry, the equation of the ellipse can be described as (x–x0) 2/a2+ (y–y0) 2/b2 = 1, where (x0, y0) is the center coordinate, a and B are the long and long axes of the ellipse, especially when (x0, y0) is the coordinate center point, the elliptic equation can be reduced to X2/A2 + Y2/B2 = 1. In computer graphics, elliptic graphics also have problems of displaying or outputting on the dot-matrix output device, so a raster scan conversion algorithm is also needed. In order to simplify, we first consider the generation of the ellipse at the center of the origin, and the ellipse that is not the origin, the ellipse of the corresponding position can be obtained by the translation transformation of the coordinate.

Before you perform a scan transformation, you need to understand the symmetry of the ellipse, as shown in figure (1):

Figure (1) symmetry of an ellipse

The center is at the original point. The standard ellipse with the focus on the axis has an x-axis symmetry, y Axisymmetric and Origin symmetry, known as the P-point coordinate of the first quadrant of the Ellipse is (x, y), then the symmetry points of the ellipse in the other three quadrants are (x, y), (x, Y), and (-X,-y) respectively. So as long as you draw the One-fourth ellipse of the first quadrant, you can use these three symmetries to get the entire ellipse.

There are many methods of output ellipse on raster device, which can solve the point coordinate directly according to the coordinate equation of rectangular plane, yekeyii use polar coordinate equation to solve, but because it involves floating point to get the whole, the effect is not good, generally do not use direct solution method. This paper introduces two kinds of commonly used ellipse generation methods in computer graphics: Midpoint-drawing ellipse algorithm and Bresenham ellipse generation algorithm.

1. Midpoint Drawing Ellipse method

The plane set equation of the ellipse on the axis (axis alignment) of the midpoint at the origin of the coordinates is:

X2/A2 + Y2/B2 = 1 can also be transformed into the following nonparametric equation form:

F (x, y) = b2x2 + a2y2-a2b2 = 0 (equation 1)

Whether it is the midpoint line algorithm, the midpoint circle algorithm or the midpoint ellipse algorithm introduced in this verse, it is very sensitive to choose the x direction pixel delta increment or the y direction pixel Delta increment. For example, if there is an increment of 1 pixels in the x direction on the arc of a segment, the increment in the y direction if < 1, is more suitable for the midpoint algorithm, if the Y-direction of the Increment > 1, will produce some jumping points, the last generated raster bitmap arc will have some mutation point, it looks like not on the arc. Therefore, for the midpoint of the arc algorithm, we should distinguish which section of the elliptical arc Δx increment changes significantly, which segment Δy increment change significantly, and then treated differently. Because of the symmetry of the ellipse, we consider only the elliptical arc of the first quadrant, as shown in Figure (2):

Fig. (2) schematic diagram of the first Quadrant elliptical arc

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.