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

What is surface patch, What is surface patch?  A single surface element...

What is surface patch?  A single surface element can be explained as the surface traced out as two parameters (u, v) take all possible values between 0 and 1 in a two-parameter

Objectives-introduction to computer graphics, Objectives After complet...

Objectives After completing this section, you must be familiar with: explain computer graphics, its characteristics and features; Conversations about applicat

Key frame systems - computer animation, Key Frame Systems - computer animat...

Key Frame Systems - computer animation This method is for low-level motion control. In fact these systems comprise languages that are designed simply to produce the in-between

Resolution-introduction to computer graphics, Resolution Graphic demons...

Resolution Graphic demonstrations are utilized in presentations to assist convey a concept or express a mood, two kinds of demonstrations graphics are: Vector, and B

What are the important properties of bezier curve, What are the important p...

What are the important properties of Bezier Curve?  It requires only four control points It always passes by the first and last control points The curve lies enti

#title., WHAT IS PAINTERS ALGORITHM?

WHAT IS PAINTERS ALGORITHM?

Archeology-applications for computer animation, Archeology: along with the...

Archeology: along with the advent of the computer, the archeologist has obtained a new tool, computer animation. An object-model can be made comparatively quick and without any we

Rigid body or non-rigid body transformations, Rigid body or Non-Rigid body ...

Rigid body or Non-Rigid body Transformations 2D transformations can be classified as rigid body or non-rigid body transformations. Rigid body transformations keep the shape and

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

why there is coating of phosphorous on CRT screen?

Panning and zooming a component, Panning and zooming Components (such as yo...

Panning and zooming Components (such as your Polybounce or Animation) is simply a matter of reFrameing the world window. To pan right or left horizontally, one shifts it in the pos

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