Draw a long line segment using dda line drawing algorithm, Computer Graphics

Assignment Help:

Draw a long line segment using (i) DDA line drawing algorithm (ii) Bresenham line drawing algorithm (iii) OpenGL function using GL_LINES.  Observe if DDA line segment deflects from Bresenham line segment or the graphics library line segment. 

Answer: Implementation of Bresenham and DDA algorithm is already given on page 20-21 of this unit.  Use the code to draw a line segment (10, 20) - (1020, 700) using both the algorithms.  Further, we draw the same line segment by adding the following code in the RenderScene( ) function of the code using the following OpenGL library function.    

glBegin(GL_LINES);

   glVertex2i(1020,700);

   glVertex2i(10,20);

   glEnd();  

Use a different colour for each of the three codes. Accordingly code of RenderScene( ) will be modified as follows:   

void RenderScene(void)

{

glClear(GL_COLOUR_BUFFER_BIT);

glColour3f(1.0f, 0.0f, 0.0f);    

bresenham(10,20,1020,700);//Bresenham line segment with RED

   glColour3f(0.0f, 1.0f, 0.0f);        

  dda(10,20,1020,700); //dda line segment with GREEN

  glColour3f(1.0f, 1.0f, 1.0f);        

  glBegin(GL_LINES);

   glVertex2i(1020,700);

   glVertex2i(10,20);

  glEnd(); //OpenGl Line segment with WHITE

        glFlush();   

}

On present day systems with very high accuracy on floating point calculations all the three line segments are plotting almost the same line segment. However, if you run the same program on an older system, you would find that the pixels generated by DDA algorithm are slightly away from the two line segments that have been generated using Bresenham algorithm and OpenGL function. The OpenGL function and Bresenham algorithm produce almost the same line segments.


Related Discussions:- Draw a long line segment using dda line drawing algorithm

Algorithm scan-line, Algorithm (scan-line): For each scan line perform ...

Algorithm (scan-line): For each scan line perform from step (1) to (3). 1) For all pixels on a scan-line, arrange depth [x]=1.0 i.e. max value and Intensity [x] = background

Draw line segment - digital differential analyzer algorithm, Example 1: Dr...

Example 1: Draw line segment from point (2, 4) to (9, 9) by using Digital Differential Analyzer algorithm. Solution: We know usual equation of line is specified via y = mx

PERT , Program of PERT in c language

Program of PERT in c language

Macintosh - hardware for computer animation, Macintosh - Hardware for compu...

Macintosh - Hardware for computer animation It was originally designed to be graphic and desktop publishing machines. Macs did not turn into which widely known till recently, a

digital audio technologies, Digital audio technologies DAB (Digita...

Digital audio technologies DAB (Digital Audio Broadcasting) Digital Audio Tape (DAT) DVD DVD-A Digital audio player Compact disc (CD) Minidisc (obsolete

Storing information structures in display memory, What is the major disadva...

What is the major disadvantages of storing information structures in display memory? A major disadvantage of storing information structures in display memory is that when color an

Application in image capture formats, Application Interlacing is utiliz...

Application Interlacing is utilized through all the analogue TV broadcast systems in recent use as: NTSC: 59.94 fields per second, 525 lines, still field drawn first

Determine the perspective transformation matrix, Determine the perspective ...

Determine the perspective transformation matrix upon to z = 5 plane, when the center of projection is at origin. Solution. As z = 5 is parallel to z = 0 plane, the normal is s

Flash - software to generate computer animations, Flash - software to gener...

Flash - software to generate computer animations Flash: Learning Macro-Media's Flash can quite complicated, although you can do almost anything along with it. You can devel

Digital audio comprises audio signals, Digital audio comprises audio signal...

Digital audio comprises audio signals stored in a digital format. Particularly, the term encompasses the subsequent: 1)   Audio conversion: 1.   Analogue to digital conversi

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd