0% found this document useful (0 votes)
19 views29 pages

Scan 2set

A polygon is a closed figure defined by three or more non-collinear vertices, classified into convex and concave types based on their interior angles. Techniques such as super sampling and scan-line algorithms are used to reduce jagged effects and fill polygons, while methods like the odd-even rule help determine if a point lies inside a polygon. Additionally, concepts like antialiasing, bitmap and outline fonts, and ambient and diffuse reflection are discussed in the context of computer graphics.

Uploaded by

Nushrat Imrose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views29 pages

Scan 2set

A polygon is a closed figure defined by three or more non-collinear vertices, classified into convex and concave types based on their interior angles. Techniques such as super sampling and scan-line algorithms are used to reduce jagged effects and fill polygons, while methods like the odd-even rule help determine if a point lies inside a polygon. Additionally, concepts like antialiasing, bitmap and outline fonts, and ambient and diffuse reflection are discussed in the context of computer graphics.

Uploaded by

Nushrat Imrose
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

Polygon

1. What is polygon? classify it.


Ans: A polygon is a closed polyline in which the initial and terminal points
coincide. It is a surface defined by three or more non-collinear vertices and is
represented as a number of line segments connected end to end to form a closed
figure.
Polygons are divided into two classes:
1. Convex Polygons:
• All interior angles are less than 180 degrees.
• Any line that connects two points in the polygon remains inside the polygon
boundary.

2. Concave Polygons:
• Interior angles can be greater than 180 degrees.
• Lines connecting two points in the polygon may have parts that remain
outside the polygon boundary.
2. Classify polygon with diagram.
Ans: A polygon is a closed polyline in which the initial and terminal points
coincide. It is a surface defined by three or more non-collinear vertices and is
represented as a number of line segments connected end to end to form a closed
figure.
Polygons are divided into two classes:
1. Convex Polygons:
• All interior angles are less than 180 degrees.
• Any line that connects two points in the polygon remains inside the polygon
boundary.

2. Concave Polygons:
• Interior angles can be greater than 180 degrees.
• Lines connecting two points in the polygon may have parts that remain
outside the polygon boundary.

3. How can you reduce jagged effect by super sampling?


Ans: Reducing jagged effects (aliasing) through super sampling:
1. Assign intensities to pixels dependent on the percentage of the ideal line that
crosses the pixel.
2. Supersampling can be thought of as area averaging or linear filtering of sub-
sampled pixels.
3. For lines with positive slope greater than 1, reverse the roles of x and y.
4. Sample at unit y intervals (Δy = 1) and calculate each succeeding x value.
5. For lines with slope less than or equal to 1, sample at unit x intervals (Δx =
1) and compute each successive y value.
6. Use pixel-weighting masks to determine intensity contributions from
neighboring pixels.
7. Apply area sampling techniques for straight line segments to calculate pixel
coverage.
8. Compensate for line intensity differences between pixels.
9. Use filtering techniques to smooth transitions between pixels.
10.Apply pixel phasing to optimize the placement of line segments on the pixel
grid.

4. How can you find a point inside a polygon or not?

or, How to determine if a point is inside a polygon or


not? Explain.
Ans: To determine whether a point is inside a polygon or not, we normally use
either the odd-even rule or the nonzero winding number rule.
Odd-Even Rule Method
1. Consider a point P(x,y) that needs to be tested for inside/outside status.
2. Draw a horizontal line (ray) from point P to a distant point outside the
polygon's coordinate extents.
3. Count the number of intersections between this ray and the polygon edges:
• If number of intersections is odd, point P is inside the polygon
• If number of intersections is even (including 0), point P is outside the
polygon.
4. For accurate edge counting, ensure the test line does not intersect any
polygon vertices.

Nonzero Winding Number Rule


1. Initialize winding number to 0.
2. Draw a line from point P to a distant point beyond polygon boundaries.
3. Count edges crossing the line:
• Add 1 when an edge crosses from bottom to top
• Subtract 1 when an edge crosses from top to bottom.
4. If final winding number is nonzero, point is inside; if zero, point is outside.

In the above figure, we sum up the direction values from which the scan line is
passing then the total is 1 – 1 + 1 = 1; which is non-zero. So the point is said to be
an interior point.
5. What is jagged effect?
Ans: The "jagged effect" refers to the visual distortion that occurs when a computer
graphics system displays a primitive, such as a line or a curve, that appears as a
series of stair-stepped segments instead of a smooth line. This effect, commonly
known as aliasing, results from the under-sampling of the digital representation of
the graphics data, where coordinate points on an object are rounded to the nearest
integer pixel positions.
It occurs due to two main factors:
1. The finite addressability (discrete pixels) of the display device when
converting continuous lines/curves to discrete pixels.
2. Under-sampling during the conversion of geometric shapes into pixel
patterns on the screen.

