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

C++ programming, self test exercise 17 asked you to overload the operator >...

self test exercise 17 asked you to overload the operator >> and the operator Overload biinary operator + to add pairs according to the rule (a, b) + (c, d) = (a + c, b, + d) overl

Essentialily of computer simulation, Essentialily of Computer Simulation ...

Essentialily of Computer Simulation You may want to understand why to do simulation? Is there any one way to perform the tasks? To converse these matters lets briefly discuss

Printing press discovered in 16th century, Printing Press discovered in 16t...

Printing Press discovered in 16th century: Books provided more role models & multiple perspectives. Exposure to books demanded that learners employ critical thinking to r

Bresenham line generation algorithm for positive slope, Bresenham Line Gene...

Bresenham Line Generation Algorithm for Positive Slope (BLD algorithm for positive slope (0 - If slope is negative then utilize reflection transformation to transform the

Time based and presentation tools, Time Based and Presentation Tools In...

Time Based and Presentation Tools In such authoring systems, components and events are organized beside a timeline, along with resolutions as high as 1/30 second. Time based to

Parametric continuity conditions , Parametric Continuity Conditions   To e...

Parametric Continuity Conditions   To ensure a smooth transitions from one section of a piecewise parametric curve to the next, we can impose various continuity conditions at the

Key frame systems, Ask questionkms eey frame syst #Minimum 100 words accept...

Ask questionkms eey frame syst #Minimum 100 words accepted#

Definition of computer animation, Definition of Computer Animation A ti...

Definition of Computer Animation A time dependence phenomenon for imparting visual modifies in any scene as per to any time sequence, the visual modifies could be incorporated

Important points about the curve segment, Important Points about the Curve ...

Important Points about the Curve segment - properties of bezier curves Note : if P (u) → = Bezier curve of sequence n and Q (u) → Bezier curve of sequence m. After that Co

B-spline curves - clipping and 3d primitives, B-spline curves - clipping an...

B-spline curves - clipping and 3d primitives B-spline curves are piecewise polynomial cubes with one or more polynomial pieces with a minimum smoothness requirement.  For examp

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