Sei sulla pagina 1di 58

# Prepared By:: Prof.

## Computer Graphics Suggestion Question [University Examination]

Chapter 1: Introduction, CRT, Color
1. Define the following terms:- i) resolution ii) aspect ratio iii) refresh rate iv) Bit map and pix map v)
frame buffer vi) interlacing, vii) bit-plane viii) triad.

2. Short note on Cathode Ray Tube./or, describe the functionality of a CRT system with the help of a
diagram.

3. Consider the two different raster system with resolutions of 800x600 and 2560x2048. What size of
frame buffers is needed for each of these systems to store 24 bits per pixel? How much storage is required
for each system if 16 bits per pixel are to be stored?

4. Consider the three different master systems with resolution of 640x480, 1280x1024 and 2560x2048.
What is the size of the frame buffers is needed for each of these systems to store 12-bits per pixel? How
much storage is required for each systems if 24-bits per pixel are to be stored?

## Chapter 2: Line and Circle Drawing

1. Draw a line using DDA having coordinates as (-1,-4) and (5,6).

2. Briefly explain or write the Bresenham’s line drawing algorithm. How does it removes the drawback of
DDA algorithm?

3. Draw a straight line segment in between (0,0) and (5,4) using Bresenham’s algorithm. Find the
intermediate points.

4. Using mid point circle algorithm, find out the screen coordinates of the circumference of a circle whose
centre is (0,0) and radius is 10 units.

5. Write mid point circle drawing algorithm and generate coordinates for a circle of radius 12 cm with
center located at (0,0).
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## 7. Compare and contrast DDA and Bresenham’s line drawing algorithm.

8. Calculate the points using DDA algorithm that would be plotted for a line whose endpoints are A(6,5)
and B(10,10).

## 9. Write a short note on parametric method of circle drawing.

10. Find the points required to plot to draw the circle with center at (100,90) and radius 10 using
Bresenham’s circle drawing algorithm.

## Chapter 3: Filling and aliasing

1. Write a function called flood fill for filling closed area.
2. Write down a function for boundary fill.
3. What is aliasing? What is the solution to it?

Chapter 4: 2D Transformation
1. Reflect the triangle whose vertices are A(3,1), B(1,3) and C(3,3) about the line y=x+4.

## 2. Prove that the inverse of the rotation matrix is its transpose.

3. Short Note on Homogeneous coordinate system/ What do you understand by homogeneous coordinate
and why it is used?

## iii) about the point P(-1,-1).

5. Derive the transformation matrices for 2D reflection about X-axis and Y-axis.

6. Find the transformation matrix for the reflection about the line y=mx+c.

## 7. Write a short note on transformation between coordinate system.

8. Derive composite transformation matrices for i) two successive rotations, ii) two successive scaling, iii)
general pivot point rotation.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

9. A mirror is placed in such a way that its x-intercept is 10 units and its y-intercept is 5 units from the
origin. Find the reflection of the vertices of the square whose coordinates are A(0,0), B(5,0), C(5,5) and
D(0,5) in the mirror.

10. Find the coordinates of the point X(3,3) after it is rotated twice, first about a point A(1,2) by 45 0
anticlockwise and then about a point B(2,1) by 450 anticlockwise direction.

11. Write the general form of a scaling with respect to a fixed point P(h,k).

12. Find the transformation matrix for reflection of the point P(x,y) about the line y=x.

13. Magnify the triangle with vertices A(0,0), B(1,1), C(5,2) to twice its size while keeping C(5,2) fixed.

Chapter 5: Clipping
1. Discuss briefly or write about Cohen-Sutherland line clipping algorithm with suitable example. (A
short discussion about the binary region codes assigned to line endpoints must precede the algorithm).

2. A clipping window ABCD is specified as A(0,0), B(40,0), C(40,40) and D(0,40). Using mid point
subdivision algorithm find the visible portion if any, of the line segment joining the points P(-10,20) and
Q(50,10).

3. Find the normalization transformation for windows to viewport which uses the rectangle whose lower
left corner (2,2) and upper right corner (6,10) as a window and the viewport that has lower left corner at
(0,0) and upper right corner at (1,1).

## 5. A clipping window ABCD is located as following: A(100,10), B(160,10), C(160,40), D(100,40).

Using Cohen-Sutherland clipping algorithm find the visible portion of the line segment P1-P2 where
P1(120,5) and P2(180, 30).

## 7. Define condition about a point clipping.

Chapter 6: Projection
1. Short note on Orthographic and oblique projection.

2. What is projection? How many projections are there? Differentiate between oblique and orthographic
projection.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Chapter 7: Hidden surface removal

1. Write down the Z-buffer algorithm or a short note on z-buffer algorithm.

## 2. Write a short note on hidden surface removal.

Chapter 8: Curves
1. Write the condition for smooth joining of two Bezier curve segment of degree three.

2. Draw the Bezier curve by the control points (2,1),(3,2),(5,0) and (6,2).

3. Explain Bezier curves and give the equation of the curve of degree n and the equation of the
polynomial.

4. Draw the Bezier curve defined by the control points (2,1),(3,2),(5,0) and (6,2). By properly choosing
another set of control points draw a Bezier curve such that the second curve is joined smoothly with the
first curve.

5. Find equation of Bezier curve which passes through points (0,0) and (-2,1) and is controlled through
points (7,5) and (2,0).
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Chapter 1: Introduction, CRT, Color Display

