Friday, 16 August 2013

Various Algorithms in Computer Graphics Curriculum

Digital Differential Analyzer Algorithm


This section will help you understanding DDA Algorithm for line drawing to be implemented in C Graphics using Turbo C / Borland C.

You can find the algorithm at this link.

You have to follow the exact pattern while writing answers that ask you to write algorithms.

If you find any problem in implementing the DDA Algorithm in the software provided, kindly let me know through the comments section, I will try to answer them as quickly as possible. 


The Sample Screen Shot for two coordinates 2,2 and 10,8 is shown below:




Bresenham's Algorithm for Line Drawing


This section will help you understanding Bresenham's Algorithm for line drawing to be implemented in C Graphics using Turbo C / Borland C.

You can find the algorithm at this link.
If you find any problem in implementing the Bresenham's Algorithm in the software provided, kindly let me know through the comments section, I will try to answer them as quickly as possible. 


The Sample Screen Shot for two coordinates 0,0 and 10,6 ( slope, |m| <= 1) is shown below:



Bresenham's Algorithm for Circle Drawing

aka Midpoint Circle Drawing Algorithm


This section will help you understanding Bresenham's Algorithm for circle drawing to be implemented in C Graphics using Turbo C / Borland C.

You can find the algorithm at this link.
If you find any problem in implementing the Bresenham's Algorithm in the software provided, kindly let me know through the comments section, I will try to answer them as quickly as possible. 


The Sample Screen Shot for the input is as:


For the above input, the circle drawn is as:


Note: The Intersection of the horizontal and vertical rectangle is the ORIGIN (0,0)


Cohen - Sutherland Line Clipping Algorithm


This section will help you understanding Cohen - Sutherland Line Clipping Algorithm to be implemented in C Graphics using Turbo C / Borland C.

You can find the algorithm at this link.
If you find any problem in implementing the Cohen - Sutherland Line Clipping Algorithm in the software provided, kindly let me know through the comments section, I will try to answer them as quickly as possible. 


The Sample Screen Shot for the input is as:



Output for the above given input is as:



2 comments:

  1. Sir, I am using windows7, 32-bit OS.For simple c programs my Borlad c++ is working pretty well and when i am trying to execute a graphic related program it is not showing me any error during compilation but when i run it a blank screen appear for few sec. saying "BGI ERROR: Graphics not initialized(use 'initgraph')".What am i suppose to do in this case.MY program is-
    #include
    #include
    void main()
    {
    int *gd=DETECT,*gm;
    initgraph(&gd,&gm,"");
    line(100,200,300,400);
    getch();
    closegraph();
    getch();
    }
    Also when i was installing Borland a msg appeared on screen saying it will be installed in delayed mode.Is it causing the errors??Please help asap.

    ReplyDelete
    Replies
    1. 1. Make sure you are using "#include<graphics.h>"
      2. Make sure you have given third argument to "initgraph" i.e. "C:\\BC5\\BGI"
      3. Make sure you have disabled your graphics driver in Device Manager
      Start->type "Device Manager" -> Display Adapter -> Right Click to disable

      If it still doesn't work,
      1. try removing "*" from gd and gm.
      2. try writing int main() instead of void main().

      Let me know further problems, if any.

      Delete

Ask me anything right here...