0% found this document useful (0 votes)
9 views

Computer Graphics Theory

The document covers the basics of computer graphics, including definitions of pixels, resolution, and graphics modes. It discusses various applications of computer graphics, different display devices, and image file formats. Additionally, it explains concepts like virtual and augmented reality, the graphics pipeline, and algorithms for drawing shapes and filling polygons.

Uploaded by

userid13042006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Computer Graphics Theory

The document covers the basics of computer graphics, including definitions of pixels, resolution, and graphics modes. It discusses various applications of computer graphics, different display devices, and image file formats. Additionally, it explains concepts like virtual and augmented reality, the graphics pipeline, and algorithms for drawing shapes and filling polygons.

Uploaded by

userid13042006
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 36

Chapter 1: Basics of Computer Graphics

2 Marks Questions:
1. Define Pixel and Resolution.
Answer: Pixel: Pixel or Pel is defined as "the smallest addressable screen element". OR
A pixel may be defined as the smallest size object or color spot that can be displayed and
addressed on a monitor.
Resolution: This is referring to the size of the pixel. The number of horizontal and vertical
pixels on a display screen is called Resolution. The smaller the pixel, the higher the
resolution.
2. List any four areas of applications of Computer Graphics.
Answer:

- DTP (Desktop Publishing)


- Graphical User Interface (GUI)
- Computer-Aided Design
- Computer-Aided Learning (Cal)
- Animations
- Computer Art
- Entertainment
- Education and training
- Image processing
- Medical Applications
- Simulation and Virtual Reality

3. State any two graphics functions with its syntax.


Answer: Following are some basic graphical functions for drawing geometrical objects.
(1) setcolor(color): It is a function that is used to set the color of the drawing object with
given color. The color is indicated by the integer from 0 to 15 (16 color)
(2) moveto (x, y): it is used to move the cursor in display screen at specified co-ordinates
by the value (x, y).
(3) outtext (" text string "): prints the text string in the current position of screen.
(4) outtextxy (x, y, "string"): prints the string from the co-ordinate (x, y) position.
(5) lineto (x, y): draws the line from current position to (x, y) position.
(6) putpixel (x, y, color): displays a pixel(point) at (x, y) with given color.
(7) line (a, b, c, d): draws line from (a, b) to (c, d).
(8) circle (x, y, r): prints circle with center (x,y) and radius r.
(9) rectangle (a, b, c, d): prints rectangle where (a,b) is upper left coordinate and (c,d) is
lower right co-ordinates of rectangle.
4. What is the Graphics mode and Text mode?
Answer:
In text mode, the screen is internally rendered as text rather than pixels. The screen is divided
into a rectangular grid (cell or termed box), with each cell capable of bolding only one
character.
Text mode with 25 rows and 80 columns of characters is supported by all video standards. Text
mode uses mono-space typefaces, which means that each character is the same width on the
screen. So that the output can be appropriately aligned.

It is a computer display mode that uses pixels to create an image. The screen is internally
represented as a grid of pixels in graphics mode. The smallest addressable entity on the screen
is the pixel.
Pixels are used to represent everything, including characters. More smooth shapes and
typefaces are supported in Graphics mode. In text mode, graphical objects such as a circle, line,
triangle, and so on cannot be displayed.
5. List different Display devices.
Answer: There are some display devices given below:
1. Cathode-Ray Tube(CRT)
2. Color CRT Monitor
3. Liquid crystal display(LCD)
4. Light Emitting Diode(LED)
5. Direct View Storage Tubes(DVST)
6. Plasma Display
7. 3D Display
6. Define aspect ratio. Give one example of an Aspect ratio.
Answer: Aspect ratio: It is the ratio of the number of vertical points to the number of
horizontal points necessary to produce equal length lines in both directions on the screen.
Or
In computer graphics, the relative horizontal and vertical sizes. For example, if a graphic
has an aspect ratio of 2:1, it means that the width is twice as large as the height. Or Aspect
ratio is the ratio between width of an image and the height of an image.
Example: The term is also used to describe the dimensions of a display resolution. For
example, a resolution of 800x600, 1027x768, 1600x1200 has an aspect ratio of 4:3.
Resolution 1280x1024 has an aspect ratio 5:4. Resolution 2160x1440, 2560x1700 has an
aspect ratio 3:2.