Question:- Define the following terms:- i) resolution ii) aspect ratio iii) refresh rate iv) Bit map and
pix map v) frame buffer vi) interlacing, vii) bit-plane viii) triad.

Solution:-

 Resolution:- The maximum no. of points that can be displayed without overlap on a CRT.

## Number of distinct pixels in each dimension that can be displayed.

In digital measurement, display resolution would be given in pixels per inch or cm.

## Example:- 640x480, 1920x1080, 4096x2160, 1280x720 etc.

 Aspect Ratio:- This number gives the ratio of horizontal points to vertical points necessary to
produce equal length lines in both directions on the screen.

## E.g. 4:3, 16:9, 16:10 etc.

 Refresh Rate of CRT:- It is defined by the number of times CRT screen is scanned by electron
beam per unit time.

E.g., 60Hz or 60fps refresh rate means whole screen is scanned 60 times per second.

 Pixmap:- Colorful mapping to bitplane’s bits is termed as pixmap where each one pixel may store
more than two colors, thus using more than one bit per pixel.

Bitmap:- Sometimes bitmap is used instead of pixmap which uses exactly one bit per pixel.

 Frame Buffer:- Picture definition is stored in a memory area called as refresh or frame buffer.

Frame buffer holds intensity values for all the screen points.

Stored intensity values are retrieved from frame buffer and displayed on the screen one row
(scanline) at a time.

 Interlacing:- On some raster scan system, each frame is displayed in two passes using an
interlaced refresh procedure.

In interlacing, instead of refreshing every line, the electron guns sweep alternate lines on each
pass. In the first pass, odd numbered lines are refreshed, in the seconds pass even numbered lines
are refreshed.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 Bit-plane:- In graphics, frame buffer is a contiguous memory location available for image
information

storage. At a minimum, there is 1 bit storage for each pixels in the screen. This is called as bit-
plane. In color image, there exists atleast 1 bit-plane surface for each basic colors. These surfaces
makes up the frame buffer storage.

 Triad:- a triad is a group of three phosphor dots coloured red, green, and blue on the inside of the
CRT display of a computer monitor or television set. 3 different electron guns exists to hit these
different colored phosphor of a pixel area to illuminate the light.

Question:- Short note on Cathode Ray Tube./or, describe the functionality of a CRT system with
the help of a diagram.

Solution:-

 Primary components of an electron gun in a CRT are the heated metal cathode & a control grid.

 Heat is supplied to the cathode by directing a current through a coil of wire (filament).

##  This causes electron to be “boiled off” the hot cathode surface.

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 The free, negatively charged electrons are then accelerated toward the phosphor coating by a high
+ve voltage.

 A beam of electrons (cathode ray) emitted by an electron gun, passes through focusing &
deflection systems that direct the beam toward specified position on the phosphor coated screen.

 Intensity of the electron beam is controlled by setting voltage levels on the control grid.

 Focusing system forces the electron beam to converge into a small spot as it strikes the phosphor.

 Horizontal & vertical movement of the electron beam is controlled by horizontal & vertical
deflection plate respectively.

##  Accelerating anode controls the velocity of the electron beam.

 After passing through focusing system & deflection system, when the electron in the beam collide
with phosphor coating, they are stopped & their kinetic energy is absorbed by the phosphor.

 Part of the beam energy is converted by friction into heat energy, & the remainder causes
electrons in the phosphor atoms to move up to higher quantum energy levels.

 After a short time, the “excited” phosphor electrons begins dropping back to their stable ground
state, giving up their extra energy as small quantum's of light energy.

 Because the light emitted by the phosphor fades very rapidly, to keep the phosphor glowing, the
picture is redrawn repeatedly by quickly directing the electron beam back over the same point.
This type of display is known as refresh CRT.

Question:- Consider the two different raster system with resolutions of 800x600 and 2560x2048.
What size of frame buffers is needed for each of these systems to store 24 bits per pixel? How much
storage is required for each system if 16 bits per pixel are to be stored?

Solution:-

## So, size of frame buffer=(2560x2048x24)/8 =1,57,28,640 bytes

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## So, size of frame buffer=(2560x2048x16)/8 =1,04,85,760 bytes

Question:- Consider the three different master systems with resolution of 640x480, 1280x1024 and
2560x2048. What is the size of the frame buffers is needed for each of these systems to store 12-bits
per pixel? How much storage is required for each systems if 24-bits per pixel are to be stored?

Solution:-

## 1 pixel can store=24 bits

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Question:- Define persistence and animation.

Solution:-

 Persistence:- Time it takes the emitted light from the screen to decay to 1/10 th of its original
intensity.

 Computer animation is a general term for a kind of visual digital display technology that
simulates moving objects on-screen.

Solution:-

## Random or Vector Scan Display Raster Scan Display

Beam is moved between the endpoints of Beam is moved all over the screen.
graphics primitives.

Scan conversion continuous to discrete Graphics primitives must be scan converted into
transformation] is not required. corresponding pixels.

Draws continuous and smooth lines. Can display mathematically smooth lines only by
approximating them with pixels on the raster grid.

## Cost is more. Cost is less.

Only draws lines. It has the ability to display areas filled with solid
colors or patterns or shaded areas.

## Line drawing system Point plotting system.

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Question:- Write a short note on raster scanning display system.

Solution:-

 Electron beam is swept across the screen one row at a time from top to bottom and from left to
right.

##  Entire screen is a matrix of phosphor dot(pixel).

 As the electron beam moves across each row, beam intensity is turned on and off to create
