Dda program to plot line segments, Computer Graphics

Assignment Help:

Use DDA algorithm to get the output of your program as shown in Figure

2008_DDA program to plot line segments.png

ANs: Use DDA( ) function to plot line segments that have end points on diametrically opposite points on the circumference of a circle.  Take these points on uniform distance.  For example, you may use the following function CirclePoints() to get line segment endpoints (x1 [i], y1[i])  and (x2[i], y2[i]), i=0,1,....5 and use the array 2 y ,2 x ,1y ,1x  as input to your dda() function. Call the DDA function six times as given in plot Lines code below. 

// Compute points on the circumference of a circle.

int Points(int r, int xc, int yc, int x1[6], int y1[6],int

x2[6], int y2[6])

{

 float pi = 3.1416;

 int i=0;

 for(float theta = 0; theta

 {

  x1[i] = xc + r*cos(theta);

  y1[i] =yc+r*sin(theta);

  x2[i] = xc + r*cos(pi+theta);

  y2[i] =yc+r*sin(pi+theta);

  i++;

 }

return x1[6], y1[6], x2[6],y2[6];

}

//Plot line segments using DDA algorithm

void plotLines()

{

 int xx1[6],yy1[6],xx2[6],yy2[6];

 Points(100, 200, 200, xx1, yy1, xx2,yy2);

 for(int i=0;i<=5;i++)

  dda(xx1[i], yy1[i], xx2[i], yy2[i]);

}  

Add the above code in your program for line segment generation using dda() function and call the function plotLines in your RenderScene() function.


Related Discussions:- Dda program to plot line segments

Why Video Game Characters Look Better Today, what is the control for Why Vi...

what is the control for Why Video Game Characters Look Better Today

Performing rotation about an axis, Performing rotation about an Axis Fo...

Performing rotation about an Axis For performing rotation about an axis parallel to one of the coordinate axes (say z-axis), you first need to translate the axis (and hence the

Differentiate between a raster image and vector image, Question: (a) D...

Question: (a) Describe in details the meaning of the following terms often available in drawing tools: (i) Welding objects; (ii) Trimming objects; (iii) Intersecting obje

State the areas of use of data goggles, State the Areas of use of data gogg...

State the Areas of use of data goggles Entertainment   Used in television/films as special effects (for example "holodeck" in Star Trek: The Next Generation and Brazilian

Concept of hyper text and hyper media, Concept Of Hyper Text And Hyper Medi...

Concept Of Hyper Text And Hyper Media:- Any student, who has utilized online assist for gaming etc, will previously be familiar along with a basic component of the Web-Hypertext.Hy

What is monitor, Q. What is Monitor? A Monitor is a television like bo...

Q. What is Monitor? A Monitor is a television like box connected to your computer and providing you a vision into the mind of your PC. It displays what your computer is thinki

Use the midpoint circle algorithm to get the output, Figure uses three dash...

Figure uses three dashed arcs and one small circle. Dashed line or arc is a style attribute that can be attached with a line or a curve. In OpenGL you can use the line stipple func

Plane equation - curves and surfaces, Plane Equation - Curves and Surfaces ...

Plane Equation - Curves and Surfaces Plane is a polygonal surface that bisects its environment in two halves. One is termed to as forward and another as backward half of som

Clip a line segment - cyrus beck line clipping algorithm, How does the Cyru...

How does the Cyrus Beck line clipping algorithm, clip a line segment whether the window is non convex? Solution : see the following figure 13, now the window is non-convex in s

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