7. List different image file formats.


Answer:
(1) JPEG (or JPG) - Joint Photographic Experts Group.
(2) PNG - Portable Network Graphics
(3) GIF - Graphics Interchange Format.
(4) TIFF - Tagged Image File.
(5) PSD - Photoshop Document.
4 Marks Questions:
1. Explain graphics pipeline in detail.
• Vertex Processing: Process and transform individual vertices & normals.
• Rasterization: Convert each primitive (connected vertices) into a set of fragments.
A fragment can be interpreted as a pixel with attributes such as position, color,
normal and texture.
• Fragment Processing: Process individual fragments.
• Output Merging: Combine the fragments of all primitives (in 3D space) into 2D
color-pixel for the display.
2. Differentiate between vector scan display and Raster scan display.
Sr. Vector Scan Raster Scan
No
1. Vector graphics are composed of Raster graphics are composed of
paths. pixels.
2. Vector graphics are resolution Raster graphics are resolution
independent. dependent.
3. Scan conversion is not required. Graphics primitives are specified in
terms of their endpoints and must be
scan converted into their
corresponding points in the frame
buffer.
4. Scan conversion hardware is not It required separate scan conversion
required. hardware.
5. Vector display only draws lines and Raster display has ability to display
characters areas filled with solid colors or
patterns.
6. It does not used interlacing. It uses interlacing.
7. This display has higher resolution. This display has lower resolution.
8. They occupy less space. They occupy more space which
depends on image quality.
9. File extensions are: .pdf, .ai, .svg, File extensions are: .bmp, .gif, .jpg,
.eps, .dxf .tif
3. Explain virtual and Augmented Reality.
Answer:
Virtual reality (VR) means experiencing things through our computers that don't really
exist. OR
Virtual Reality (VR) is the use of computer technology to create a simulated environment.
Instead of viewing a screen in front of them, users are immersed and able to interact with
3D worlds.

Advantages:
• Virtual reality creates a realistic world
• Through Virtual Reality user can experiment with an artificial environment.
• Virtual Reality make the education more easily and comfort.
• It enables user to explore places.
• Virtual Reality has made watching more enjoyable than reading.

Virtual reality widely used in video games, engineering, entertainment, education, design,
films, media, medicine and many more.

Augmented reality merges the physical world with computer-generated virtual elements.
It is accessed using common equipment such as mobile phones.
• There are nearly uncountable possibilities with the Augmented Reality. With the
smartphone's camera, AR adds the digital elements to a live view.
• It uses the smartphone's camera to present the real world's view in front of us and
then put a layer of information that includes the text or images on the top of that
view.
• Some of the examples of Augmented Reality are the Pokemon Go game, Snapchat
lenses.

4. Explain CRT with diagram and its Advantages and disadvantages.


Answer:
Cathode-ray Tube (CRT): Here, CRT stands for Cathode ray tube. It is a technology
which is used in traditional computer monitor and television.
Cathode ray tube is a particular type of vacuum tube that displays images when an electron
beam collides on the radiant surface.
Component of CRT
• Electron Gun: The electron gun is made up of several elements, mainly a heating
filament (heater) and a cathode. The electron gun is a source of electrons focused
on a narrow beam facing the CRT.
• Focusing & Accelerating Anodes: These anodes are used to produce a narrow and
sharply focused beam of electrons.
• Horizontal & Vertical Deflection Plates: These plates are used to guide the path of
the electron the beam. The plates produce an electromagnetic field that bends the
electron beam through the area as it travels.
• Phosphorus-coated Screen: The phosphorus coated screen is used to produce bright
spots when the high-velocity electron beam hits it.
4 Marks Questions:

5. Write a Program in C to draw the following shapes with given points.


i) Line (20,20;60,60)
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
int main()
{
int gd=DETECT, gm;
initgraph (&gd, &gm, “C:\\tc\\bgi\\”);
line(20,20,60,60);
getch();
closegraph();
Return 0;
}
ii) Circle (100,100,25)
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
int main()
{
int gd=DETECT, gm;
initgraph (&gd, &gm, “C:\\tc\\bgi\\”);
circle(100,100,25);
getch()’
closegraph();
}
Return 0;