patterns of illuminated spots.

##  Picture definition is stored in a memory area called as refresh or frame buffer.

 Frame buffer holds intensity values for all the screen points.

 Stored intensity values are retrieved from frame buffer and displayed on the screen one row
(scanline) at a time.

 Raster scan starts from the top left corner of the screen, scanning horizontally from left to right
one row at a time.

 When it reaches the end of a scanline, it jumps to left end of next scanline (horizontal retrace)
and starts scanning it.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 When electron gun reaches bottom right of the screen, it jumps to the top left corner of the screen
without tracing (vertical retrace) and starts again.

 In the raster scan, screen image is maintained by repeatedly scanning the same image known as
refreshing of screen.

Solution:-

##  It has 3 phosphor color dots at each pixel position, known as triad.

 One phosphor dot emits a red light, another emits a green light and the third emits a blue light.

##  It has 3 electron guns, one for each color dot.

 Also it has shadow mask grid just behind the phosphor coated screen.

 The three electron beams are deflected and focused as a group onto the shadow mask, which
contains a series of holes aligned with the phosphor dot patterns.

 When the three beams pass through a hole in the mask, they activate a dot triangle, which appears
as a small color spot on the screen.

 We obtain color variations by varying the intensity levels on the three electron beams as follows-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Differentiate between passive and interactive computer graphics. Give example.

Solution:-

## (a) Non-Interactive or Passive Computer Graphics:

In non-interactive computer graphics, the picture is produced on the monitor, and the user does not have
any controlled over the image, i.e., the user cannot make any change in the rendered image. One example
of its Titles shown on T.V.

Non-interactive Graphics involves only one-way communication between the computer and the user, User
can see the produced image, and he cannot make any change in the image.

## (b) Interactive Computer Graphics:

In interactive Computer Graphics user have some controls over the picture, i.e., the user can make any
change in the produced image. One example of it is the ping-pong game.

Interactive Computer Graphics require two-way communication between the computer and the user. A
User can see the image and make any change by sending his command with an input device.

## Interactive computer graphics

The graphics which include animation are known as interactive computer graphics. We often visit
websites that include animation of pictures or buttons. When we hover over any button or image then its
shape is changed i.e. it is interactive in nature by which users can feel interaction. Similarly, there are
numerous other graphics which shows the animation when we perform any action on it e.g. on scrolling
browser window the image change its size or location.

##  Animation of button or graphics on mouse hover

 Animation of the picture or graphic objects on the scroll of the window or mobile screen
 Drawing on touch screens
 Display of weather forecast or any other moving charts/graphs on the screen
 Animating pictures or graphics in movies
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Passive computer graphics

The graphics which not change its shape on display are known as passive computer graphics. The images
or graphics objects are used in all the computer application e.g. in word documents, ebooks, websites,
presentations, emails etc.

Passive computer graphics gives details to the texts and it makes our reading more interesting. Also, note
that some graphics make the websites slow to load due to the high quality of the image. To solve the
problem of the large size of the image, we use jpg on websites. Another technique is that you can make
different versions of images by decreasing its quality. So for tablet and mobile devices, low-quality
images are displayed on the website and for a large screen, high quality of images are used. This makes

##  Data representation through charts

 Graphics elements used in the presentation, emails, word documents, and pdf
 Static images used in websites and mobile apps

 Interactive graphics respond to what the user does while passive graphics don’t

 Interactive graphics are often more bandwidth hungry than passive graphics

Solution:-

## These Devices include:

1. Keyboard
2. Mouse
3. Trackball
4. Spaceball
5. Joystick
6. Light Pen
7. Digitizer
8. Touch Panels
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

9. Voice Recognition
10. Image Scanner

Computers only work with numbers. To the computer, everything is a number. For example, the letter ‘A’
to a computer looks like the number 32 in decimal or 0010 0000 in hex (what the computer actually uses).
For graphics, the numbers represent (x,y) position in a 2-dimensional space as well as (r,g,b) colors at
those points.

Humans, on the other hand, process information in pictures and a picture-like format. The alphabet (pick
a human language, there’s plenty to choose from) for conveying information, and pictures for conveying
other information.

For communication, we use letters, numbers, and symbols mainly to convey information. The other side
of that would be pictures. In terms of computers, pictures are just another type of number; but instead of a
group of bytes that humans interpret as the alphabet, graphics work on the idea of points - so numbers to a
computer would be represented to us humans as points.

For graphical input, humans would use something like a digitizer - the most common one being your
mouse. The computer has a routine that converts the mouse movements into point coordinates. The other
type would be a digitizer pad - basically like a mouse pad with a special pen, but it converts the graphics
pen position to a pair of (x,y) coordinates.

Basically, any device that converts analog information to a digital format that a computer can “read” is a
graphical input device. Mouse, digitizer, digital camera, laser measurment device, etc.

For graphical output, the routines in the computer convert the (x,y) position, plus the {r,g,b} color
sequences to points on a monitor. In this case, the computer tells the graphics card what colors to paint at
specific points on the monitor.

With the right program and information, the computer will input graphics information (mouse, digitizer,
distance measurements, etc.) and process this data and present it in a graphical format to a montior (like
Google maps, jpeg picture, DVD movie, etc.)

Other types of graphical output would be a printer or plotter for ‘painting’ graphics onto paper, a 3-d
printer for creating blocks, gears, etc.

## Question:- What are the vertical and horizontal retrace?

Solution:-

 Raster scan starts from the top left corner of the screen, scanning horizontally from left to right
