Ellipse generation algorithm
Not strictly speaking, the ellipse is the elongated circle. It can also be said that the ellipse is a modified circle whose radius changes from the maximum in one direction to the minimum of its orthogonal direction. The two orthogonal straight segments of the ellipse are called the long and short axes of the ellipse.
Characteristics of the Ellipse
The exact definition of the ellipse is given by the distance from one point of the ellipse to the two fixed points called the elliptical focus: the sum of the distance between the ellipse and the two point is equal to a constant (see figure 3.21). If any point on the ellipse has a distance of P = (x, y) to two focus D1 and D2, then the general equation of the ellipse can be expressed as
Using the focal coordinates f1= (X1,Y1) and F2 = (x2,y2) to represent the distance D1 and D2, you can get
To square the equation, remove the remaining root, and then square, you can rewrite the general elliptic equation in the following form:
The coefficients A, B, C, d,e, F are calculated based on the focal coordinates and the dimensions of the long and short axes. A long axis is a line segment that passes the focus from one side of the ellipse to the other. The short axis is a shorter size across the ellipse, which divides the long axis by the midpoint position between the two focal points (the center of the ellipse).
The interactive method for specifying an ellipse in any direction is to enter two focus points and a point on the ellipse boundary. Using these three coordinate positions, the constants in the equation (3.35) can be obtained. You can then find the coefficients in equation (3.36) and use them to generate pixels along an elliptical path.
If the short axis and the long axis are parallel to the axis, then the elliptic equation can be greatly simplified. Figure 3.22 shows an ellipse with a "standard position". The long axis and the short axis are parallel to the X and Y axes. In this example, the parameter Rx identifies the long axis, and the parameter Ry identifies the short axis. For the elliptic equation in Figure 3.22, it can be rewritten with the help of the ellipse center coordinate and the parameter Rx and ry
Using polar coordinates: R and θ, you can also describe a standard position ellipse in the form of a parametric equation:
Θ, called an elliptical centrifugal angle (eccentricangle), is measured along the circumference of its enclosing circle. If rx> ry, the radius of the enclosing circle is R = Rx (see figure 3.23), otherwise the radius of the enclosing circle is R = Ry
As with the circle algorithm, considering the symmetry of the ellipse can further reduce the computational amount. The ellipse in the standard position is symmetrical in the four quadrant, but unlike a circle, it is not symmetrical in the eight quadrant. Therefore, we must calculate the pixel position of the elliptic curve in one quadrant, and then the pixel position in the other three quadrants by symmetry (see Figure 3.24).
Computer Graphics (ii) output graph element _6_opengl curve function _3_ ellipse generation algorithm