6. Write the reasons to avoid geometric equations for


generate objects for computer.
Ans: Reasons to avoid geometric equations for generating computer graphics
objects:
1. Geometric equations require complex mathematical operations that are
computationally expensive compared to simpler representations.
2. Pure geometric functions are difficult to process when dealing with
discontinuities and irregular shapes that are common in graphics.
3. Using complicated monolithic functions is less efficient than using many
simpler pieces to represent objects.
4. Geometric equations have difficulty handling intersections and membership
testing which are crucial for graphics operations.
5. Traditional geometric representations lack adequate means for expressing
arbitrary discontinuities needed in computer graphics.
6. Analysis of geometric equations becomes more complex when dealing with
surfaces that have sharp edges or corners.
7. Converting geometric equations into discrete pixel/screen coordinates
requires additional computational overhead.

7. Describe scan line polygon filling technique.


Ans: The Scan-Line Polygon Fill Algorithm is used to fill closed polygons by
dividing the polygon into horizontal lines (scan lines) and determining the
intersections between these lines and the polygon edges. Figure 3-20 illustrates the
scan-line procedure for solid filling of polygon areas. For each scan line crossing a
polygon, the area-fill algorithm locates the intersection points of the scan line with
the polygon edges. These intersection points are then sorted from left to right, and
the corresponding frame-buffer positions between each intersection pair are set to
the specified fill color. In the example of Fig. 3-20, the four pixel intersection
positions with the polygon boundaries define two stretches of interior pixels from
𝑥 = 10 to 𝑥 = 14 and from 𝑥 = 18 to 𝑥 = 24.

Some scan-Line intersections at polygon vertices require special handling:


1. If both lines intersecting at the vertex are on the same side of the scanline,
consider it as two points.
2. If lines intersecting at the vertex are at opposite sides of the scanline, consider it
as only one point.
8. Describe the flood fill and boundary fill algorithm to
fill a polygon.
Ans:
Flood Fill Algorithm
1. Sometimes we want to fill in (or recolor) an area that is not defined within a
single color boundary but bordered by several different color regions.
2. Process:
• Start from a specified interior point (x,y) called seed
• Reassign all pixel values that are currently set to a given interior color
with the desired fill color
3. If the area we want to paint has more than one interior color:
• First reassign pixel values so that all interior points have the same
color
• Using either a 4-connected or 8-connected approach, step through
pixel positions until all interior points have been repainted.
Boundary Fill Algorithm
1. Starting from an interior point (x,y), the procedure tests neighboring
positions to determine whether they are of the boundary color.
2. If not boundary color:
• Paint them with the fill color
• Test their neighbors
3. This process continues until all pixels up to the boundary color for the area
have been tested.
4. Both inner and outer boundaries can be set up to specify an area.
The algorithm can be implemented using either:
• 4-connected approach (testing pixels at left, right, top and bottom)
• 8-connected approach (testing all 8 adjacent pixels)
9. Describe boundary fill procedure to fill a polygon.
Ans: The Boundary Fill procedure works as follows:
1. Starting from an interior point (x,y), the procedure tests neighboring
positions to determine whether they are of the boundary color.
2. If the tested positions are not boundary color:
• Paint them with the fill color
• Test their neighbors
3. This process continues until all pixels up to the boundary color for the area
have been tested.
4. Both inner and outer boundaries can be set up to specify an area to be filled.
The algorithm can be implemented using either:
• 4-connected approach (testing pixels at left, right, top and bottom)
• 8-connected approach (testing all 8 adjacent pixels)

10. Explain half-toning process.


Ans: Half-toning is a technique used to simulate gray levels by creating patterns of
black dots of varying size.
The half-toning process:
1. The process involves generating a binary pattern of black and white dots
from an image to create apparent intensity values.
2. Many displays and hand copy devices are bilevel - they can only produce
two intensity levels.
3. In such displays or devices, we can create an apparent increase in the
number of available intensity values by viewing a very small area from a
sufficient large viewing distance.
4. Our eyes average fine details within the small area and record only the
overall intensity of the area.
5. The phenomenon of apparent increase in the number of available intensity
by considering combined intensity of multiple pixels is known as half-
toning.

11. What do you mean by antialiasing?


