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

Determine the transformation matrix for the reflection, Determine the trans...

Determine the transformation matrix for the reflection about the line y = x. Solution: The transformation for mirror reflection regarding to the line y = x, comprises the subs

Will the shape of the resulting b-spline curve change, If the spacing betwe...

If the spacing between the knot sequence is uniformly doubled, will the shape of the resulting B-spline curve change?  Justify your answer.

What do you mean by perspective projection, What do you mean by Perspective...

What do you mean by Perspective projection?  Perspective projection is one in which the lines of projection are not parallel. Instead, they all converge at a single point known

What is the minimum number of control points, Question: A curve shape ha...

Question: A curve shape has three quadratic Bézier curve segments. The curves have been joined sequentially so that continuity of the first derivative of the resulting curve sha

Containment test - visible surface detection, Containment Test -  visible s...

Containment Test -  visible surface detection Test: That is Containment test: it can be either comprised (contained) or surrounding polygon, if intersection test fails. The

Production of animation , Historical and traditional methods for productio...

Historical and traditional methods for production of animation                                              Definition: Computer animation is a time depends phenome

Acquire a transformation matrix for perspective projection, Acquire a trans...

Acquire a transformation matrix for perspective projection for a specified object projected onto x=3 plane as viewed by (5,0,0). Solution: Plane of projection: x = 3 as given.

General perspective transformation with cop at the origin, General Perspect...

General Perspective transformation with COP at the origin Here we suppose the given point P(x,y,z) be projected like P'(x',y',z') on the plane of projection. The center of pro

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