Chapter 2: Raster Scan Graphics


2 Marks
1. List two polygon filling methods.
Answer:

2. Draw 8-way symmetry of circle.

3. Define convex and concave polygon.

4. Draw 8-connect region of a pixel.


5. List two line drawing algorithms.
(1) Digital Differential Analyzer algorithm generates a line from differential equations of
line and hence the name DDA.
(2) Bresenham’s Algorithm The Bresenham algorithm is another line drawing algorithm
which uses integer calculations for drawing line.
4 Marks
1. Explain following character generation method with example.
i) Stroke method
Answer:

ii) Starbust method


2. Write DDA line drawing algorithm.
Answer:
3. Explain even-odd method of conducting inside-outside test.
Answer: In this technique, we count the edge crossing along the line from any point (x, y)
to infinity. If the number of interactions is odd then the point (x, y) is an interior point. If
the number of interactions is even then point (x, y) is an exterior point. Here is the example
to give you the clear idea,

From the Fig., we can see that from the point (x, y), the number of interactions point on the left
side is 5 and on the right side is 3. So, on both sides of the point, the number of interactions are
odd. Hence, the point is considered within the object.
4 Marks

4. Write algorithm to fill polygon using flood fill.

5. Consider the line from (0,0) to (4,6). Use DDA algorithm to rasterize this line.

Answer:

Step 1: x1 = 0; y1 = 0, x2 = 4 and y2 = 6

𝑦 −𝑦 6−0 6
Step 2 : Slope 𝑚 = 𝑥2−𝑥1 = 4−0 = 4 which is more than 1.
2 1

Step 3: As m = 6/4 is greater than 1 therefore y is increased and x is calculated.

Step 4: Now increase the value of y and calculate value of x.

1
𝑦1 = 𝑦1 + 1, 𝑥1 = 𝑥1 +
𝑚

Step X1 Y1 Pixel plotted

1 0 0 (0,0)

2 4/6 = 0.67 1 (1,1)

3 0.67+4/6=1.34 2 (1,2)

4 1.34+4/6=2.01 3 (2,3)

5 2.01+4/6=2.68 4 (3,4)

6 2.68+4/6=3.35 5 (3,5)

7 3.35+4/6=4.02 6 (4,6)

The algorithm will stop here because x and y values are reached to end point (4,6).

6. Write DDA line drawing algorithm.

Answer: DDA line drawing algorithm can be understood by taking an example.

Let us consider a line joining point A (x1, y1) and B (x2, y2)
𝑦 −𝑦
The slope of this equation is given as 𝑚 = 𝑥2 −𝑥1
2 1

• If slope (m) is less than 1 (i.e. m < 1) then increment x as 𝑥1 = 𝑥1 + 1 and


calculate y as 𝑦1 = 𝑦1 + 𝑚.
• If slope (m) is greater than 1 (m > 1) then increment y as 𝑦1 = 𝑦1 + 1 and
1
calculate 𝑥1 = 𝑥1 +
𝑚

• If slope is equal to 1 (m=1) then increment both x and y. i.e. 𝑥1 = 𝑥1 + 1; 𝑦1 =


𝑦1 + 1
7. Write a Program in C to fill Polygon using Boundary fill algorithm.

#include <graphics.h>
void boundaryFill4(int x, int y, int fill_color,int boundary_color)
{
if(getpixel(x, y) != boundary_color &&
getpixel(x, y) != fill_color)
{
putpixel(x, y, fill_color);
boundaryFill4(x + 1, y, fill_color, boundary_color);
boundaryFill4(x, y + 1, fill_color, boundary_color);
boundaryFill4(x - 1, y, fill_color, boundary_color);
boundaryFill4(x, y - 1, fill_color, boundary_color);
}
}
int main()
{
int gd = DETECT, gm;
initgraph(&gd, &gm, "");
int x = 250, y = 200, radius = 50;
circle(x, y, radius);
boundaryFill4(x, y, 6, 15);
delay(10000);
getch();
closegraph();
return 0;
}
Algorithm DDA

