Computer graphics-Midpoint generation algorithm verification of Circle

Source: Internet
Author: User

Algorithm Description:

The algorithm of the midpoint generation of a circle

If we construct the functionF(x,y)= x2+ y2- R2, the points on the circle haveF(x,y) = 0, for points outside the circleF(x,y) >0, for points within the circleF(x,y) <0.

As with the midpoint drawing line method, the construction discriminant:

D=F(M)=F( xp+1,yp -0.5) = (XP+ 1)2+(YP-0.5)2- R2

if D <0, you should take P1 is the next pixel, and then the discriminant of the next pixel is:

D=F(XP+2,YP-0.5) = (XP+2)2+(YP-0.5)2- R2=d +2XP+3

if D ≥ 0, you should take P2 is the next pixel, and the discriminant of the next pixel is

D=F(XP+2,YP-1.5) = (XP+2)2+(YP-1.5)2- R2=d+2 (XP-YP) +5

The first pixel we're talking about here is (0, R ), discriminant D the initial values are:

d0=F(1,R-0.5) =1.25-R

Detail Code:Computer Graphics-code_1

Build Result:

Computer graphics-midpoint generation algorithm validation for a circle

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.