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

CRT, why there is coating of phosphorous on CRT screen?

why there is coating of phosphorous on CRT screen?

Dv encoder types, DV Encoder Types: While DV is captured in a computer thi...

DV Encoder Types: While DV is captured in a computer this is stored in an AVI file, that is Microsoft's standard file format used for video files. Video support in Windows is prov

Write short notes on active and passive transformations, Write short notes ...

Write short notes on active and passive transformations?  In the active transformation the points x and x| show different coordinates of the similar coordinate system. Here all

Polygon or area clipping algorithm, Polygon or Area Clipping Algorithm - Su...

Polygon or Area Clipping Algorithm - Sutherland-Hodgman Algorithm There are different algorithms as Liang-Barsky, Line clipping, Weiler-Atherton Polygon Clipping,

Write short notes on active and passive transformations, Write short notes ...

Write short notes on active and passive transformations?  In the active transformation the points x and x represent different coordinates of the similar coordinate system. Here

Orientation dependence - modeling and rendering, Orientation Dependence - M...

Orientation Dependence - Modeling and Rendering The outcomes of interpolated-shading models are dependent of the projected polygon's orientation. Because values are interpolat

Magnify a triangle with vertices, Magnify a triangle with vertices A = (1,1...

Magnify a triangle with vertices A = (1,1), B = (3,1) and C = (2,2) to twice its size in such a way that A remains in its original position.  Answer: You need to apply scaling b

Combined consequence of ambient and diffused reflection, Combined consequen...

Combined consequence of ambient and diffused reflection At this time the resulting intensity I will be the total sum of the intensities in case 8.3.2 and 8.3.3 we find that:

Describe transformation, What is Transformation?  Transformation is the...

What is Transformation?  Transformation is the process of introducing changes in the shape size and orientation of the object using scaling rotation reflection shearing & trans

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