1. Read the line end points (𝑥1, y1) and (𝑥2, y2) such that they are not equal. [If
equal then plot that point and exit]
2. Δ𝑥 = |𝑥2 − 𝑥1| and Δ𝑦 = |𝑦2 − 𝑦1|
3. If (Δ𝑥 ≥ Δ𝑦) 𝑡ℎ𝑒𝑛
Length=Δ𝑥
Else
Length=Δ𝑦
End if
4. Δ𝑥 = (𝑥2 − 𝑥1)/𝑙𝑒𝑛𝑔𝑡ℎ
Δ𝑦 = (𝑦2 − 𝑦1)/𝑙𝑒𝑛𝑔𝑡ℎ
[This makes either Δ𝑥 or Δ𝑦 equal to 1 because length is either 𝑥2 − 𝑥1 or 𝑦2−
𝑦1. Therefore, the incremental value for either x or y is one.]
5. 𝑥 = 𝑥1 + 0.5 sign (Δ𝑥)
𝑌 = 𝑦1 + 0.5 sign (Δ𝑦)
[Here, sign function makes the algorithm work in all quadrants. It
returns -1, 0, 1 depending on whether its argument is <0, =0, >0, respectively.]
6 . i=1
[begins the loop, in this points are plotted]
While ( i ≤ length)
Begin
Plot (integer (x), integer (y))
𝑥 = 𝑥 + Δ𝑥
𝑦 = 𝑦 + Δ𝑦
𝑖=𝑖+1
End.
Stop
Note :
1- Sign function returns : -1 if its argument is < 0
: 0 if its arguments is = 0
: +1 if its arguments is > 0

Ex. Sign(-10) = -1 , Sign (5) = 1

Using the Sign function makes the algorithm work in all quadrants.
Example 2.1: consider the line from (0,0) to (6,6). Use the simple DDA algorithm
to rasterize this line
Solution:

x1=0 , y1=0 , x2=6 , y2=6


Length = 𝑦2− 𝑦1 = 𝑥2 − 𝑥1 =6
Δ𝑥 = (𝑥2 − 𝑥1)/𝑙𝑒𝑛𝑔𝑡ℎ
= 6/6 = 1 and
Δ𝑦 = (𝑦2 − 𝑦1)/𝑙𝑒𝑛𝑔𝑡ℎ
=6/6 = 1
Initial value for
𝑥 = 0 + 0.5 (1) =0.5
𝑌 = 0 + 0.5 (1) = 0.5

i plot x y
0.5 0.5
1 (0,0)
1.5 1.5
2 (1,1)
2.5 2.5
3 (2,2)
3.5 3.5
4 (3,3)
4.5 4.5
5 (4,4)
5.5 5.5
6 (5,5)
6.5 6.5

Example 2.2: consider the line from (23,33) to (29,40) Use the simple DDA
algorithm to rasterize this line
Solution:
x1=23 ,
y1=33 ,
x2=29 ,
y2=40
Δ𝑥 = 𝑥2 − 𝑥1 =6
Length = 𝑦2− 𝑦1=7
Δ𝑥 = (𝑥2 − 𝑥1)/𝑙𝑒𝑛𝑔𝑡ℎ
= 6/7 = 0.85 and
Δ𝑦 = (𝑦2 − 𝑦1)/𝑙𝑒𝑛𝑔𝑡ℎ
=7/7 = 1
Initial value for
𝑥 = 23 + 0.5 (0.8) =23
𝑌 = 33 + 0.5 (1) = 33.5

i x y Plot(x,y)
1. 23.5 33.5 (23,33)
2. 24.3 34.5 (24,34)
3. 25.1 35.5 (25,35)
4. 25.9 36.5 (25, 36)
5. 26.7 37.5 (26, 37)
6. 27.5 38.5 (27, 38)
7. 28.3 39.5 (28, 39)
Example 2.3: consider the line from (0,0) to (4,6). Use the simple DDA

algorithm to rasterize this line

Solution:

x1=0 , y1=0 ,
x2=4, y2=6
Length = y2− y1 =6
Δ𝑥 = (x2 − x1)/ length = 4/6 and
Δy = (y2 − y1)/ length =6/6 = 1

