Computer Graphic Question, Exams of Computer Graphics

Line Drawing and Computer Graphics

Typology: Exams

2018/2019

Uploaded on 01/05/2019

mir-ali
mir-ali 🇵🇰

1 document

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Circle Drawing Using Polar Coordinates
Polar Coordinates:
Radius r
Angle
calculate points along the circular boundary
using polar coordinates r and
Expressing the circle equation in parametric polar form yields the pair of
equations:
x = xc + r cos
y = yc + r sin
Using above equation circle can be plotted by calculating x and y
coordinates as takes values from 0 to 360 degrees or 0 to 2 radians.
The step size for depends on:
. application and
. display device
Larger angular separations along the circumference can be connected with
straight-line segments to approximate the circular path.
Step size at 1/r gives continuous boundary
This plots pixel positions that are approximately one unit apart.
Circle2 (xcenter, ycenter, radius)
for = 0 to 2 step 1/r
x = xc + r * cos
y = yc + r * sin
drawPixel (x, y)
Drawbacks/ Shortcomings
pf3
pf4

Partial preview of the text

Download Computer Graphic Question and more Exams Computer Graphics in PDF only on Docsity!

Circle Drawing Using Polar Coordinates

Polar Coordinates:

Radius r Angle 

calculate points along the circular boundary

using polar coordinates r and 

Expressing the circle equation in parametric polar form yields the pair of equations:

x = xc + r cos  y = yc + r sin 

Using above equation circle can be plotted by calculating x and y coordinates as  takes values from 0 to 360 degrees or 0 to 2 radians.

The step size for  depends on:

. application and . display device

Larger angular separations along the circumference can be connected with straight-line segments to approximate the circular path.

Step size at 1/r gives continuous boundary

This plots pixel positions that are approximately one unit apart.

Circle2 (xcenter, ycenter, radius)

for  = 0 to 2 step 1/r x = xc + r * cos  y = yc + r * sin  drawPixel (x, y) Drawbacks/ Shortcomings

This works, but …

. is inefficient . multiplications & square root . large gaps in the circle for values of x close to r

DDA Algorithm

DDA abbreviated for digital differential analyzer has a very simple technique.

Find difference, dx and dy as:

dy = y2 – y

dx = x2 – x

if |dx| > |dy| then

step = |dx| else step = |dy| Now very simple to say that step is the total number of pixels required for a line.

Next step is to find xIncrement and yIncrement:

xIncrement = dx/step

yIncrement = dy/step

Next a loop is required that will run ‘step’ times.

In the loop drawPixel and add xIncrement to x1 and yIncrement to y1.

Now sum-up all above in the algorithm:

DDA_Line (Point p1, Point p2)

Now, using these three inputs there are a number of ways to draw an ellipse.

To use polar coordinates r and, for that we have parametric equations:

x = xc + rx cosy = yc + ry sin