Full Notes CG
Full Notes CG
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
24. Write algorithm to clip line using cohen Sutherland line clipping algorithm.
25. Explain about Southerland Hodgeman polygon clipping.
26. What is 3D viewing? Explain in brief the role of parallel projection in 3D visualization.
27. Define 3D translation, rotation and scaling.
28. What is projection? What are the types of projection?
29. What do you mean by perspective projection?
30. What are the type of parallel projection?
31. Differentiate between parallel and perspective projections.
32. Explain back face detection method and depth buffer method in details.
33. Explain depth sorting method and buffer method in details.
34. What do you mean by animation?
35. What are different kinds of animation techniques used in graphics system.
36. Explain different types of animation system in computer graphics.
37. Define aliasing and anti-aliasing.
38. Differentiate between the Simulation and animation.
39. What do you mean by tweaking and morphing explain in brief.
40. What are the raster and vector graphics?
41. What are the curve fitting techniques? Explain.
42. Describe about pattern filling techniques.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
1 CTH EDUCATION
UNIT-01 : INTRODUCTION AND APPLICATIONS
What is CG,
Characteristics & Classification of CG
Applications:
Presentation graphics,
painting and drawing,
scientific visualization,
image processing,
digital art, entertainment,
CAD in architecture, animation.
Questions to be discussed :
1. Define the following terms :
a. Pixel
b. Resolution
c. Aspect ration
d. PPI and DPI
2. What is computer graphics ? What are the application of computer graphics.
3. Explain in details presentation graphics & image processing.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
What is graphics ?
Graphics are visual presentation which are displayed on a variety of surfaces, including paper,
walls, or a computer monitor.
They are created for entertainment, branding, or providing information.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
Basically there are two types of computer graphics :
1) Non Interactive Computer Graphics
2) Interactive Computer Graphics :
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
Vector Graphics :
In vector graphics, mathematical formulae are used to draw different types of shapes, lines,
objects, and so on.
What is pixel ?
The full form of the pixel is "Picture Element.
Pixel is the smallest element of an image.
A pixel is represented with a dot or a square on a computer screen.
A pixel size has expressed in pixels per inch(PPI) or dot per inch(DPI).
It can have only one color at a time.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
Resolution :
Resolution is the total number of pixels in an digital image.
If an image has M rows and N columns, then its resolution can be defined as M X N.
Where M represents the width of the picture and N repersents height of the picture.
We can say that the higher is the pixel resolution, the higher is the quality of the image.
Example : We can define pixel resolution of an image as 1366 X 768.
Megapixels
We can calculate mega pixels of a camera using pixel resolution.
Mega pixels = width x height / 1 Million.
Calculating the mega pixels of the camera
Lets say we have an image of dimension: 2500 X 3192.
Its pixel resolution = 2500 * 3192 = 7982350 bytes.
Dividing it by 1 million = 7.9 = 8 mega pixel (approximately).
Aspect Ratio :
It is the ratio of its width to its height of an image.
Aspect ratio is expressed with two numbers separated by a colon, such as 16:9.
For the x:y aspect ratio, the image is x units wide and y units high.
Common aspect ratios are 1.85 : 1 and 2.39 : 1 in cinematography, 4:3
and 16:9 in television photography, and 3:2 in still photography.
It is defined as the density of dots present per It is the number of pixels present per inch of a
inch of a printed image digital image
Colors used Cyan, magenta, yellow, and black Red, green, and blue colors are used.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
1 CTH EDUCATION
Unit-02 : Display devices
Random-scan and raster scan monitors,
Colour CRT,
Plasma panel displays,
LCD Panels Input/Output Devices.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
What is Display device ?
A display device is an output device which is used to view text, image or video on the screen.
It is also known as a visual display unit (VDU).
Anything capable of connecting to a computer and display its output is considered as display
device
Examples :
CRT monitor
LCD.
LED
Projector
Touch screen etc.
What is a Monitor ?
A monitor is an electronic output device.
It is used to display images, text, video, and graphics.
It is almost like a TV, but its resolution is much higher than a TV.
The first computer monitor was introduced on 1 March 1973.
Older monitors were built by using a fluorescent screen and CRT, result heavy & large in size.
Nowadays, all monitors are made up by using flat-panel display technology, commonly backlit
with LEDs.
These modern monitors take less space on the desk as compared to older CRT displays.
Types of Monitors
There are several types of monitors, some are as follows :
1. CRT Monitors
2. LCD Monitors
3. LED Monitors
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
The electron beam from the gun sequentially scan every pixel.
In the process beam heats the pixel and phosphorus dot of the pixel gets excited.
Once the electron heats the pixel then phosphorus dot, light up & they are projected on screen.
The color you view on the screen is red, blue and green.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
Color CRT :
A color CRT monitor capable of displaying many colors.
Color monitors implement the RGB color model by using three different phosphors that
appear red, blue and green, when activated.
When colors are activating with different intensities, color monitors can create an unlimited
number of colors.
There are two popular approaches for producing color displays with a CRT are :
1. Beam Penetration Method
2. Shadow-Mask Method
Shadow-Mask Method :
Shadow Mask Method is commonly used in Raster-Scan System because they produce a much
wider range of colors than the beam-penetration method.
It is used in the majority of color TV sets and monitors.
This type of CRT has 3 electron guns, one for each color dot and a shadow mask grid just behind
the phosphor coated screen.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
Difference between CRT and LCD :
CRT LCD
CRT stands for Cathode Ray Tube. While LCD stands for Liquid Crystal Display.
The cost of CRT is less than LCD. While it is costlier than CRT.
CRT is faster than LCD in terms of response. It is slower than CRT in terms of response.
Electron Gun is used to form images. Liquid crystals are used to form images.
It stands for “Cathode Ray It stands for “Liquid Crystal It stands for “Light Emitting
Tube“ Display“. Diode”
CRTs are bulky, heavy, and LCDs are thin, light, and LED is light, compact, and
large. compact. Thinner.
Used Electron Gun Used Liquid crystals Used Light Emitting Diode
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
All commands regarding point, line or character are stored in display buffer memory &
controlled by display controller.
After drawing the picture, the system cycles back to the first line and design all the lines 30 to
60 time each second.
Faster refreshing can burn phosphor so, prevent refresh rate greater than 60 frames per sec.
It is also called as stroke-writing displays or calligraphic displays.
They have a high resolution of pictures and produce smooth line drawing.
Random-Scan monitors cannot display realistic shades scenes.
Exp : Pen plotter.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
Refresh rate depends or resolution Refresh rate does not depend on the
picture.
Beam Penetration technology come under it. Shadow mark technology came under this.
Flat-Panel Displays :
The term flat-panel display is a class of video devices.
It has reduced the volume, weight and power requirements compared to a CRT.
A significant feature of flat-panel displays is that they are thinner than CRT, & we can hang on
walls.
Current uses of flat-panel displays include small TV, monitors, calculator, laptop,
advertisement boards in elevators etc.
There are two types of flat-panel displays :
o Emissive displays
o Non-emissive displays
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
Emissive displays :
The emissive displays are device that convert electrical energy into light.
Example : plasma panel, LED etc.
Non-emissive displays :
Non-emissive displays use optical effect to convert sunlight or light from other source into
graphics pattern.
Example : LCD.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
1 CTH EDUCATION
Unit-03 : 2D DRAWING GEOMETRY
2D transformation :
Use of homogeneous coordinate systems,
translation,
scaling,
rotation,
mirror reflection,
rotation about an arbitrary point.
Interactive techniques :
Constraints,
Grids,
Gravity field,
Rubber-band,
Dragging,
Painting & drawing
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
What is 2D transformation :
The term ‘transform’ means ‘to change’.
The change can either be of shape, size or position of the object.
2D Transformations take place in a two dimensional plane.
The fundamental objective of 2D transformation is to simulate the movement & manipulation
of objects in a plane.
There are various transformations possible on an object :
Translation
Scalling
Rotation
Reflection
Shearing
Each of the above transformation is done by using a different transformation matrix.
2D Translation :
The term ‘translation’ means ‘re-position’.
A translation moves an object to a different position on the screen.
It is a process of moving an object from one position to another in a 2D plane.
In translation parameter Tx and Ty denote the change in the coordinates of x & y respectively.
You can translate a point in 2D by adding translation coordinate (Tx, Ty) to the original
coordinate X,Y to get the new coordinate X′, Y′.
Consider a point A has to be moved from one position to another in a 2D plane.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
Q. Given a circle C with radius 10 and center coordinates (1, 4). Apply the translation
with distance 5 towards X axis and 1 towards Y axis. Obtain the new coordinates of
C without changing its radius.
Solution :
Given, Old coordinates = A(x, y) = (1, 4)
Translation vector = T(Tx, Ty) = (5, 1)
x’ = x + Tx = 1 + 5 = 6
y’ = y + Ty = 4 + 1 = 5
A’ = A + T
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
Q. Given a square with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply the
translation with distance 1 towards X axis and 1 towards Y axis. Obtain the new
coordinates of the square.
Solution :
Given,
Old coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
Translation vector = (Tx, Ty) = (1, 1)
For Coordinates A(0, 3) :
x’ = x + Tx = 0 + 1 = 1
y’ = y + Ty = 3 + 1 = 4
Thus, New coordinates of corner A’ = (1, 4).
For Coordinates B(3, 3) :
x’ = x + Tx = 3 + 1 = 4
y’ = y + Ty = 3 + 1 = 4
Thus, New coordinates of corner B’ = (4, 4).
For Coordinates C(3, 0) :
x’ = x + Tx = 3 + 1 = 4
y’ = y + Ty = 0 + 1 = 1
Thus, New coordinates of corner C’ = (4, 1).
For Coordinates D(0, 0) :
x’ = x + Tx = 0 + 1 = 1
y’ = y + Ty = 0 + 1 = 1
Thus, New coordinates of corner D’ = (1, 1).
Thus, New coordinates of the square = A’ (1, 4), B’(4, 4), C’(4, 1), D’(1, 1).
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
Scalling :
Scalling means to change the size of object.
This change can either be positive or negative.
In scalling parameter Sx and Sy denote the change in the coordinates of x & y respectively.
After applying scalling factor, coordinate is either increased or decreased depending on the
value of scalling factors.
If scaling factor > 1, then the object size is increased.
If scaling factor < 1, then the object size is reduced.
The scalling matrix is given as :
A’ = S x A
Q1. A square object with coordinate points A(0, 3), B(3, 3), C(3, 0), D(0, 0). Apply
the scaling parameter 2 towards X-axis and 3 towards Y-axis and obtain the new
coordinates of the object.
Solution :
Given,
Old corner coordinates of the square = A (0, 3), B(3, 3), C(3, 0), D(0, 0)
Scaling factor along X axis = 2
Scaling factor along Y axis = 3
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
Thus, New coordinates of the square after scaling = A (0, 9), B(6, 9), C(6, 0), D(0, 0).
Q2. Scale the object with co-ordinate A(2, 1), B(2, 3), C(4, 2), and D(4, 4) with a scale
factor of Sx = Sy = 2.
Q3. What will be the effect of scalling factor Sx=1/2 and Sy=1/3 on a given triangle
ABC whose coordinates are A=[4, 1], B=[5, 2] and C=[4, 3] ?
2D Rotation :
It is a process of changing the angle of the object in 2D plane.
Rotation can be clockwise or anticlockwise.
Rotation point is also called a pivot point.
The positive value of the rotation angle rotates an object in a counter-clockwise direction.
The negative value of the rotation angle rotates an object in a clockwise direction.
When the object is rotated, then every point of the object is rotated by the same angle.
Consider a position vector from origin to point P(x, y).
Let r be the length of vector and θ be the angle of vector with x-axis.
The rotation matrix will be :
Given that,
Initial coordinates of the object P = (x, y)
Initial angle of the object P with respect to origin = θ
Rotation angle = Φ
New coordinates of the object P after rotation = (x’, y’)
It is required to rotate the point P(x, y) by an angle θ in anti-clockwise direction, then the
point P is now shifted to point P’(x’, y’).
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
Let us find the value of x’ in terms of x, y, and θ.
x’ = rcos(θ+Φ)
Where,
= rcosθcosΦ – rsinθsinΦ x = rcosθ
x’ = xcosΦ - ysinΦ y = rsinθ
In matrix form,
[x’] = [x] [T]
Substituting value of x’ and y’, we get,
Q1. Concider an object ABC with coordinates A(1, 1), B(10, 1) and C(5, 5). Rotate the object by 90°
in counter-clockwise direction, and give the coordinates of the transformed object.
Q2. Perform a 45° rotation of object A(2, 1), B(5, 1), C(5, 6) in clockwise direction & give the
co-ordinates of the transformed objects.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
Reflection :
The term ‘reflection’ means to simply reflect an object in the plane mirror.
The image is made on the opposite side.
The reflection is also described as the rotation by 180°.
Due to reflection an image is of the same size but on opposite quadrant.
So, we need a identity matrix with negative or positive value depending on the situation.
Reflection about y = x is :
Reflection about y = -x is :
Q1. Concider a triangle ABC whose coordinates are A[4, 1], B[5, 2] and C[4, 3].
a) Reflect the given triangle about x-axis
b) Reflect the given triangle about y-axis
c) Reflect the given triangle about y = x
d) Reflect the given triangle about line y = -x
a) Reflection about x-axis is : b) Reflection about y-axis is :
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
9 CTH EDUCATION
c) Reflection about y = x is : d) Reflection about y = -x is :
Non-Interactive :
In non-interactive technique, the picture is produced on the monitor, and the user does not have
any controlled over the image.
Image will work according to instructions given in stored program.
This technique 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.
Example : Shown TV, Screen saver, listening song on radio etc.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
10 CTH EDUCATION
Interactive technique :
In interactive technique user have some controls over the picture.
The user can make any change in the produced image.
This technique involves in 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.
Example : Ping pong video game, Browsing internet etc.
Constraints :
A constraint is a rule for altering input coordinates values to produce a specified orientation or
alignment of the displayed coordinates.
The most common constraint is a horizontal or vertical alignment of straight lines.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
11 CTH EDUCATION
Grids :
Another kind of constraint is a grid.
A grid is a rectangular lines displayed in some part of the screen area.
When a grid is used, any input coordinate position is rounded to the nearest intersection of two
grid lines.
Gravity field :
When it is needed to connect lines at positions between endpoints, the graphics packages convert
any input position near a line to a position on the line.
The conversion is accomplished by creating a gravity area around the line.
Any related position within the gravity field of line is moved to the nearest position on the line.
It illustrated with a shaded boundary around the line.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
12 CTH EDUCATION
Rubber Band Methods :
Straight lines can be constructed and positioned using rubber band methods which stretch out
a line from a starting position as the screen cursor.
Dragging :
This methods move object into position by dragging them with the screen cursor.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
1 CTH EDUCATION
Unit-04 : CONICS AND CURVES
DDA lines circle drawing algorithm,
Bresenham's lines circle drawing algorithm,
Generation of ellipses,
Curve drawing,
Parametric representation,
need of cubic curves,
Drawing cubic Bezier and B-spline curves & their properties.(No derivations needed)
Questions to be discussed :
1. Write DDA line drawing algorithm.
2. Explain DDA algorithm. Also, write the advantage and disadvantage of DDA algorithm.
3. Explain about Bresenham’s line drawing algorithm.
4. Derive the expression for decision parameter used in Bresenham’s circle algorithm.
5. Differentiate between DDA algorithm and Bresenham’s algorithm.
6. What is curve ? Explain different types of curve in computer graphics.
7. What do you mean by Bezier curve ? Also explain cubic bezier curve.
8. Differentiate between Bezier curve and B-Spline curve.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
What is line ?
A line connects two or more points.
It is a basic element in computer graphics.
To draw a line, you need minimum two points between which you can draw a line.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
DDA Line Drawing :
DDA stands for Digital Differential Analyzer.
The DDA helps us to interpolate the variables on an interval from one point to another point.
We can use the DDA algorithm to perform rasterization on polygons, lines, and triangles.
DDA algorithm is also known as an incremental method of scan conversion.
In this algorithm, we can perform the calculation in a step by step manner.
We use the previous step result in the next step.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
Q. A line has a starting point (1, 1) and ending point (3, 3). Apply the Digital
Differential Analyzer algorithm to plot a line.
Solution :
Here, starting point as (1, 1), and ending point (3, 3).
Now, we have to calculate Δx and Δy.
Δx = 3 – 1 = 2
Δy = 3 – 1 = 2 xk yk xk+1 yk+1
𝟐 1 1 2 2
m= =1
𝟐 2 2 3 3
Here, |Δx| ≥ |Δy|
Then assign, Δx = 1
xk+1 = xk + 1 = 1 + 1 = 2
yk+1 = yk + m = 1 + 1 = 2 (3, 3)
Now, our new co-ordinate (2, 2)
(2, 2)
Again, performe same operation.
(1, 1)
xk+1 = xk + 1 = 2 + 1 = 3
yk+1 = yk + 1 = 2 + 1 = 3
Now, our new co-ordinate (3, 3), so we have achieve the end points.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
Introduction to Bresenham's line drawing Algorithm
It is a second method of generating a line that was proposed after the DDA algorithm to
overcome its limitations and drawbacks.
It was developed by J.E. Bresenham in 1962.
This algorithm is used for calculating intermediate coordinate points using integer addition
and subtraction.
It is also an incremental method for creating a line.
It is faster than the DDA algorithm as it does not involves the use of heavy operations.
It uses multiplication & division its operation. It uses only subtraction & addition for operation.
It is slower. It is faster.
DDA Algorithm can draw circle and curves Bresenham's Line Algorithm can draw circle and
but are not accurate. curves with more accurate than DDA Algorithm.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
Algorithm of Bresenham's line drawing :
Step – 1 : Start
Step – 2 : We consider Starting point as (x1, y1), and ending point (x2, y2).
Step – 3 : Now, we have to calculate slope(m), Δx and Δy.
Δx = x2 – x1
Δy = y2 – y1
𝚫𝐲 y2−y1
m= =
𝚫𝐱 x2−x1
Step – 4 : Calculate decision parameter(P) :
P = 2.Δy – Δx
Step – 5 : Check two conditions about decision parameter
If P < 0
xk+1 = xk + 1
yk+1 = yk
Pk+1 = Pk + 2.Δy
If P ≥ 0
xk+1 = xk + 1
yk+1 = yk + 1
Pk+1 = Pk + 2.Δy - 2.Δx
Step – 6 : We will repeat step 5 until we find the ending point of the line.
Step – 6 : Stop.
Q. A line has a starting point (9,18) and ending point (14,22). Apply the
Bresenham’s Line Drawing algorithm to plot a line.
Solution : We have two coordinates,
Starting Point = (x1, y1) = (9, 18)
Ending Point = (x2, y2) = (14, 22)
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
Step – 2 : Now, we are going to calculate the decision parameter(Pk).
Pk = 2Δy - Δx
=2x4–5=3
The value of Pk = 3
Step – 3 : Here m < 1(m=0.8) Now, we will check both the cases.
If Pk ≥ 0(Pk = 3)
Then,
xk+1 =xk +1 = 9 + 1 = 10
yk+1 =yk +1 = 18 +1 = 19
Pk+1 = Pk +2Δy - 2Δx =3+ (2 x 4) - (2 x 5) = 1
Step – 4 : Now move to next step. We will calculate the coordinates until we reach the end
point of the line.
Pk Pk+1 xk+1 yk+1
9 18
3 1 10 19
1 -1 11 20
-1 7 12 20
7 5 13 21
5 3 14 22
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
Algorithm of Bresenham’s Circle Drawing :
Step – 1 : Start.
Step – 2 : First, we allot the starting coordinates (x1, y1) as follows :
x1 = 0
y1 = r
Step – 3 : Now, we calculate the initial decision parameter P.
P = 3 – 2R
Step – 4 : Assume, the initial coordinates are (xk, yk) then next coordinates will be (xk+1, yk+1).
Now, we will find the next point according to the value of the decision parameter (P).
Case – 2 : If P ≥ 0 then
xk+1 = xk + 1
yk+1 = yk –1
Pk+1 = Pk + 4(xk+1 – yk+1) + 10
Step – 6 : If the center coordinates (x1, y1) is not at the origin (0, 0), then we will draw the points
as follow :
x coordinate = xc + x1
y coordinate = yc + y1 {xc and yc represents the current value of x and y coordinate}
Step – 7 : We repeat step 5 and 6 until we get xk+1 ≥ yk+1.
Step – 8 : Stop.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
9 CTH EDUCATION
Q. Given the centre point coordinates (0, 0) and radius as 8, using Bresenham’s
circle drawing algorithm generate all the points to form a circle.
Solution :
Step – 1 : Start
Step – 2 : Assign the starting point coordinates (X1, Y1) as :
X1 = 0
Y1 = R = 8
Step – 3 : Calculate the value of initial decision parameter P as :
P=3–2xR
P = 3 – 2 x 8 = -13
Step – 4 : Assume, the initial coordinates are (xk, yk) then next coordinates will be (xk+1, yk+1).
Step – 5 : If P < 0, so case-01 is satisfied.
Xk+1 = Xk + 1 = 0 + 1 = 1
Yk+1 = Yk = 8
Pk+1 = Pk + 4 x Xk+1 + 6 = -13 + (4 x 1) + 6 = -3
Step – 6 : This step is not applicable here because center is (0, 0).
Step – 7 : We repeat step 5 until we get xk+1 ≥ yk+1.
These are all points for Octant-1. These are all points for Quadrant-1.
(5, 5) (8, 0)
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
10 CTH EDUCATION
These are all points of the Circle.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
11 CTH EDUCATION
What are curves in computer graphics ?
A curve is a continuous and smooth drawing a line without any gap.
In other words, a curve is a finite or infinite set of points.
Mathematically, a line or any geometrical figure generated by line is also a curve.
One way to recognize a curve is that it bends and changes its direction at least once.
There are three types of curves :
1. Explicit,
2. Implicit, and
3. Parametric curves.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
12 CTH EDUCATION
Implicit Curves :
In this curve there are two variables one is dependent and other is independent.
Here, dependent variable is expressed in terms of independent variable.
An explicit function is used to define the explicit curve
y = f(x)
In this equation x is independent & y is dependent variable.
Example :
y = mx + c
Implicit curve :
Here, dependent variable is not expressed in terms of independent variable.
An implicit function is used to define the implicit curve
f(x, y) = 0
The multivalued curves can be represented such as for an single x value, many y values.
The very common example is circle, and is implicitly represented as :
Parametric Curves :
Parametric curves are the curves which have parametric values.
Here, a third variable considered to be a parameter.
Practically parametric curves are mostly used.
P(t) = x(t), y(t)
The functions f and g become the (x, y) coordinates of any point on the curve, and the points are
obtained when the parameter t is varied over a certain interval [a, b], normally [0, 1].
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
13 CTH EDUCATION
Bezier Curve :
Bezier Curve is parametric curve defined by a set of control points.
In this, two points are ends of the curve & other points determine the shape of the curve.
Bezier curve is discovered by the French engineer Pierre Bézier.
The Bezier curve can be represented mathematically as :
𝑛
Where Pi is the set of points and B 𝑖 (t) represents the Bernstein polynomials which are given by
Here,
t is any parameter where 0 <= t <= 1
P(t) = Any point lying on the bezier curve
Bi = ith control point of the bezier curve
n = degree of the curve
Example :
The simplest Bézier curve is the straight line from the point P0 to P1.
A quadratic Bezier curve is determined by three control points.
A cubic Bezier curve is determined by four control points.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
14 CTH EDUCATION
Bezier Curve Properties :
It is always contained within a polygon called as convex hull of its control points.
Bezier curve generally follows the shape of its defining polygon.
The degree of the polynomial is one less than the total number of control points.
The order of the polynomial is equal to the total number of control points.
Bezier curves exhibit global control means moving a control point alters the shape of the
whole curve.
Here,
This curve is defined by 4 control points b0, b1, b2 and b3.
The degree of this curve is 3.
So, it is a cubic bezier curve.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
15 CTH EDUCATION
Difference between B-Spline & Bezier curve :
B-Spline Bezier
It specified by Bernstein basis function that It specified with boundary conditions, with a
has limited flexibiity. characterizing with blending function.
These curves are a result of the use of open The curve generally follows the shape of a
uniform basis function. defining polygon.
These curves can be used to construct These are found in painting and drawing
blending curves. packages as well as in CAD applications.
It this, the degree of the resulting curve is The degree of curve segment is one less than
independent of number of vertices. the number of defining polygon point.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
1 CTH EDUCATION
Unit-05 : Window-port and viewport :
Line clipping algorithm –
Sutherland Cohen algorithm,
Mid-point sub-division algorithm,
Polygon Clipping :
Sutherland- Hodgeman algo - Polygon representation,
Inside & outside test of Polygon Filling :
Stack based and queue-based seed fill algorithms
Scan line fill algorithm Character generation
Questions to be discussed :
1. Define windows and viewport.
2. What is clipping ? Explain about curve and area clipping.
3. Define convex and concave polygon.
4. Translate the polygon with co-ordinates A(2, 5), B(7, 10) and C(10, 2) by 3 units in x-direction
and 4 units in y-direction.
5. Write algorithm to clip line using cohen Sutherland line clipping algorithm.
6. Explain about Southerland Hodgeman polygon clipping.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
Window-port and viewport :
Window port is the coordinate area specially selected for the display.
Viewport is the display area of viewport in which the window is perfectly mapped.
Window-port Viewport
It is the area on the world coordinate selected It is the area on the device coordinate where
for display. graphics is to be displayed.
World coordinate is the Cartesian coordinate Device Coordinate is the screen coordinate
w.r.t which we define the diagram, like X wmin, where the objects are to be displayed, like
Xwmax, Ywmin, Ywmax Xvmin, Xvmax, Yvmin, Yvmax
Clipping :
Clipping is the process to identify the picture either inside or outside of the displaying area.
It is used to remove objects, lines, or line segments that are outside of the viewing pane.
When we have to display a large portion of the picture, then visible part of picture is identified.
It may be certain parts of the image are visible, while others are invisible.
For deciding the visible and invisible portion, a particular process is used called clipping.
The lines or elements which are partially visible or invisible will be omitted.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
Types of Clipping :
1. Point Clipping
2. Line Clipping
3. Area Clipping (Polygon)
4. Curve Clipping
5. Text Clipping
Point Clipping :
Assume that the clip window is a rectangle in the standard position we have a point P = (x, y)
for display,
If the following conditions are satisfied :
Xw min ≤ x ≤ Xw max
Yw min ≤ y ≤ Yw max.
If anyone of these four conditions is not satisfied the point is clipped.
Line Clipping :
In line clipping, we will cut the portion of line which is outside of the window and keep only the
portion that is inside the window.
It is performed by using the line clipping algorithm.
The line clipping algorithms are :
1. Cohen Sutherland Line Clipping Algorithm
2. Midpoint Subdivision Line Clipping Algorithm
3. Liang-Barsky Line Clipping Algorithm
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
Introduction to Cohen-Sutherland algorithm :
In this algorithm, we divides a 2D space into 9 regions on the screen.
Out of which one region is of the window and the rest 8 regions are around it.
All regions are represented by 4 binary digits.
The division of the regions are based on (x_max, y_max) and (x_min, y_min).
The central part is the viewing region, all the lines which lie within this region are completely
visible.
A region code is always assigned to the endpoints of the given line.
Cohen-Sutherland algorithm :
Step – 1 : Assign the region codes to both endpoints.
Step – 2 : Perform OR operation on both of these endpoints.
if OR = 0000, then
It is completely visible.
else
Perform AND operation on both these endpoints.
if AND ≠ 0000, then
The line is invisible and it can’t be considered for clipping.
else
AND = 0000, the line is partially inside the window & considered for clipping.
Step – 3 : After confirming that the line is partially inside the window, then we find the
intersection with the boundary of the window. By using the following formula :
Slope : m = (y2-y1)/(x2-x1)
Case - 1 : For left window edge, the intersection point will be(x min , y)
y = y1 + m(xmin – x1)
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
Case - 2 : For right window edge, the intersection point will be(x max , y)
y = y1 + m(xmax – x1)
Case - 3 : For top window edge, the intersection point will be(x , ymax)
1
x = x1 + (ymax – y1)
m
Case - 4 : For left window edge, the intersection point will be(x , y)
1
x = x1 + (ymin – x1)
m
Step – 4 : Now, overwrite the endpoints with a new one and update it.
Step – 5 : Repeat the step-3 till your line doesn’t get completely clipped
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
What is Polygon ?
Polygon is a representation of the surface which is closed in nature.
It is formed using a collection of lines.
It is also called as many-sided figure.
The lines combined to form polygon are called sides or edges.
Example :
1. Triangle
2. Rectangle
3. Hexagon
4. Pentagon
Convex Polygon :
If all the interior angles of a polygon are strictly less than 180° , then the polygon will be
known as a convex polygon.
Concave Polygon :
If one or more interior angles of a polygon are more than 180° degrees, then the polygon will
be known as a concave polygon.
This polygon can have at least four sides.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
Sutherland-Hodgeman Polygon Clipping :
Sutherland Hodgeman polygon clipping algorithm is used for polygon clipping.
In this algorithm, all the vertices of the polygon are clipped.
First clipped against the left edge of the polygon window to get new vertices of the polygon.
These new vertices are used to clip the polygon against right edge, top edge, bottom edge, of the
clipping window as shown in the following figure.
The following figures show left, right, top and bottom edge clippings :
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
Q. If a polygon with co-ordinates A(2,5),B(7,10),C(10,2) is translated 3 units in
x-direction & 4 units in y-direction then the resultant co-ord.of polygon are :
a) A\(5,9), B\(10,14), C\(13,6)
b) A\(2,5), B\(7,10), C\(10,2)
c) A\(9,5), B\(14,10), C\(6,13)
d) A\(5,9), B\(10,14), C\(13,6)
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
1 CTH EDUCATION
Unit-06 : 3D GRAPHICS
Transformation matrices for
translation,
scaling and
rotation around axis
Parallel Projection : Orthographic, Axonometric, Oblique projection with multi views.
Perspective Projection: - Vanishing point: Single – point, Two- point & Three-point
Hidden Surface Removal:
Back face removal
Questions to be discussed :
1. Define 3D translation, rotation and scaling.
2. What is projection? Explain the types of projection?
3. What do you mean by perspective projection?
4. What do you mean by parallel projection?
5. Explain orthographic and oblique projection in details.
6. Differentiate between parallel projection and perspective projection.
7. Explain back-face detection method and depth buffer method in details.
8. Explain in detail the use of area base algorithm for hidden surface elimination.
9. Explain depth sorting method and buffer method in details.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
3-D Transformation:
3-D Transformation is the process of manipulating the view of a 3D object w.r.t its original
position.
It is the process of modifying its physical attributes through various methods of
transformation like Translation, Scaling, Rotation, Shear, etc.
3D Transformations take place in a three dimensional plane.
3D Transformations are important and a bit more complex than 2D Transformations.
In computer graphics, various transformation techniques are :
1. Translation
2. Rotation
3. Scaling
4. Reflection
5. Shear
3D Translation :
3D Translation is a process of moving an object from one position to another in 3D plane.
A 3D Translation process contains the x-axis, y-axis, and z-axis.
We can move any object from one place to another without changing the shape of the object.
We can apply Translation on the following objects :
Line
Rectangle
Polygon
Square
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
3D Rotation :
3D Rotation is a process of rotating an object w.r.t an angle in a 3D plane.
The 3D rotation is different from 2D rotation.
In 3D Rotation we also have to define the angle of Rotation with the axis of Rotation.
3D Scaling :
Scaling is a process of modifying or altering the size of objects.
The 2D and 3D scaling are similar, but the key difference is that the 3D plane also includes the
z-axis along with the x and y-axis.
In scaling, we can expend or compress the size of any object.
We can apply scaling on the object by multiplying the original coordinates with scaling factors.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
What is Projection ?
Projection is a technique or process which is used to transform a 3D object into a 2D plane.
The technique projection was invented by Leonhard Euler Around in 1756.
The "Episcope" was the first projection system.
In other words, we can define "projection as a mapping of points P (x, y, z) on to its image P'
(x,' y', z') in the projection plane or view plane, which create the display surface.”
Types of Projection :
Parallel Projection:
In Parallel Projection, the distance of project plane from the center of projection is infinite.
In parallel Projection, the projection lines are parallel to each other.
The view of Parallel Projection is the less realistic cause of no foreshortening.
The Parallel Projections are good for accurate measurements.
Advantages:
1. Good for exact Measurement
2. Parallel lines remain parallel
Disadvantages:
1. Less Realistic Looking
2. Angles are not preserved
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
Types of Parallel Projection :
There are two kind of parallel Projection:
1. Orthographic projection
2. Oblique projection
Orthographic projection :
In the Orthographic Parallel Projection, the Projection is perpendicular to the view plane.
The Orthographic Projection is divided into two parts :
1. Multiview orthographic projection
2. Axonometric orthographic projection
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
Oblique Projection:
In this, the direction of projection is not normal to projection of plane.
It is a simple technique that is used to construct two-dimensional images of 3D objects.
The Oblique Projection is mostly used in technical drawing.
The Oblique Projection is divided into two parts :
1. Cavalier
2. Cabinet
Cavalier:
In cavalier Projection, there is an angle between the Projection and Projection Plane is 45
degrees.
Cabinet:
In Cabinet Projection, there is an angle between Projection and Projection Plane is 63.4
degrees.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
Perspective Projection :
In perspective projection, the distance of project plane from the center of projection is finite.
In Perspective Projection, it is difficult to define the actual size and shape of the object.
The Perspective Projection has the concept of vanishing points.
The Perspective Projection is realistic but tough to implement.
Perspective projection is used to determine the projector lines come together at a single point.
The single point is also called "project reference point" or "Center of projection".
Advantages:
1. Better Look
2. Clear Representation
Disadvantages:
1. Difficult to Draw
2. Not Suitable for many-dimensional images
Vanishing Point:
Vanishing point can be defined as a point in image plane where all parallel lines are
interlinked.
The Vanishing point is also called “Directing Point.”
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
One Point :
A One Point perspective contains only one vanishing point on the horizon line.
It is easy to draw.
The One Point projection is used to draw the images of roads, railway tracks, & buildings.
Two Point :
It is also called "Angular Perspective".
A Two Point perspective contains two vanishing points on the line.
The main use of Two Point projection is to draw the two corner roads.
Three-Point :
The Three-Point Perspective contains three vanishing points.
Two points lie on the horizon line, and one above or below the line.
It is very difficult to draw.
When we see an object from above, than the third point is below the ground.
If we see an object from the below, than the third point is in the space above.
It is mainly used in skyscraping.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
9 CTH EDUCATION
It does not form realistic view of object. It forms a realistic view of object.
It can give the accurate view of object. It cannot give the accurate view of object.
The lines of parallel projection are parallel. The lines of perspective projection are not ll.
In parallel projection, these effects are not Here, objects that are far away appear
created. smaller & objects that are near appear bigger.
The distance of the object from the center of The distance of the object from the center of
projection is infinite. projection is finite.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
1 CTH EDUCATION
Unit – 07 : ANIMATION
Basics of animation,
Types of animation,
Types of animation system.
Tweaking and Morphing
Questions to be discussed :
1. What do you mean by animation ?
2. What are different kinds of animation techniques used in graphics system.
3. Explain different types of animation system in computer graphics.
4. Define aliasing and anti-aliasing.
5. Differentiate between the Simulation and animation.
6. What do you mean by tweaking and morphing explain in brief.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
What is animation ?
An animation is a technique of building progressive image and running it in a sequence to
create an effect of motion.
It contains a series of rapidly changing objects which gives the illusion of movement.
The image are called frames.
These frames are rapidly moved in front of human eye and this is look like as the motion.
In animation, the speed of each object is replaced by next, so the eye receive this as motion.
Because our eyes can only retain an image for approx 1/10 of a second, when multiple images
appear in fast succession, the brain blends them into a single moving image.
Early cartoons are examples of this, but today, most animated movies are made with computer.
The term animation is derived from the Latin word "anima" which means the soul.
Animators create the art of animation.
J. Stuart Blackton made the first animated film in 1906.
Computer animation is the process used for digitally generating animated images.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
Types of Animation:
1. Traditional Animation
2. 2D Animation (Vector-based)
3. 3D Animation
4. Motion Graphics
5. Stop Motion
Traditional(Cel) :
This is one of the oldest forms of animation in film.
It is also known as cel animation.
In traditional animation, objects are drawn on transparent paper.
Traditional is most often 2D animation.
2D Animation :
2D animation can fall under traditional animation.
It is also known as Vector-based animation that can be 2D without being traditional.
Here, the motion can be controlled by vectors rather than pixels.
Images with familiar formats like JPG, GIF, BMP, are pixel images.
These images cannot be enlarged or shrunk without affecting image quality.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
3D Animation :
Now a days, the most common type of computer animation is 3D.
In 3D animated movies, the animator uses a program to move the character.
They set their digital frames when all of the parts of the character are in the right position.
They do this for each frame, and the computer calculates the motion from each frame.
Motion Graphics :
Motion Graphics are pieces are digital graphics that create the illusion of motion usually for
ads, title sequences in films.
It is used to communicate something to the viewer.
They’re often combined with sound for multimedia projects.
They’re a type of animation used mostly in business, usually with text as a main player.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
Stop Motion :
It is an animated film making technique in which objects are physically manipulated in small
increments between individually photographed.
In stop motion object will appear to exhibit independent motion or change when the series of
frames is played back.
If moved in small increments, captured one frame at a time, the illusion of motion is
produced.
Stop motion is definitely an older form of animated storytelling, especially compared to 3D
computer animation.
Scripting Systems :
Scripting Systems were the oldest type of motion control systems.
The animator writes a script in the animation language.
One scripting system is ASAS (Actor Script Animation Language).
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
Procedural Animation :
Here, procedures are used to define movement over time.
An example is a motion that is the result of some other action.
Example : throwing a ball which hits another object and causes the second object to move.
Representational Animation :
This technique allows an object to change its shape during the animation.
Stochastic Animation :
This uses stochastic processes to control groups of objects, such as in particle systems.
Examples are fireworks, fire, water falls, etc.
Behavioural Animation :
Objects or "actors" are given rules about how they react to their environment.
Examples are schools of fish or flocks of birds where each individual behaves according to a set
of rules defined by the animator.
It can change the colors and location of an Morphing can change the face to another one
object. in blink of eye.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
Aliasing :
It is the visual stair-stepping of edges that occurs in an image when the resolution is too low.
Aliasing occurs when real-world objects which comprise of smooth.
The aliasing effect is the appearance of jagged edges.
The problem of jagged edges technically occurs due to distortion of the image when scan
conversion is done with sampling at a low frequency, which is also known as Undersampling.
Anti-aliasing :
Anti-aliasing is the smoothing of jagged edges in digital images by averaging the colors of the
pixels at a boundary.
Antialiasing is a technique used in computer graphics to remove the aliasing effect.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
Simulation :
Simulation is an imitation or replication from the real thing.
It is the representation of specific behavior of a selected system.
It is used in safety engineering, teaching, testing and video games.
Simulation is also used in scientific modeling for getting information about their working.
Simulation is a mathematical model and it does not need a picture.
It can be completely mathematical.
Even if simulation is done in a cartoon, it is based on mathematical model including every
aspect like background motion, human body motion, camera etc.
All the movements are assessed with accuracy in simulation while in animation the artists have
to just create sequence of any frame.
Simulation Animation
Simulation refers to creating replicas from Animation is the method of creating an illusion
the real version. of any movement by using rapid display images.
Simulation is also used in scientific modeling Animation can be also used on simulation.
for getting information about their working.
All the movements are assessed with In animation the artists have to just create
accuracy in simulation. sequence of any frame.
Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)