Initial value for


𝑥 = 0+ 0.5 (4.6)=0.5
𝑌 = 0 + 0.5 (1) = 0.5

Advantages of DDA Algorithm


1. It is the simplest algorithm and it does not require special skills for implementation.
2. It is a faster method for calculating pixel positions than the direct use of equation y
= mx + b. It eliminates the multiplication in the equation by making use of raster
characteristics, so that appropriate increments are applied in the x or y direction to
find the pixel positions along the line path.

Disadvantages of DDA Algorithm

1. Floating point arithmetic in DDA algorithm is still time-consuming.


2. The algorithm is orientation dependent. So the end point accuracy is poor.
3. This algorithm assumes the width of line to be zeros.

Bresenham’s Line Algorithm

1. Read the line end points (x1, y1) and (x2 , y2) such that they are not equal.
[If equal, then plot that point and exit]
2. ∆𝑥 =∣ 𝑥2 − 𝑥1 ∣ And ∆𝑦 =∣ 𝑦2 − 𝑦1 ∣
3. [Initialize starting point]
x=x1
y=y1
4. 𝑒 = 2 ∗ ∆𝑦 − ∆𝑥
[Initialize value of decision variable or error to compensate for non zero
intercepts]
5. i=1
[Initialize counter]
6. Plot (x,y)
7. While (e ≥ 0)
{
y=y+1
e = e − 2 ∗ Δx
}
x=x+1
e = e + 2 ∗ Δy
8. i=i+1
9. If (i≤Δx) then go to step 6
10. Stop
Example2.2:- Consider the line from (5, 5) to (13, 9), use the Bresenham's
algorithm to rasterize the line.
Solution: Evaluating steps 1 through 4 in the Bresenham's algorithm we have,
𝚫x = ∣13-5∣=8
𝚫y = l9-5∣=4
x=5 , y=5.
𝑒 = 2 ∗ ∆𝑦 − ∆𝑥 = 2*4-8 =0
Tabulating the results of each iteration in the step 5 through 10
i plot x y e
5 5 0
1 (5,5) 6 6 -16
-8
2 (6,6) 7 6 0
3 (7,6) 8 7 -16
-8
4 (8,7) 9 7 0
5 (9,7) 10 8 -16
-8
6 (10,8) 11 8 0
7 (11,8) 12 9 -16
-8
8 (12,9) 13 9 0
9 (13,9) 14 10 -16
-8

Generalized Bresenham's Algorithm

1. Read the line end points (x1, y1) and (x2, y2) such that they are not equal.
[If equal then plot that point and exit]
2. ∆𝑥 =∣ 𝑥2 − 𝑥1 ∣ and ∆𝑦 =∣ 𝑦2 − 𝑦1 ∣
3. [Initialize starting point]
x=x1
y=y1
4. 𝑆1 = 𝑆𝑖𝑔𝑛(𝑥2 − 𝑥1 )
𝑆2 = 𝑆𝑖𝑔𝑛(𝑦2 − 𝑦1 )
5. If ∆y > ∆x then
Begin
T=∆x : ∆x =∆y : ∆y =T : Interchange=1
End
Else
Interchange =0
End If
6. e = 2 ∗ ∆y − ∆x
[Initialize value of decision variable or error to compensate for non zero
intercepts]
7. i=1
[initialize counter ]
8. Plot (x,y)
9. While (𝐞 ≥ 𝟎)
Begin
If (Interchange=1) Then x=x + s1
Else y= y + s2
End If
e = e − 2 ∗ Δx
End while

10. If (Interchange=1), Then y=y + s2


Else x=x + s1
End If
e = e+ 2 Δy
11. i=i+1
12. if (i≤ Δx) then go to step 8
13. Stop
Example 2.3 : Draw the line from (0,0) to (-8,-4) using General
Bresenham algorithm

Solution : X=0 ; Y=0 ; ΔX=8 ; ΔY=4 ; S1=-1 ; S2=-1

Because ΔX>ΔY then Interchange=0 ; E=0

I Plot E x y