one row at a time.

 When it reaches the end of a scanline, it jumps to left end of next scanline (horizontal retrace)
and starts scanning it.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 When electron gun reaches bottom right of the screen, it jumps to the top left corner of the screen
without tracing (vertical retrace) and starts again.

## Chapter 2: Line and Circle Drawing

Question:- Draw a line using DDA having coordinates as (-1,-4) and (5,6).

Solution:-

Slope of line=m=10/6=1.67>1

1/m=0.6

## So, xi+1= xi+1/m and yi+1= yi+1 is to be followed.

Points are,

-1,-4

-0.4,-3

0.2,-2

0.8,-1

1.4,0

2,1

2.6,2

3.2,3

3.8,4

4.4,5

5,6

Question:- Briefly explain or write the Bresenham’s line drawing algorithm. How does it removes
the drawback of DDA algorithm?

Solution:-

 Two endpoints of the line are taken as input and left endpoint are stored in (x0,y0).

##  Calculate P0=2∆y-∆x which is starting value for the decision parameter

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 At each xk along the line starting at k=0, if Pk<0 the next point to plot is (xk+1,yk) and
Pk+1=Pk+2∆y

##  Repeat step 4 ∆x times.

 The algorithm takes decision of pixel plotting on the basis of pixel’s calculated(actual) position’s
distance from its upper and lower pixel(which actually exists on the screen).

 Either upper or lower pixel is selected and displayed to which the line’s calculated pixel is closest
to.

 Decision parameter checks the above mentioned criteria and thus removes the DDA algorithm’s
inaccuracy related drawbacks.

Question:- Draw a straight line segment in between (0,0) and (5,4) using Bresenham’s algorithm.
Find the intermediate points.

Solution:-

 ∆x=5-0=5

 ∆y=4-0=4

##  Initial decision parameter P0=2∆y-∆x=3

 x0,y0=0,0

 2∆y-2∆x=8-10= -2

k Pk xk+1,yk+1

0 3>0 1,1

1 3-2=1>0 2,2

2 1-2=-1<0 3,2

3 -1+8=7>0 4,3

4 7-2=5>0 5,4
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Using midpoint circle algorithm, find out the screen coordinates of the circumference of
a circle whose center is (0,0) and radius is 10 units.

Solution:-

 P0=1-10=-9

 (x0,y0)=(0,10)

## k Pk Xk+1,yk+1 2xk+1 2yk+1

0 P0=-9<0 1,10 2 20

1 P1=-9+2+1=-6<0 2,10 4 20

2 P2=-6+4+1=-1<0 3,10 6 20

3 P3=-1+6+1=6>0 4,9 8 18

4 P4=6+8+1-18=-3<0 5,9 10 18

5 P5=-3+10+1=8>0 6,8 12 16

6 P6=8+12+1-16=5>0 7,7(x=y) 14 14
STOP

Question:- Write midpoint circle drawing algorithm and generate coordinates for a circle of radius
12 cm with center located at (0,0).

Solution:-

## k Pk Xk+1,yk+1 2xk+1 2yk+1

0 P0=-11<0 1,12 2 24

1 P1=-11+2+1=-8<0 2,12 4 24
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

2 P2=-8+4+1=-3<0 3,12 6 24

3 P3=-3+6+1=4>0 4,11 8 22

4 P4=4+8+1-22=-9<0 5,11 10 22

5 P5=-9+10+1=2>0 6,10 12 20

6 P6=2+12+1-20=-5<0 7,10 14 20

7 P7=-5+14+1=10>0 8,9 16 18

## Question:- What do you understand by 8 point symmetry of a circle?

Solution:-

In circle, if we know a point on first octant having location as y,x, it can be reflected to get other 3

points. Also, if a point y,x exists in first octant, there must be a point x,y in second octant which can be

reflected to get other unique 3 points in circle. So from 1 point on circle, we can assume other
symmetrical 7 points on a circle. This property is called

## as 8-point symmetry of a circle.

Question:- Compare and contrast DDA and Bresenham’s line drawing algorithm.

Solution:-

Comparision
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 DDA uses floating points where as Bresenham algorithm use fixed points.
 DDA round off the coordinates to nearest integer but Bresenham algorithm does not.
 Bresenham algorithm is much accurate and efficient than DDA.
 Bresenham algorithm can draw circles and curves with much more accuracy than DDA.
 DDA uses multiplication and division of equation but Bresenham algorithm uses subtraction and

## - Digital Differential Analyzer,Line Bresenhams Line Drawing Algorithm

Drawing Algorithm

Arithmetic DDA algorithm uses floating points i.e. Bresenhams algorithm uses fixed points i.e. integer
Real Arithmetic Arithmetic.

Operations DDA algorithms uses multiplication Bresenhams algorithm uses only subtraction and
and division in its operations. addition in its

Speed DDA algorithm is rather slowly than Bresenhams algorithm is faster than DDA algorithm
Bresenhams algorithm in line drawing in line drawing because it performs only addition
because it uses real arithmetic (floating and subtraction in its calculations and uses only
point operations). integer arithmetic so it runs significantly faster.

Accuracy & DDA algorithm is not as accurate and Bresenhm algorithm is more accurate and efficient
Efficiency efficient as Bresenhm algorithm. as than DDA algorithm.

Drawing DDA algorithm can draw circles and Bresenhm algorithm can draw circles and curves
curves but that are not as accurate as with much more accuracy than DDA algorithm.
Bresenhm algorithm.