Ans:
Antialiasing is a technique used in computer graphics to reduce the aliasing
(jagged) effect.
1. Antialiasing is a technique used to remove the aliasing effect that occurs
when rasterized images have jagged edges, sometimes called "jaggies".
2. The jagged effect technically occurs due to distortion of the image when
scan conversion is done with sampling at a low frequency, which is also
known as under-sampling.
3. Under-sampling is an important factor in anti-aliasing. It results in a loss of
information about the picture. To avoid this loss, we need to have our
sampling frequency at least twice that of the highest frequency occurring in
the object.

12. Describe bitmap font and outline font.


Ans: Bitmap Font:
• Bitmap fonts represent characters as a set of pixels in a rectangular grid.
Each character in the typeface is stored as a bitmap, specifying which pixels
are to be displayed, allowing for straightforward rendering by copying these
bitmaps directly into the frame buffer.
• The main advantage is simplicity in design and rendering. However, bitmap
fonts require more storage space since each variation (like different sizes and
styles) must be individually stored, leading to potentially large font files.
Outline Font:
• Outline fonts use mathematical descriptions to define the character shapes,
specifically through lines and curves that outline each character. This
approach allows characters to be scaled and transformed without losing
quality.
• Outline fonts are more flexible and efficient in terms of storage because they
do not require a separate font cache for each size and style. The character's
shape can be dynamically rendered at any size or style directly from the
mathematical descriptions, facilitating higher quality output especially at
larger scales.

13. Describe Character Generation Technique for


computer.
Ans: The Character Generation Technique in computer graphics involves two
primary methods for creating characters displayed in various styles and fonts:
1. Bitmap Method
• Description: This method uses a rectangular grid to define character shapes,
where each cell in the grid is either turned on (1) or off (0) to create a bitmap
image of the character. This set of characters is known as a bitmap font.
• Implementation: The bitmap of each character is stored and then copied to
a display area in the frame buffer, determining which pixels are displayed on
the monitor. The size of the array determines the font size of the character.
• Limitations: While simple to implement and render, bitmap fonts require
significant storage as each font size and style variation (like bold or italic)
must be stored separately. This method can also lead to less crisp characters,
especially when scaled or viewed at larger sizes.
2.Stroke Method
• Description: Also known as the vector or outline method, this technique
utilizes lines and curves to outline each character.
• Implementation: The outlines of characters are defined using lines and
Bezier curves, allowing for scalable and rotatable text that retains high
quality at various sizes. The outlines are filled using scan-line or other
polygon filling techniques to render the characters on the display.
• Advantages: This method is more storage-efficient as it does not require
separate entries for each font size and style. It also allows for higher-quality
rendering at various sizes and transformations.

Figure 3-23: Character outline method illustrated with lines and curves.
14. How do you generate image from scene?
Ans: To generate an image from a scene, two main steps are involved:
1. The scene description is converted into a set of geometric primitives with
associated attributes like color, texture, and lighting information.
2. The geometric primitives are then converted into pixel values through scan
conversion and rendering processes that determine the color and intensity of
each pixel in the final image.
The process involves transforming 3D scene descriptions into 2D pixel
representations that can be displayed on output devices like monitors, considering
factors like viewing position, lighting, and surface properties.

15. List and explain the goal of computer graphics.


Ans:
1. Work in a convenient coordinate system: Use transformations to get from
where we want to be to where we need to be. Hierarchical modeling allows
building complex objects from simpler pieces.
2. Use homogeneous coordinates and transformations: This facilitates easier
computation and representation of graphics.
3. Make common operations easy: Operations like translation and projection
should become simple matrix multiplications.
4. Demonstrate the transformation of information: Transform design
solutions into creative outputs using industry-standard software and
hardware.
5. Demonstrate graphic design theory: Include principles of design, elements
of composition, and typography to create aesthetically pleasing artifacts.
6. Organize computations for hardware: Utilize programmable shading and
optimize for speed in rendering.
7. Determine apparent color of objects: Use local lighting models for
efficiency, incorporating tricks for handling non-local effects.
8. Use high-quality rendering techniques: Focus on creating visually
sophisticated appearances.

16. Difference between electrostatic and


electromagnetic deflection system. Which is superior
for computer graphics application and why?
Ans: Difference between electrostatic and electromagnetic deflection system:
Electrostatic Deflection Electromagnetic Deflection

Uses charged parallel plates to create electric


fields Uses magnetic fields generated by deflection coils

Vertical and horizontal plates control x-y


movement Magnetic yoke coils mounted around CRT neck

Requires high voltage (up to 2kV) for