0 0 0
1 (0,0)
-16 0 -1
-8 -1 -1
2 (-1,-1)
0 -2 -1
3 (-2,-1)
-16 -2 -2
-8 -3 -2
4 (-3,-2)
0 -4 -2
5 (-4,-2)
-16 -4 -3
-8 -5
6 (-5,-3)
0 -6 -3
7 (-6,-3)
-16 -6 -4
-8 -7 -4
8 (-7,-4)
0 -8 -4

Eight-Way Symmetry
The first thing we can notice to make our circle drawing algorithm more
efficient is that circles centred at (0, 0 ) have eight-way symmetry . If the point
is (x,y)is on the circle , then we can trivially compute seven other points on
the circle , as shown in figure above. Therfore, we need to compute only 45
segment to detrmine the circle completely .
get point's symmetric complement about these lines by permuting the indices
:
{(x,-y), (-x,y), (-x,-y), (y,x), (y,-x), (-y,x),(-y,-x)}

Eight- way –symmetry circle Algorithm


(xc, yc ) =center of the circle( integer);
r is the radius of the circle (integer);
r=8;
th = 0 : 1/r : pi/4;
x = r * cos(th);
y = r * sin(th) ;
Plot (round(round(xc + x), round(yc + y));
Plot (round(round(xc + x), round(yc − y));
Plot (round(round(xc − x), round(yc + y));
Plot (round(round(xc − x), round(yc − y));
Plot (round(round(xc + y), round(yc + x));
Plot (round(round(xc + y), round(yc − x));
Plot (round(round(xc − y), round(yc + x));
Plot (round(round(xc − y), round(yc − x));
End
Bresenham's Circle Drawing Algorithm

Fig.2.7:Scan conversion with Bresenham’s Algorithim.

Let us assume point P in Fig. 2.7 as a last scan converted pixel. Now we have two options
either to choose pixel A or pixel B. The closer pixel amongst these two can be determined as
follows:
The distances of pixels A and B from the origin are given as

𝐷𝐴 = √𝑋𝑖+1 2 + (𝑌𝑖 )2

𝐷𝐵 = √𝑋𝑖+1 2 + (𝑌𝑖 − 1)2

Now, the distances of pixels A and B from the true circle are given as
𝛿𝐴 = 𝐷𝐴 − 𝑟 𝑎𝑛𝑑 𝛿𝐵 = 𝐷𝐵 − 𝑟

However, to avoid square root term in derivation of decision variable, i.e. to simplify the
computation and to make algorithm more efficient the 𝛿𝐴 𝑎𝑛𝑑 𝛿𝐵 defined as

𝛿𝐴 = 𝐷𝐴 2 − 𝑟 2 𝑎𝑛𝑑
𝛿𝐵 = 𝐷𝐵 2 − 𝑟 2

From Fig.2.7, we can observe that 𝛿𝐴 is always positive and 𝛿𝐵 always negative.
Therefore, we can define decision variable 𝑑𝑖 as

𝑑𝑖 = 𝛿𝐴 + 𝛿𝐵

and we can say that if 𝑑𝑖 < 0 , i.e. 𝛿𝐴 < 𝛿𝐵 then only x is incremented; otherwise x is
incremented in positive direction and y is incremented in negative direction. In other words
we can write,

For 𝑑𝑖 < 0 𝑥𝑖+1 = 𝑥𝑖 + 1


For 𝑑𝑖 ≥ 0 0 𝑥𝑖+1 = 𝑥𝑖 + 1 and 𝑦𝑖+1 = 𝑦𝑖 − 1
CHAPTER 3
Overview of Transformations
1. Give the matrix representation for 2D scaling.

Answer:

2. What is Homogeneous Coordinates? Why is it required?

Answer:
- We have to use 3×3 transformation matrix instead of 2×2 transformation matrix.
- To convert a 2×2 matrix to 3×3 matrix, we have to add an extra dummy coordinate W.
- In this way, we can represent the point by 3 numbers instead of 2 numbers, which is
called Homogenous Coordinate system.
- Homogeneous coordinates are used extensively in computer vision and graphics
because they allow common operations such as translation, rotation, scaling and
perspective projection to be implemented as matrix operations.

3. List types of Reflection.

Answer:
• Reflection about X axis
• Reflection about Y axis
• Reflection about X=Y axis
• Reflection about X = -Y axis
• Reflection about origin
• Reflection about any line y = mx +c
• Reflection about a line parallel to X-axis
• Reflection about a line parallel to Y axis
4. Explain X-shear with Yref Line.

Answer:

5. Give the Transformation Matrix for rotation about arbitrary point.

Answer:
What is Parallel Projection? Explain with Example.

Answer:

- Parallel Projection use to display picture in its true shape and size. When projectors are
perpendicular to view plane then is called orthographic projection.
- The parallel projection is formed by extending parallel lines from each vertex on the
object until they intersect the plane of the screen.
- The point of intersection is the projection of vertex.
- Parallel projections are used by architects and engineers for creating working drawing
of the object, for complete representations require two or more views of an object using
different planes.
1. Isometric Projection: All projectors make equal angles generally angle is of
30°.
2. Dimetric: In these two projectors have equal angles. With respect to two
principle axis.
3. Trimetric: The direction of projection makes unequal angle with their principle
axis.
4. Cavalier: All lines perpendicular to the projection plane are projected with no
change in length.
5. Cabinet: All lines perpendicular to the projection plane are projected to one
half of their length. These give a realistic appearance of object.

6. List types of Projection.

Answer:
7. Prove that two Scaling Transformations Commute. i.e. S1*S2=S2*S1

Answer:

8. List any four properties of Homogeneous System.

Answer:
1) Any 2D point in the homogeneous coordinate system is represented by a triplet (x, y,
b) where x, y and h are not all zero. (0, 0, 0) does not represent any point. Origin is
represented as (0,0,1)
2) In homogeneous coordinate systems, two points are identical, if one point is derived by
multiplying some constant to the second point.
3) If h is not zero, then point (xh, yh, h) in a homogenous coordinate system is represented
as (xh /h, yh/ h) in the Euclidean/Cartesian coordinate system.
4) If h is 0, point represented is at infinity.
CHAPTER 4
Windowing & Clipping

1. Define Window and Viewport.

Answer:

Window: The window is a 2D or 3D region in world coordinates that defines what


part of a scene should be visible in the final image.

Viewport: The viewport is the rectangular region on the display screen where the
contents of the window are actually displayed, mapped from the window
coordinates to screen coordinates, usually through a transformation process.

2. List four text clipping techniques.

a) Bounding Box Clipping


b) Path Clipping
c) Alpha Clipping
d) Textured Clipping
3. Explain polygon clipping.
- Polygon clipping is a process in computer graphics that involves determining
and rendering the visible portions of a polygon, such as a triangle, quadrilateral,
or any more complex shape, while discarding or clipping away the parts that fall
outside a defined clipping region, such as a rectangular window or a custom-
defined shape.
- The goal of polygon clipping is to efficiently render only the portions of the
polygon that are visible within the specified boundary.
4. List the steps involved in viewing transformations.