Round off DDA algorithm round off the Bresenhm algorithm does not round off but takes the
coordinates to integer that is nearest to incremental value in its operation.
the line.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## - Digital Differential Analyzer,Line Bresenhams Line Drawing Algorithm

Drawing Algorithm

## - - Bresenhm algorithm is less expensive than DDA

algorithm as it uses only addition and subtraction.

Question:- Calculate the points using DDA algorithm that would be plotted for a line whose
endpoints are A(6,5) and B(10,10).

Solution:-

Slope m=5/4=1.25>1

1/m=0.8

Points are,

6,5

6.8, 6

7.6, 7

8.4, 8

9.2, 9

10, 10

## Question:- Write a short note on parametric method of circle drawing.

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

(x,y) be any point on circle at (0,0) origin, t is the angle subtended by point at the circle’s center. “r” is the

## Now, from the diagram,

sin(t)=y/r  y=rsin(t)

cos(t)=x/r  x=rcos(t)

## t parameter values are not plotted on an axis.

Question:- Find the points required to plot to draw the circle with center at (100,90) and radius 10
using Bresenham’s circle drawing algorithm.

Solution:-

##  X=0 to x=y (first octant)

 P0=3-2x10=3-20=-17

 (x0,y0)=(0,10)

## 6 P6=13+24+10-28=19>0 7,6(x>y) 28 24 107,96

STOP
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Chapter 3: Filling and aliasing

Question:- Write a function called flood fill for filling closed area.

Solution:-

## void floodfill(int x, int y, int fill, int oldcolor)

if(getpixel(x,y)==oldcolor)

setcolor(fill);

setpixel(x,y);

floodfill(x+1,y,fill, oldcolor);

floodfill(x-1,y,fill, oldcolor);

floodfill(x,y+1,fill, oldcolor);

floodfill(x,y-1,fill, oldcolor);

Solution:-

## void boundaryfill(int x, int y, int fill, int boundary)

int current=getpixel(x,y);

## if((current!=boundary) && (current!=fill))

setcolor(fill);

setpixel(x,y);

boundaryfill(x+1,y,fill,boundary);

boundaryfill(x-1,y,fill,boundary);
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

boundaryfill(x,y+1,fill,boundary);

boundaryfill(x,y-1,fill,boundary);

## Question:- What is aliasing? What is the solution to it?

Solution:-

 The restriction of pixel position on the phosphor coated screen to integer values leads to two
consequences in raster scan:

1) Non-integer value points shift to the nearest integer location, causing deviations of the line.

2) There are steps or sudden jumps in the line from one integer value to the next.

##  A common example of aliasing effect is the staircase or jagged appearance.

 These are essentially caused by the problem of trying to map a continuous image onto a discrete
grid of pixels.

##  This continuous-to-discrete transformation (scan conversion) is performed by sampling the

continuous line, curve etc. at discrete points that only approximates the true location of the
sampled points.

This problem of pixel generation at alias locations of true objects is known as staircase effect.

Unequal intensity

• A slanted line appears dimmer than a horizontal/vertical line, although all are presented at the
same intensity level.

• In the above figure, pixels on the horizontal and vertical lines are placed at ‘a’ unit apart.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

• Distance between two pixels on the diagonal line is, d= √(a2+a2)= √2a=1.414a

• So, density of pixels will be less on diagonal. Therefore, intensity of line will decrease.

Solution of aliasing: Anti-aliasing is a method of fooling the eye that a jagged edge is really smooth.

##  Approaches regarding Anti-aliasing:-

1) To increase the resolution to such an extent that more pixels become available to
coincide with the computed values; in other words, to make the steps so small and so many that the
staircase begins to look more smooth.

2) Displaying two or more pixels around the computed location at varying intensities,
rather than a single pixel at rounded off location, which results the image to become hazy.

Chapter 4: 2D Transformation
Question:- Reflect the triangle whose vertices are A(3,1), B(1,3) and C(3,3) about the line y=x+4.

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Prove that the inverse of the rotation matrix is its transpose.

Solution:-

Question:- Write a short Note on Homogeneous coordinate system or What do you understand by
homogeneous coordinate and why it is used?

Solution:-

## In 2D transformation, problem arise when the successive operation involves translation/rotation/scaling

other than origin.
 This forms, [X’’]=[T1][X]+[T2], where [T2] is the additional column matrix containing
translation factor.
 Now, [T1] and [T2] can be combined to form a 3x3 composite transformation matrix
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 Where, a,b,d,e are the multiplicative factor of [T1] and c,f are respective x,y translational factors
of [T2].
 PROBLEM:- 3x3 matrix is not compatible for multiplying with a 2x1 position vector matrix.

 Inclusion of dummy coordinate to make 2x1 position vector matrix to a 3x1 matrix
where third coordinate is dummy.

 If is multiplied with a non-zero scalar “h” then the resultant matrix is which is known as
homogeneous coordinates of the point . , where extra coordinate “h” is known as a weight,
which is homogeneously applied to the Cartesian components.
 E.g., a point (2,3) can have homogeneous representation as (4,6,2) or (-2,-3,-1) or (8,12,4) etc.
 For geometric transformation, h=1 and corresponding homogeneous triple is (x,y,1) for the point
(x,y) in xy-plane.
Question:- Perform a 450 rotation of triangle ABC where A (0,0), B( 1,1), C(5,2)

## iii) About the point P(-2,-2).

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## the matrices to be multiplied should be,

