Computer Graphics
UNIT 2
1. What is an output primitive?
Graphics programming packages provide function to describe a scene in terms of these basic geometric structures, referred to as output primitives.
2. What do you mean by ‘jaggies’?
Line with stair step appearance is known as jaggies.
3. What is point in the computer graphics system?
The point is a most basic graphical element & is completely defined by a pair of user coordinates (x , y).
4. Write short notes on lines?
A line is of infinite extent can be defined by an angle of slope θ and one point on the line P=P(x,y). This can also be defined as Y=mx+C where C is the Y- intercept.
5. Define Circle?
Circle is defined by its center xc, yc and its radius in user coordinate units. The equation of the circle is
(x-xc)^2 + (y-yc)^2 = r^2.
6. Define Ellipse?
An ellipse can use the same parameters xc, yc ,r as a circle, in addition to the eccentricity e. the eqn of an ellipse is:
[(x-xc)^2]/a^2 + {(y-yc)^2}/b^2= 1
7. Define polygon?
A polygon is any closed continues sequence of line segments ie, a polyline whose last node point is same as that of its first node point. The line segments form the sides of the polygon and their intersecting points form the vertices of the polygon.
8. Distinguish between convex and concave polygons?
If the line joining any two points in the polygon lies completely inside the polygon then, they are known as convex polygons. If the line joining any two points in the polygon lies outside the polygon then, they are known as concave polygons.
9. What is seed fill?
One way to fill a polygon is to start from a given point (seed) known to be inside the polygon and highlight outward from this point i.e neighboring pixels until encounter the boundary pixels, this approach is called seed fill.
10. What is scan line algorithm?
One way to fill the polygon is to apply the inside test. i.e to check whether the pixel is inside the polygon or outside the polygon and then highlight the pixel which lie inside the polygon. This approach is known as scan-line algorithm.
11. Define coherence properties?
A coherence property of a scene is apart of a scene by which relate one part of the scene with the other parts of the scene.
12. What is an active edge list in the scan line algorithm?
The active edge list for a scan line contains all edges crossed by that scan line.
13. What is a winding number?
Winding number method is used to check whether a given point is inside or out side the polygon. In this method give a direction number to all the edges which cross the scan line. If the edge starts below the line and ends above scan line give direction as -1 . otherwise1. Fr polygons or two dimensional objects, the point is said to be inside when the value of winding number is nonzero.
14. What is cell array?
The cell array is a primitive that allows users to display an arbitrary shape defined as a two dimensional grid pattern.
15. What is type face?
Letters, numbers and other characters can be displayed in a variety of sizes and styles. The overall design style for a set of characters is called a type face.
16. What do you mean by font?
The term font referred to a set of cast metal character forms in a particular size and format, such as 10-point courier italic.
17. What is a bitmapped font?
A simple method for representing the character shapes in a particular typeface is
to use rectangular grid patterns. The set of characters are then referred to as a bitmap font.
18. What is an outline font?
A flexible scheme is to describe character shapes using straight-line and curve sections. In this case, the set of character is called an out line font.
19. What is an attribute parameter?
Any parameter that affects the way a primitive is to be displayed is referred to as an attribute parameter.
20. What are the various attributes of a line?
The line type, width and color are the attributes of the line. The line type include solid line, dashed lines, and dotted lines.
21. What is pixel mask?
Pixel mask is a string containing the digits 1 and 0 to indicate which positions to plot along the line path. The mask 1111000, could be used to display a dashed line with a dash length of 4 and inter dot spacing of three.
22. What is a Line cap?
Line caps can be used to adjust the shape of the line ends to give a better appearance. There are three types of line caps. Butt cap which has a square end, round cap which has a semi circle end, projecting square cap which has one half of the line width beyond the specified end points.
23. List out the methods used for smoothly joining two line segments?
Mitter join- by extending the outer boundaries of each of the two lines until they meet.
Round join – by capping the connection between the two segments with a circular boundary whose diameter is equal to the line width.
Bevel join – by displaying the line segments with butt caps and filling in the triangular gap where the segment meet.
24. What is Color Look up table?
In color displays, 24 bits per pixel are commonly used, where 8 bits represent 256 level for each color. It is necessary to read 24- bit for each pixel from frame buffer. This is very time consuming. To avoid this video controller uses look up table to store many entries to pixel values in RGB format. This look up table is commonly known as colour table.
25. What is tiling patterns?
The process of filling an area with rectangular pattern is called tiling and rectangular fill patterns are sometimes referred to as tiling patterns.
26. What is soft fill?
Soft fill is a filling method in which fill color is combined with the background colors.
27. What is kerned character?
The characters which extend beyond the character body limits is known as kerned character. Example f and j.
28. What is character up vector?
The orientation for a displayed character string is set according to the direction of the character up vector.
29. Define bundled attributes?
Individual attribute commands provide a simple and direct method for specifying attributes when a single output device is used. When several kinds of output device are available at a graphics installation, it is convenient to set up a table for each output device that lists set of attribute values that are to be used on that device to display each primitive type. Attribute specified in this manner is known as bundled attribute.
30. What is aliasing?
In the line drawing algorithms, all rasterzed locations do not match with the true line and have to represent a straight line. This problem is severe in low resolution screens. In such screens line appears like a stair-step. This effect is known as aliasing.
31. What is antialiasing?
The process of adjusting intensities of the pixels along the line to minimize the effect of aliasing is called antialiasing.
32. What is pixel phasing?
Pixel phasing is an antialiasing technique, stair steps are smoothed out by moving the electron beam to more nearly approximate positions specified by the object geometry.
16 marks
1. Explain in detail about the DDA scan conversion algorithm?The digital differential analyzer is a scan conversion algorithm based on
calculation either ∆y or ∆x using the following euations
∆y = m ∆x
∆x = ∆y / m
Sample the line at unit intervals in one coordinate and determinecorresponding integer
values nearest the line path for the coordinates
Sample at X intervals (∆x = 1) and compute each successive Y value as
Yk+1 = Yk + m 20
For lines with positive slope greater than 1, reverse the roles of X and Y. Sample at unit
Y intervals (∆y = 1)and calculate each successive X value as
Xk+1 = Xk + 1/m
Algorithm
Step 1: Input the line endpoints and store the left endpoint in (x1, y1) and right
endpoint in (x2, y2)
Step 2: Calculate the values of ∆x and ∆y using ∆x = xb – xa, ∆y = yb – ya
Step 3: if the values of ∆x > ∆y assign values of steps as ∆x otherwise the values
of steps as ∆y
Step 4: Calculate the values of X increment and Y increment and assign
the value x= xa and y = ya
Step 5: for k=1 to steps do
X = X + X increment
Y= Y + Y increment
Putpixel(ceil(x), ceil(y),15)
Step 6: End
2. Explain Bresenhams line drawing algorithm?
In Bresenham’s approach the pixel position along a line path aredetermined by sampling unit X intervals. Starting from the left end point(X0, Y0)of a given line we step to each successive columns and plot the pixel whose scan line Y-value is closest to the line path.Assuming the Kth step in process, determined that the pixel at (Xk, Yk)decide which pixel to plot in column Xk+1.The choices are (Xk+1,Yk) and (Xk+1, Yk+1)
Algorithm
Step 1: Input the line endpoints and store the left endpoint in (X0, Y0)
Step 2: Load (X0, Y0) in to the frame buffer
Step 3: Calculate constants ∆x, ∆y, 2 ∆y, -2 ∆x, and obtain the decision parameters as
P0 = 2 ∆y – ∆x
Step 4 : At each Xk along the line, starting at k = 0, perform the following test
If Pk < 0, the next point to plot is (Xk+1,
Yk) and
Pk+1 = Pk+2 ∆y
Otherwise, the next point to plot is (Xk+1, Yk+1) and
Pk+1 = Pk+2 ∆y - 2 ∆x
Step 5: Repeat step 4 ∆x times
3. Explain Midpoint Circle algorithm?
Algorithm
Step 1:Input radius r and circle center(Xc, Yc)and obtain the first point on 21
the circumference of a circle centered on the origin as
(X0, Y0) = (0, r)
Step 2: Calculate the initial values of the decision parameter as
P0 = 5/4 – r
Step 3: At each position starting at k perform the following test:
If Pk < 0, the next point to plot is (Xk+1,
Yk) and
Pk+1 = Pk+2 Xk+1 + 1
Otherwise the next point is (Xk+1, Yk+1) and
Pk+1 = Pk+2 Xk+1 + 1- 2 Yk-1
Step 4: Determine symmetry points in the other seven octants
Step 5: Move each pixel position(X, Y) onto the circular path centred on
(Xc, Yc) and plot the coordinate values as
X = X + Xc Y = Y + Yc
Step 6: Repeat steps 3 through until X>=Y
Pk + 1= Pk + 2 ∆Y
Other wise, the next point is (Xk+1, Yk+1) and
Pk + 1= Pk + 2 ∆Y - 2 ∆X
Step 5: Repeat steps 4 ∆X times
4. Explain Ellipse generating Algorithm?
Algorithm
Step 1:Input radius rx, ry and ellipse center(Xc
, Yc
)and obtain the first
point on the circumference of a circle centered on the origin as
(X0, Y0) = (0, ry)
Step 2: Calculate the initial values of the decision parameter in region 1 as
P10 = ry^2 - rx^2 ry + 1/4 rx^2
Step 3: At each position starting at Xk position in region 1,starting at k = 0,
perform the following test:
If Pk < 0, the next point to plot is (Xk+1,
Yk) and
P1k+1 = P1k+2 ry
2
Xk+1 + ry
2
Otherwise the next point is (Xk+1, Yk-1) and
P1k+1 = P1k+2 ry
2
Xk+1 - 2ry
2
Yk+1 + ry
2
Step 4: Calculate the initial values of the decision parameter in region 2 as
P20 = ry
2
(X0+1/2)
2
+ rx
2
(Y0 – 1)
2
- rx
2
ry
2
Step 5: At each position starting at Yk position in region 2,starting at k = 0,
perform the following test:
If Pk > 0, the next point to plot is (Xk,
Yk-1) and 22
P2k+1 = P2k - 2 ry
2
Yk+1 + rx
2
Otherwise the next point is (Xk+1, Yk-1) and
P2k+1 = P2k - 2 ry
2
Yk+1 - 2rx
2
Yk+1 + rx
2
Step 6: Determine symmetry points in the other three octants
Step 7: Move each pixel position(X, Y) onto the circular path centred on
(Xc, Yc) and plot the coordinate values as
X = X + Xc Y = Y + Yc
Step 8: Repeat steps for region 1 until 2 ry
2
X>=2 ry
2
Y
5.Explain Boundary fill Algorithm?
♦ If the boundary is specified in a single color, the fill algorithm
proceeds outward pixel-by-pixel until the boundary color is
encountered. This is called boundary fill algorithm
♦ The boundary fill procedure accepts as input the coordinates of an
interior point (x, y), a fill color, and a boundary color.
♦ Starting from (x, y), the procedure tests the neighboring positions to
determine whether they are boundary color.
♦ If not, they are painted with the fill color, and the neighbors are tested.
♦ This process continues until all pixels up to the boundary color for the
area have been tested
♦ Two methods
♦ 4- connected
• 4 neighbouring points are conected
♦ 8-connected
• correctly fill the interior of the area defined
program
void boundaryfill( int x, int y, int fill, int boundary)
{
int current;
current = getpixel (x, y);
if ((current != boundary) &&(current != nil)
{
setColor ( fill);
setPixel ( x, y);
boundaryfill (x+1, y, fill, boundary);
boundaryfill (x-1, y, fill, boundary);
boundaryfill (x, y+1, fill, boundary);
boundaryfill (x, y-1, fill, boundary);
}
}