Computer graphics-midpoint generation algorithm for parabolic line

Source: Internet
Author: User

Algorithm Description:

  For parabolic, the most special case is analyzed, that is, the symmetry axis is the y axis, and it passes through the origin point of coordinates. :

  

As long as such a parabolic line is generated, the general parabola can be translated and rotated by this special case. Because the parabolic in this special case is symmetrical on both sides of the y-axis, it is only necessary to solve the parabolic formation in the first quadrant to obtain a complete image.
So how to get the parabolic in this special case

By the assumption that a point in the first quadrant of the parabola to move from the origin, and over that point A as a parabola tangent, then according to the slope of the tangent line k=1 can be divided into two parts of the quadrant, part of Point a left, the tangent slope is all less than 1, the other part is point A to the right, the tangent slope is all greater
Based on the idea of the previous midpoint generation algorithm, in the left half, each generation can increment the x coordinate by 1, and determine if the Y coordinate increases according to the decision parameters.

Area 1

In the right half, each build increments the Y coordinate by 1 and determines whether the X coordinate increases based on the decision parameters.

Zone 2

  The next step is the derivation of the decision parameters:

  The parabolic equation is, then the curve equation has two forms:

  

 Zone 1:

  

At that time: the coordinates of the next point should be selected at this time:

  

At that time: the coordinates of the next point should be selected at this time:

  

  

  Zone 2:

  

At that time: the coordinates of the next point should be selected at this time:

  

At that time: the coordinates of the next point should be selected at this time:

  

  Detailed code: Computer Graphics-code_1

Build Result:

  

Computer graphics-midpoint generation algorithm for parabolic line

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.