Question:- Derive the transformation matrices for 2D reflection about X-axis and Y-axis.

Solution:-

 X-coordinate is not changed and sign of y-coordinate is changed. Thus, if we reflect a point (x,y)
in the x-axis, we get (x,-y)

 x’=x

 y=-y
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 So,

 y-coordinate is not changed and sign of x-coordinate is changed. Thus, if we reflect a point (x,y)
in the y-axis, we get (-x,y)

##  So, x’=-x and y’=y

Question:- Find the transformation matrix for the reflection about the line y=mx+c.

Solution:-

 Step 1:- Translate the line and object so that line passes through origin.

##  Step 2:- Rotate the object about origin about angle –Ѳ

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

##  Step 4:- Apply inverse rotation about origin

 Step 5:- Apply inverse translation to send back the object to its original position
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Question:- Write a short note on transformation between coordinate system.

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Derive composite transformation matrices for i) two successive rotations, ii) two
successive scaling, iii) general pivot point rotation.

Solution:-

i)
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

ii)

iii)
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- A mirror is placed in such a way that its x-intercept is 10 units and its y-intercept is 5
units from the origin. Find the reflection of the vertices of the square whose coordinates are A(0,0),
B(5,0), C(5,5) and D(0,5) in the mirror.

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Find the coordinates of the point X(3,3) after it is rotated twice, first about a point
A(1,2) by 450 anticlockwise and then about a point B(2,1) by 450 anticlockwise direction.

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Write the general form of a scaling with respect to a fixed point P(h,k).

Solution:-

Question:- Find the transformation matrix for reflection of the point P(x,y) about the line y=x.

Solution:-

## Reflection about straight line y=x:-

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

If we reflect (x,y) point about the line y=x, we get (y,x) i.e. (x’,y’)=(y,x)

Question:- Magnify the triangle with vertices A(0,0), B(1,1), C(5,2) to twice its size while keeping
C(5,2) fixed.

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Chapter 5: Clipping
Question:- Discuss briefly or write about Cohen-Sutherland line clipping algorithm with suitable
example. (A short discussion about the binary region codes assigned to line endpoints must precede
the algorithm). What are the advantage and disadvantages of the above algorithm?

Solution:-

 Algorithm:-

## 1) Given a line segment with endpoint P1(x1,y1) and P2(x2,y2).

2) Compute the 4-bit code for each endpoint with respect to clipping window.

3) If both codes are 0000, line lies completely inside the window and no clipping is required.

4) If both codes have 1 in the same bit position and bitwise AND of the codes is non-zero, line lies
outside the window.

5) If the resultant AND of the two endpoint codes is zero (0000) but there is a 1 present in any or
both endpoint, line may be partially visible or rejected. This line must be clipped at the window
edge.

6) Examine one of the endpoints, say P1(x1,y1). Read P1’s 4-bit code in order. When a set-bit(1) is
found, compute valid intersection I of the corresponding window edge with the line. Replace P1
with I and repeat the algorithm step(6) for the other endpoint P2’s 4-bit code.

##  Bottom window:- yB, x=x1+(1/m)(yB-y1)

Example:-

 Cohen-Sutherland algorithm is used to clip a line P1(70,20), P2(100,10) against a window [lower
left corner (50,10) and upper right hand corner(80,40)]

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 P1( outcode)0000

 P2(outcode) 0010

P1 AND P2 = 0000

0010

##  In P2, 1 is found in 3rd bit.

 Intersection with the right side of the window and line is at,

## Advantage:- ► Clipping and testing are done in fixed order.

► Efficient when most of the lines to be clipped are either rejected or accepted (not so many
subdivisions).

► Easy to program.

## ► Most line segments are outside and can be eliminated

Question:- A clipping window ABCD is specified as A(0,0), B(40,0), C(40,40) and D(0,40). Using
mid point subdivision algorithm find the visible portion if any, of the line segment joining the points
P(-10,20) and Q(50,10).

Solution:-

 Outcode of P is 0001
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 Outcode of Q is 0010

 Logical AND is zero and both endpoint codes are non-zero. Hence, line cannot be rejected as
invisible.

##  Midpoint is, xm=(x1+x2)/2 =(-10+50)/2 =20

 ym=(y1+y2)/2 =(20+10)/2=15

##  Outcode of Pm (xm,ym) is 0000.

 Neither segment PPm nor PmQ is either totally visible or totally invisible.

P Q Pm Remark

## 35,12 42,11 38,11 Continue with PmQ

38,11 42,11 40,11 This is the intersection point of line & right window edge

## -3,18 1,17 -1,17 Continue with PmQ

-1,17 1,17 0,17 This is the intersection point of line & left window edge

## Visible portion of line segment is from (0,17) to (40,11)

Question:- Find the normalization transformation for windows to viewport which uses the
rectangle whose lower left corner (2,2) and upper right corner (6,10) as a window and the viewport
that has lower left corner at (0,0) and upper right corner at (1,1).

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Describe or write the midpoint subdivision algorithm for line clipping.

Solution:-

At each endpoint,

 1) If the endpoints are visible, then it is farthest visible point. The process is complete. If not,
continue.

 2) If the line endpoints are invisible, no output is generated. The process is complete. If not,
continue.

 3) Divide the line P1P2 at its midpoint, Pm. Apply the previous testes to the two segments P1Pm