deflection Controls beam through varying current in coils

Limited deflection angles Allows higher deflection angles

Higher electron beam current resulting in brighter


Lower electron beam current images

Better suited for smaller displays Better suited for larger screen displays

Simpler construction More complex construction with external coils

Superiority for Computer Graphics


Electromagnetic deflection is superior for computer graphics applications because:
• Allows for higher deflection angles enabling shallower CRTs
• Provides higher electron beam current resulting in brighter images
• Better suited for larger screen displays commonly used in computer
monitors

17. Define ambient and diffuse reflection.


Ans:
Ambient Reflection: Ambient reflection refers to a form of light reflection that
assumes even illumination of all surfaces within a scene, regardless of their
orientation to light sources. It is modeled as uniform background light that has no
spatial or directional characteristics. This type of reflection does not change with
the direction of light or the observer’s perspective, ensuring that surfaces not
directly exposed to light sources are still visible due to the light reflected from
nearby objects.
Diffuse Reflection: Diffuse reflection describes the way light is scattered in many
directions from rough surfaces. This reflection is constant over each surface within
a scene and does not depend on the viewing direction. It is described by the diffuse
reflection coefficient, which determines the fractional amount of incident light that
is diffusely reflected by the surface. This ensures that the colors and brightness of
surfaces appear the same regardless of the viewer's angle of observation.
Part-2
1. Discuss DDA line drawing algorithm.
Ans: The Digital Differential Analyzer (DDA) algorithm is a method used for
rasterizing lines between two points in computer graphics. It is based on the idea of
calculating either Δx or Δy, depending on the slope of the line, and iterating
through these steps to plot the whole line.
DDA performs calculations incrementally, meaning it uses the results of previous
steps to calculate the next point, which ensures efficiency and simplicity.
If the slope m of the line is less than or equal to 1, the line is sampled at unit x
intervals (Δx = 1). For each x, the corresponding y value is computed and rounded
to the nearest integer to determine the pixel to illuminate.
For a line with a slope greater than 1, the roles of x and y are reversed. The line
is then sampled at unit y intervals (Δy = 1), and x values are calculated and
rounded.
The DDA algorithm is relatively more precise than simple incremental error
methods since it calculates coordinates to fractional precision, then rounds them to
nearest whole numbers.
Algorithm:
2. Discuss Bresenham's line drawing algorithm with
necessary diagram.
Ans: Bresenham’s line algorithm is a highly efficient incremental method for
rendering lines on raster graphics devices using only integer arithmetic operations.
It offers an advantage over other line drawing algorithms like DDA by avoiding
floating-point calculations, making it ideal for use in low-capability devices such
as embedded systems.
For lines with |m| < 1, starting from the left endpoint (x0, y0), we step to each
successive column (x position) and plot the pixel whose scan-line y value is closest
to the line path.
For a line with positive slope greater than 1, we interchange the roles of the 𝑥 and
𝑦 directions. That is, we step along the 𝑦 direction in unit steps and calculate
successive 𝑥 values nearest the line path.
3. Find the decision parameter of line drawing using
Bresenham's algorithm.
Ans: We first consider the scan conversion process for lines with positive slope less
than 1. Pixel positions along a line path are then determined by sampling at unit x
intervals. starting from the left end point (x0, y0) of a given line. Let we have
determined the pixel at (xk, yk) to be displayed. We next need to decide which pixel
to plot in column xk+1. Our choices are the pixels are at positions (xk+1, yk) and
(xk+1, yk+1).

They coordinate on the mathematical line at pixel column position xk+1 is