Answer:

The steps involved in viewing transformation:-


1. Construct the scene in world co-ordinate using the output primitives and
attributes.
2. Obtain a particular orientation for the window by setting a two-dimensional
viewing co-ordinate system in the world co-ordinate plane and define a
window in the viewing co-ordinate system.
3. Use viewing co-ordinates reference frame to provide a method for setting
up arbitrary orientations for rectangular windows.
4. Once the viewing reference frame is established, transform descriptions in
world co-ordinates to viewing co-ordinates.
5. Define a view port in normalized co-ordinates and map the viewing co-
ordinates description of the scene to normalized co-ordinates.
6. Clip all the parts of the picture which lie outside the viewport.

5. What are outcodes?

Answer:
o Outcodes, also known as "outcode bits" or "clip codes," are a set of binary
values used in computer graphics to perform efficient line and polygon clipping
against a rectangular window or viewport.
o Each outcode corresponds to a specific region of the screen or window, and they
help determine if a line or polygon lies completely outside, partially inside, or
completely inside the defined clipping region.
o In the context of the Cohen-Sutherland line clipping algorithm, a common use
of outcodes, there are four outcode bits:

Top: This bit is set (1) if a point is above the clipping region's top boundary.
Bottom: This bit is set (1) if a point is below the clipping region's bottom
boundary.
Left: This bit is set (1) if a point is to the left of the clipping region's left
boundary.
Right: This bit is set (1) if a point is to the right of the clipping region's right
boundary
CHAPTER 5
Introduction to Curves

