Computer graphics-midpoint generation algorithm for Ellipse

Source: Internet
Author: User
Tags ellipse drawing

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

Related Article

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.