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

Camera - polygon rendering and ray tracing methods, Camera - polygon render...

Camera - polygon rendering and ray tracing methods Camera presents "viewpoint" or "eye" of observer. In order to explain the fundamental working of camera we can consider this

Describe the wiggler function in animation help, Question 1: (a) Descri...

Question 1: (a) Describe the term Mask Path and give brief steps how you could change a rectangle into a triangle with respect to time in AE CS3. (b) Expressions are ve

Characteristics of vector drawings, Characteristics of vector drawings: Ve...

Characteristics of vector drawings: Vector drawings are generally pretty small files as they include only data about the Bezier curves which form the drawing. The EPS-file format

Explain advantages of rendering polygons by scan line method, What are the ...

What are the advantages of rendering polygons by scan line method?  i. The max and min values of the scan were simply found.  ii. The intersection of scan lines with edges i

Windowing transformations - raster graphics and clipping, Windowing Transf...

Windowing Transformations - Raster Graphics and  Clipping From the above section of introduction, we understood the meaning of the viewport and term window that could again be

Engineering-applications for computer animation, Engineering: CAD has alwa...

Engineering: CAD has always been an imperative tool in industry. For illustration in automobile design, CAD could be utilized to model a car. Although with the advent of computer

Various cases of cohen sutherland line clippings - algorithm, Various cases...

Various cases of Cohen Sutherland Line Clippings Currently, we study how this clipping algorithm works. For the sake of simplicity we will tackle all the cases with the assist

What is shearing, What is shearing?  The shearing transformation actua...

What is shearing?  The shearing transformation actually slants the object with the X direction or the Y direction as needed.ie; this transformation slants the shape of an obje

Visible surface detection - modeling and rendering , Visible Surface Detect...

Visible Surface Detection - Modeling and Rendering Provided a set of 3-Dimentional objects and a viewing position for the generation of realistic graphics show, we want to de

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