calculated as:-
y = m (xk+1) +b ……………….(1)
d1 = y - yk
∴ d1 = m (xk+1) +b - yk ……………..(2)
d2 = yk+1 - y
= (yk+1) - m (xk+1) – b …………..(3)
The two difference between these two separation
d1-d2 = m (xk+1) +b -yk - { (yk +1) - m (xk+1) -b}
= m (xk+1) +b -yk - (yk +1) + m (xk+1) +b
= 2m (xk+1) + b - yk -yk -1 +b
= 2 m (xk+1) + 2b - 2yk -1
= 2 Δy/Δx (xk+1) - 2yk + 2b -1
=> Δx (d1-d2) = 2 Δy (xk+1) - 2yk + 2b -1
= 2 Δy xk+ 2 Δy - (2 yk + 2b + 1) Δx
= 2 Δy xk + 2 Δy - 2 yk Δx + (2b -1) Δx
=> Δx (d1-d2) = 2Δy xk - 2yk Δx + c
=> Pk = 2Δy xk - 2yk Δx + c …………………(4)
Where Pk = Δx (d1-d2) is the decision parameter for kth step in the line algorithm
and c is constant and c = 2Δy + Δx (2b-1) ………..(4’)
If d1<d2 then Pk is negative, we plot the lower pixel at (xk+1, yk) and if d1 ≥ d2
then Pk is positive, we plot the upper pixel at (xk+1, yk+1)
For next decision parameter Pk+1
xk+1 = xk +1
∴ Pk+1 = 2 Δy xk+1 - 2Δx yk+1 + c
Pk+1 -Pk = 2 Δy xk+1 - 2Δx yk+1 + c - 2Δy xk + 2 Δx yk -c
= 2 Δy (xk+1 - xk) - 2 Δx (yk+1 - yk)
For m < 1 xk+1 = xk +1
=> xk+1 - xk = 1
Pk+1 = Pk + 2Δy - 2Δx (Yk+1 - Yk)
The term (Yk+1 - Yk) is either 0 or 1 depending on the sign of Pk
If Pk < 0 then Yk+1 = Yk
∴ Pk+1 = Pk + 2Δy
and if Pk ≥ 0 then Yk+1 = Yk+1
∴ Pk+1 = Pk + 2Δy - 2Δx
First decision parameter P0 from equation no (4) as considering the line start
from (0,0) as
P0 = 2Δy.0 - 2Δx.0 + c
=c
= 2Δy + Δx (2b-1) [From 4']
but y = mx+b or b=0
∴ P0 = 2Δy – Δx

4. Find out the decision parameters of Bresenham's


line drawing algorithm for |𝑚|<1
Ans:

5. Find out the decision parameters of Bresenham's


line drawing algorithm for |𝑚|=>1
Ans:
6. Write the midpoint circle generation algorithm.
Ans:

7. Find the decision parameter of Midpoint circle


drawing algorithm.

or, Find the decision parameter for circle drawing


using Midpoint algorithm.
Ans:
To apply midpoint method, we define a circle function
fcircle(x, y) = x2 +y2 -r2 (a)
Any point on the boundary with radius r satisfies the equation. Position of any
point can be determined by checking the sign of the circle function.

Assume that we have just plotted point (xk, yk). The next point is a choice between
(xk+1, yk) and (xk+1, yk-1). We would like to choose the point that is nearest to the
actual circle. By evaluating function at the above equation the midpoint between
the candidate pixels.

Our decision variable can be defined as


Pk = fcircle (xk+1, yk - 1/2)
= (xk+1)² + (yk - 1/2)² - r² .......(1)
If Pk < 0 midpoint is inside the circle and the pixel at yk is closer to the
circle. Otherwise midpoint is outside and yk-1 is closer.
The next decision parameter Pk+1 is evaluated sampling position xk+2 = xk+1 +1
Pk+1 = fcircle (xk+1 +1, yk+1 - 1/2)
= [(xk+1)+1]² + (yk+1 - 1/2)² - r²
Pk+1 = (xk+1)² +2xk+1 +1 + (yk+1)² - (yk+1) +(1/2)2 - r²
= (xk+1)² + (yk - 1/2)² - r² + 2xk+1 + 1 + (yk+1)² - (yk+1) + (1/2)² - (yk - 1/2)²
∴ Pk+1 = Pk + 2xk+1 + 1 + (yk+1)² - (yk+1) + (1/2)2 - (yk - 1/2)² - .......(2)
Where yk+1 is either yk or yk-1 depending on the sign of Pk.
If Pk < 0 then yk+1 = yk, the next decision variable is given as
Pk+1 = Pk + 2xk+1 + (yk)² + (1/2)² + 1 - (yk - 1/2)² – (yk)
= Pk + 2xk+1 +1 + (yk - 1/2)² - (yk - 1/2)²
∴pk+1= Pk + 2xk+1 + 1 f(a)

8. . Write the midpoint ellipse generation


algorithm.
Ans:
9. Find the decision parameter of Midpoint ellipse
drawing algorithm
Ans:
10. Write the steps that required for generation
a circle using Bresenham's circle drawing
algorithm.
Ans:
11. Find the decision parameters for circle
drawing using Bresenham's algorithm.

or, Find the decision parameter of Bresenham's


circle drawing algorithim.
Ans: Bresenham's circle drawing algorithm efficiently determines pixel positions
to approximate a circle centered at (xc,yc) with radius r. The decision parameter
helps decide whether to move in the x-direction or diagonally (x and y directions).

You might also like