Documente Academic
Documente Profesional
Documente Cultură
Theory :- The simplest way to rasterize a line is to solve the governing differential
equation:
Equation of the straight line is
Y = mx + c
Differential with respect to x
∆dy/ ∆dy = m = constant --------------(1)
Assume that the ∆y and ∆x are the small increment in x and y direction along the path
respectively along the path.
Equation (1) can be written as ∆y/ ∆x =y2 - y1/ x2 – x1 = constant --------- (2)
Equation (2) has one solution
Yi +1 = yi + ∆y
= yi + (y2 - y1/ x2 – x1) ---------------- (3)
equation (3) represents a recursive relation for successive values of y along the required
line x1, y1, x2, y2 are the end points of the required line .
when equation (3) is used to rasterise the line then it is called as digital
differential analyzer (DDA).
ALGORITHM
Q 4. Which modifications are necessary to generate dashed line from DDA algorithm.
Q 5. Which modifications are necessary to generate dotted line from DDA algorithm.
Q 7. What is rasterization?
Theory : - This algorithm seeks to select the optimum raster location to represents a
straight line. To achieve this, the algorithm always implemented by one unit in either x or
y directions depending on the slope of the line.
The increment in the other variables either 0 or 1, is determined by examining the
distance between the actual line location and the nearest grid location. This distance is
called the error and only error term is needed to be examined.
0≤ ∆y/ ∆x<1/2(error<0)
If the slope of the line through (0,0) is greater than ½ i.e. m>1/2 then its
intercept with the x=1 which is closer to the line y=1 then y=0 hence pixel(1,1) is
selected. Similarly , if the slope of the line is less than ½ i.e. m<1/2 than its intercept with
the line is x=1 is closer to the line y=0 hence select pixel (1,0).
ALGORITHM
The line end point are (x1, y1) and (x2,y2) assumed not equal
All variables are assumed integer
The sign function returns -1, 0, 1 as its argument is <0, =0, or >0
VIVA VOICE
THEORY : - To draw a circle, only first octant of the circle is required to be generated
and other parts can be obtained by successive reflections. The circle generation is done
by using Bresenham’s algorithm.
If the first octant is generated, the second octant is obtained by reflection through
the line y = x to yield the first quadrant . The results in the first quadrant are reflected
through the line x = 0 to obtain those in second quadrant. The combined results in the
upper semicircle are reflected through the line y = 0 to complete the circle.
ALGORITHM
Initialize the variables
xi = 0
yi = R
∆i = 2(1- R)
Limit = 0
Step 1). Plot(xi , yi)
if yi ≤ Limit then 4
Determine the case 1 or 2, 4 or 5, or 3
if ∆i < 0 then 2
if ∆i > 0 then 3
if ∆i = 0 then 20
Determine whether case 1 or 2
1) δ = 2 ∆i + 2 yi -1
if δ ≤ 0 then 10
if δ > 0 then 20
determine whether case 4 or 5
3) δ’ = 2 ∆i - 2 xi -1
if δ’ ≤ 0 then 20
if δ’ >0 then 30
perform the moves
move mH
10) xi = 2 xi + 1
∆i = ∆i + 2 xi +
go to 1
move mD
20) xi = 2 xi + 1
yi = 2 yi - 1
∆i = ∆i + 2 xi - 2 yi + 2
go to 1
move mv
30) yi = yi – 1
∆i = ∆i - 2 yi + 1
go to 1
finish
VIVA VOICE
1. How to generate the circle in 2nd quadrant from 1st quadrant clockwise ?
2. How to generate the circle in 2nd quadrant from 1st quadrant anticlockwise?
3. How to generate the circle in 3rd quadrant from 1st quadrant clockwise ?
4. How to generate the circle in 3rd quadrant from 1st quadrant anticlockwise?
10. Generate the circle in 1st quadrant having radius 8 and center is origin.
EXPERIMENT NO 4
ALGORITHM:
Theory :- It’s a technique to fill the polygon by two steps.The first step is to outline the
contour.This establishes pairs of span bounding pixels on each scanline.The second step
is to fill between these bounding pixels.
Algorithm :-
1> For contour outline :
Using the half scan line convention for each edge intersecting the polygon, set the
leftmost pixel whose midpoint lies to the right of the intersection, i.e. for x+1/2 >
Xintersection ,to the boundary value.
Viva-voce :-
Qu 1 Can this algo visits each pixel more than once?
ALGORITHM
Step 6) x = x + 1
y=y+1
∆i = ∆i + b2[2(x + 1) + 1] – a2(2(y – 1)- 1)
VIVA VOICE
1>Translation
1 0 0
0 1 0
Tx Ty 1
2>Rotation
Sinθ Cosθ 0
0 0 1
Cosθ -Sinθ 0
Sinθ Cosθ 0
0 0 1
3>Scaling
Sx 0 0
0 Sy 0
0 0 1
1 0 0
0 -1 0
0 0 1
-1 0 0
0 1 0
0 0 1
-1 0 0
0 -1 0
0 0 1
0 1 0
1 0 0
0 0 1
0 -1 0
-1 0 0
0 0 1
Viva-voce
Q10 Write the transformation matrix for reflection about Y=-X axis.
EXPERIMENT NO. 8
AIM : - Write a program to implement seed fill algorithm for polygon filling
THEORY : - Generation of solid areas from the simple edge of the vertex description is
referred as solid scan conversion or polygon filling or contour filling.
There are two techniques used to fill a polygon namely scan conversion and seed
fill technique.
The seed fill algorithm required one of the pixel position inside the polygon or
region to be filled. This pixel is inside the region and set to polygon value. This pixel is
referred as seed pixel. The algorithm continues to search the pixels which are adjacent to
the current seed pixel to see whether they are boundary pixels or the pixels inside the
region. All the pixels interior to the region and are adjacent to the seed pixel are set to the
polygon value.
ALGORITHM : -
Q 5 Which are the two conditions are required before setting the pixel?
Practical List
Sem/branch : V / IT
Lab Manual : 2006 – 2007