Skip to main content

Scan Conversion(Circle) - Midpoint Algorithm

Assignment 05.
  1. Use the mid-point circle technique to derive the necessary equations to scan convert the following circular sector (i.e., points from 270o to 315o)
  2. Implement your method and use the circle's symmetric property to draw complete circles.
  3.  
  4. The file is available here (ScanConvertCirclemidpoint.cpp)
  5. Play with it. You will understand..

Comments


  1. this code also correct!!
    void MidpointCircle(GLint x1, GLint y1, GLint x2, GLint y2){
    /********************************************************************
    This function draws a Circle using the Midpoint Circle algorithm for 270 - 315
    *********************************************************************/
    float r1 = (x2-x1)(x2-x1) + (y2-y1)(y2-y1);
    float r = sqrt(r1);
    int x=0,y=-r,p=1-r;
    while(x<=-y)
    {
    plot(x1+x,y1+y);

    if(p<0)
    {
    p=p+2*x+3;
    }
    else
    {

    p=p+2*(x+y)+5;
    y++;
    }
    x++;
    }

    }

    ReplyDelete

Post a Comment

Popular posts from this blog

Some Basic Questions and answers on Operating System Concepts

1.        What are the three main purposes of an operating system? To provide an environment for a computer user to execute programs on computer hardware in a convenient and efficient manner. To allocate the separate resources of the computer as needed to solve the problem given. The allocation process should be as fair and efficient as possible. As a control program it serves two major functions: (1)    supervision of the execution of user programs to prevent errors and improper use of the computer, and (2)    Management of the operation and control of I/O devices. 2.       Keeping in mind the various definitions of operating system, consider whether the operating system should include applications such as web browsers and mail programs. Argue both that it should and that it should not, and support your answers. Point: Applications such as web browsers and email tools are performing an...

Play Fair Cipher (Version 2-with some corrections)

In my last post, I attached a file ( PlayFairCipher.java ) as my Play Fair Cipher Crypto System. But, I found out that it has an error when converting single row or column-wise words (E.g. WORD, PICO). Hence, I re-edited the file and my second version of it. Now it was working as expected. File : PlayFairCipherv2.java Comments are welcome.

Rotating a Line w.r.t Origin and an Endpoint

Assignment 10 Rotating a given point in a anticlockwise direction about the origin in 2D. (You can specify a point by the left mouse button, and click the right mouse button to rotate it). Write a program to rotate any  line  through an angle (say 30 o ) with respect to  the origin [ Answer ]  one of its end points [ Answer ]