and PmP2. If PmP2 is rejected being invisible, the midpoint is an overestimation of the farthest
visible point. Continue with P1Pm. Otherwise, the midpoint is an underestimation of the farthest
visible point. Continue with P2Pm. If the segment becomes so short that the midpoint
corresponds to the accuracy of the machine or as specified to the end points, evaluate the
visibility of the point and the process is complete.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Question:- A clipping window ABCD is located as following: A(100,10), B(160,10), C(160,40),

D(100,40). Using Cohen-Sutherland clipping algorithm find the visible portion of the line segment
P1-P2 where P1(120,5) and P2(180, 30).

Solution:-
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Question:- What do you mean by clipping? Name different types of clipping.

Solution:-

 Clipping:- The technique for not showing that part of the drawing which one is not interested in is
called clipping.

## Different Types of clipping:-

a) Point clipping
b) Line Clipping (Cohen-sutherland algorithm, Midpoint subdivision algorithm, Cyrus beck
algorithm, Liang-Barsky algorithm)
c) Polygon clipping (Sutherland-Hodgeman algorithm, Weiler-Atherton algorithm)
d) Text Clipping

## Question:- Define condition about a point clipping.

Solution:-

Chapter 6: 2D Projection
Question:- Short note on Orthographic and oblique projection.

Solution:-

Orthographic Projection:-

projection.

##  The parallel projection for orthographic projection is shown in the figure.

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 x’=x

 y’=y

##  z’=z (As projected in XY-plane having z=0)

 Projection matrix,

Oblique Projection:-

If the line of projection is not perpendicular to the view-plane, then it is called as oblique
projection.

 Equation of line through point P( x1,y1,z1) parallel to vector V=(xp, yp, zp) which passes through
another point Q(x2,y2,z2) is,

## t be any real number

 x2=x1+t*xp
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 y2=y1+t*yp

 z2= z1+t*zp

Now, z2 =0

So, t= - z1/zp

 x2=x1- z1/zp*xp

 y2=y1- z1/zp*yp

Question:- What is projection? How many projections are there? Differentiate between oblique and
orthographic projection.

Solution:-

## Projection:- Projection is the mapping of a 3D object into a view-plane. The requirement of

projection whenever we see an 3D object in a 2D screen (monitor), then we have to map a 3D object
into a 2D plane or in a 3D plane, with a fixed z-value.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Difference between oblique and orthographic projection:-

Oblique projection is a type of parallel projection. In both oblique projection and orthographic projection,
parallel lines of the source object produce parallel lines in the projected image. The projectors in oblique
projection intersect the projection plane at an oblique angle to produce the projected image, as opposed to
the perpendicular angle used in orthographic projection.

Solution:-

##  Perspective projection is located as a finite point whereas Parallel projection is located at

infinite points.
 Perspective projection form a realistic picture of object whereas Parallel projection do not form
realistic view of object.
 Perspective projection cannot preserve the relative proportion of an object whereas Parallel
projection can preserve the relative proportion of an object.
 Projector in perspective projection is not parallel whereas Projector in parallel projection is
parallel.
 Perspective projection represents the object in three dimensional way whereas Parallel
projection represents the object in a different way like telescope.
 The lines of perspective projection are not parallel whereas the lines of parallel projection are
parallel.
 Perspective projection cannot give the accurate view of object whereas Parallel projection can
give the accurate view of object.

Question:- Explain in brief different categories of parallel and perspective projection in 2D.

Solution:-

Perspective Projection:-

 There is a fixed point from which the object is viewed, is called the center of projection.

 There is a fixed plane on which the object is seen, is called projection or view-plane.

 Technique is to draw lines from each point of the 3D object with center of projection and find out
the intersecting point with the projection line & view-plane and join the intersecting points to
draw the projected view.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 C is the center of projection placed at –d distance on x-axis, XY plane is the view plane, P is the
object point, P’ is the projected point of P.

 y’=y*d/(z+d)

##  Z’=0 (Projected on XY plane having z=0)

 In matrix form,

## Type of Perspective Projection:-

1) One-point:- It is simplest to draw. It contains only one vanishing point on the horizon line.
2) Two-point:- Gives better impression of depth. It contains two vanishing points on the horizon
line.
3) Three-point:- Most difficult to draw. It contains three vanishing points, two on the horizon line
and one another below or above the horizon.

Parallel Projection:-

 The projected view can be drawn as- draw the parallel line from each point of the object to the
view plane.

 The intersecting point with the line & view plane is called the projected point.

## Type of parallel projection:-

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

a) Orthographic Projection:-

##  If the line of projection is perpendicular to the view-plane, then it is called orthographic

projection.
 The parallel projection for orthographic projection is shown in the figure.
 x’=x
 y’=y
 z’=z (As projected in XY-plane having z=0)
 Projection matrix,

b) Oblique Projection:-

If the line of projection is not perpendicular to the view-plane, then it is called as oblique
projection.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 Equation of line through point P( x1,y1,z1) parallel to vector V=(xp, yp, zp) which passes through
another point Q(x2,y2,z2) is,

## t be any real number

 x2=x1+t*xp

 y2=y1+t*yp

 z2= z1+t*zp

Now, z2 =0

So, t= - z1/zp

 x2=x1- z1/zp*xp

 y2=y1- z1/zp*yp

## Type of Oblique Parallel Projection:-

Cavalier projection:- All lines perpendicular to the projection plane are projected with no change in
length.

Cabinet projection:- Lines which are perpendicular to the projection plane are projected at ½ of the
length.

## Type of Orthographic Parallel Projection:-

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

## Chapter 7: Hidden surface removal