2 Marks Questions
1) List any four types of Curves.

Answer:
a) Bezier Curve
b) B-Spline Curve
c) Hilbert’s curve
d) Koch Curve
2) State the concept of Interpolation.

Answer:
- Depending upon the blending functions and boundary conditions, a curve generated
from a given set of control points may or may not interpolate the control points.
- If the curve passes through the control points. It is called interpolation. Interpolation
curves are used in animation and specifying camera motion. It is also used in digitizing
the coordinates.
3) Define spline curves.

Answer:

- Splines are used in graphics to represent smooth curves and. surfaces.


- They use a small set of control points (knots) and a function that generates a curve
through those points.
- A spline curve is a mathematical representation for which it is easy to build an interface
that will allow a user to design and control the shape of complex.
4) State the applications of Bezier splines.
o Computer graphics
o Computer animation
o Engineering design
o CAD packages
o Modelling
o Photoshop software
o Designing automobile parts
4 Marks Questions
1) Explain Hilbert’s curve with diagram.

Answer:
- It was introduced by the German mathematician David Hilbert.
- This curve is also known as the Hilbert space- filling curve.
- The basic entity of this curve is U-shape as shown below.

- Generation of Hilbert curve is quite simple.


- It visits the center of every square grid having size 2 x 2, 4 x 4, 8x8, 16 x 16, or any
other size of 2n x2n.
- The curve generation starts with a square. In a first approximation, the square is divided
into 4 quadrants and the curve joins the centre of all quadrants by a straight line.
- In the second approximation, each quadrant is further subdivided into 2 x 2 grids,
ending in 16 squares. Curve visits the centre of each small square in each quadrant
before moving to the next quadrant.
- In third approximation, each of the 16 squares is further subdivided in 2 x 2 grids,
ending in 64 squares. Curve visits the center of each small square before moving to
higher level quadrant.

On applying this process continuously,


a) The curve never crosses itself
b) Curve gets closer to a square containing it
c) With each subdivision, the length of the curve increases four times.
- There is no limit on length and hence there is no limit on curve length.
- At each subdivision, the scale of the square is reduced by factor 2, and length changed
by factor 4.
2) Explain Arc generation technique using DDA algorithm.
3) Write a program in C to generate Hilbert’s curve.

4) Explain the procedure to generate Bezier curve.

Answer:
- Bezier curve is discovered by the French engineer Pierre Bezier.
- These curves can be generated under the control of other points.
- Approximate tangents by using control points are used to generate curve .
- To generate a cubic Bézier curve, you need four control points: P0, P1, P2, and P3.
- P0 and P3 are the start and end points of the curve, while P1 and P2 are the control points
that influence the shape of the curve.
- Here's the procedure to generate a cubic Bézier curve:
a) Define the control points:

P0: The starting point of the curve.


P1: The first control point that influences the direction of the curve as it starts.
P2: The second control point that influences the direction of the curve as it ends.
P3: The ending point of the curve.
b) The equation for the cubic Bézier curve is given by the following parametric equations
for x and y (t is a parameter that varies from 0 to 1):

Bx(t) = (1 - t)3 P0x + 3 (1 - t)2 t P1x + 3 (1 - t) t2 P2x + t3 P3x


By(t) = (1 - t)3 P0y + 3 (1 - t)2 t P1y + 3 (1 - t) t2 P2y + t3 P3y
Where:
Bx(t) and By(t) are the x and y coordinates of the curve at parameter t.
P0x, P0y, P1x, P1y, P2x, P2y, P3x, and P3y are the x and y coordinates of the control points.
c) To generate points along the curve, you can increment t from 0 to 1 at regular intervals
(e.g., in small steps), and calculate the corresponding Bx(t) and B y(t) for each value of
t. These (Bx(t), By(t)) pairs will give you the points on the Bézier curve.
d) Plot or connect these points to visualize the Bezier curve.

You might also like