Question:- Write down the Z-buffer algorithm or a short note on z-buffer algorithm.

Solution:-

 Initialize IB=Background intensity for all (x,y), depth(x,y)=Zmax (-∞) and refresh (x,y)=IB
 For each position on each polygon surface:-
 a) Calculate depth Z for each position (x,y) on the polygon
 b) If Z<depth(x,y) then depth(x,y)=Z and refresh(x,y)=IS(x,y)

 IS is the projected intensity value of the surface at position (x,y), which has the minimum value of
Z, at the current stage of iteration.
 Equation of the surface:- Ax+By+Cz+D=0  z= (-Ax-By-D)/C

 It is easy to implement
 Total number of polygon can be arbitrarily large
 It can be implemented in hardware
 It requires additional buffer and hence large memory
 It is a time consuming process.

## Question:- Write a short note on hidden surface removal.

Solution:-

 One of the most challenging problems in computer graphics is the removal of hidden parts from
images of solid objects.
 In real life, the opaque material of these objects obstructs the light rays from hidden parts and
prevents us from seeing them.
 In the computer generation, no such automatic elimination takes place when objects are projected
onto the screen coordinate system.
 Instead, all parts of every object, including many parts that should be invisible are displayed.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 To remove these parts to create a more realistic image, we must apply a hidden line or hidden
surface algorithm to set of objects.
 The algorithm operates on different kinds of scene models, generate various forms of output or
cater to images of different complexities.
 All use some form of geometric sorting to distinguish visible parts of objects from those that are
hidden.
 Just as alphabetical sorting is used to differentiate words near the beginning of the alphabet from
those near the ends.
 Geometric sorting locates objects that lie near the observer and are therefore visible.
 Hidden line and Hidden surface algorithms capitalize on various forms of coherence to reduce the
computing required to generate an image.
 Different types of coherence are related to different forms of order or regularity in the image.
 Scan line coherence arises because the display of a scan line in a raster image is usually very
similar to the display of the preceding scan line.
 Frame coherence in a sequence of images designed to show motion recognizes that successive
frames are very similar.
 Object coherence results from relationships between different objects or between separate parts of
the same objects.
 A hidden surface algorithm is generally designed to exploit one or more of these coherence
properties to increase efficiency.
 Hidden surface algorithm bears a strong resemblance to two-dimensional scan conversions.

##  Object space methods

 Image space methods

Object space methods: In this method, various parts of objects are compared. After comparison visible,
invisible or hardly visible surface is determined. These methods generally decide visible surface. In the
wireframe model, these are used to determine a visible line. So these algorithms are line based instead of
surface based. Method proceeds by determination of parts of an object whose view is obstructed by other
object and draws these parts in the same color.

Image space methods: Here positions of various pixels are determined. It is used to locate the visible
surface instead of a visible line. Each point is detected for its visibility. If a point is visible, then the pixel
is on, otherwise off. So the object close to the viewer that is pierced by a projector through a pixel is
determined. That pixel is drawn is appropriate color.

##  Back Face Removal Algorithm

 Z-Buffer Algorithm
 Painter Algorithm
 Scan Line Algorithm
 Subdivision Algorithm
 Floating horizon Algorithm
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Chapter 8: Curves

Question:- Write the condition for smooth joining of two Bezier curve segment of degree three.

Solution:-

 To join curve, we can choose four more points and construct second curve which can be attached
to the first.

 Bezier curves pass through the end points and it is required that the first control point of the
second curve just match the last control point of the first curve.

 Two cubic Bezier curve sections are defined by the control points (P0,P1,P2,P3) and (Q0,Q1,Q2,Q3)
respectively then the above condition requires only

 Q0=P3
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question;- Draw the Bezier curve by the control points (2,1),(3,2),(5,0) and (6,2).

Solution:-

Question:- Explain Bezier curves and give the equation of the curve of degree n and the equation of
the polynomial.

Solution:-

##  Bezier curve can be fitted to any number of control points.

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 Given a set of n+1 control points P0,P1,….,Pn, a parametric Bezier curve segment that will fit to
those points is mathematically defined by,

 Where Bi,n(u) are the Bezier blending functions, also known as Bernstein Basis function

defined as,

##  Here, a cubic Bezier curve controlled by the points P0,P1,P2,P3 is

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

Question:- Draw the Bezier curve defined by the control points (2,1),(3,2),(5,0) and (6,2). By
properly choosing another set of control points draw a Bezier curve such that the second curve is
joined smoothly with the first curve.

Solution:-

 Let the cubic Bezier curve P(u) defined by P0=[2,1], P1=[3,2], P2=[5,0] and P3=[6,2] with
0≤u≤1.

##  The curve starts at P0 i.e., P(u=0) and ends at P3 i.e. P(u=1).

 We have to choose another set of four control points say Q0,Q1,Q2,Q3 such that the cubic Bezier
curve say Q(u’), 0≤u’≤1 defined by them joins the curve P(u) at P3 smoothly.
Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata

 From the fact that the last control point doesn’t feature in the C2 continuity condition, we are free
to choose Q3 without affecting continuity at junction P3=Q0.After plotting all the points P0, P1,
P2 and P3=Q0 and Q1 we choose Q3 as (6, 12).

Question:- Find equation of Bezier curve which passes through points (0,0) and (-2,1) and is
controlled through points (7,5) and (2,0).

Solution:-

##  Corresponding cubic Bezier curve is given by,

Prepared By:: Prof. Abhijit Sarkar, IEM, Kolkata