Computer Graphics is an advance field in information technology and all about manipulation and rendering of images. This presentation covers all the main concepts in computer graphics including graphics algorithms.
2. Introduction:
• Computer Graphics involves technology to access. The Process transforms and presents
information in a visual form. The role of computer graphics insensible. In today life, computer
graphics has now become a common element in user interfaces, T.V. commercial motion pictures.
• Computer Graphics is the creation of pictures with the help of a computer. The end product of the
computer graphics is a picture it may be a business graph, drawing, and engineering.
• In computer graphics, two or three-dimensional pictures can be created that are used for
research. Many hardware devices algorithm has been developing for improving the speed of
picture generation with the passes of time. It includes the creation storage of models and image
of objects. These models for various fields like engineering, mathematical and so on.
• Today computer graphics is entirely different from the earlier one. It is not possible. It is an
interactive user can control the structure of an object of various input devices.
3. Application:
• Education & Training
• Flight simulator
• Computational biology
• Computer generated maps
• Architect
• Presentation
• Computer art
• Entertainment
• Visualization
• printing technology
4. Types of CG:
• Non-interactive/passive graphics: user has no control over generated
graphics. In simple words, read only graphics are non-interactive
because user is unable to interact with like titles in TV. It is one way
communication. User cannot make changes in the available
resources.
• Interactive 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.
6. Display technologies:
• Shadow mark technology: also known as shadow X-ray or silhouette
X-ray, relies on the principle of image contrast. When an object is
placed between an X-ray source and a detector, the X-rays are
attenuated or blocked by the object, resulting in a shadow or
silhouette image(image void of internal details) on the detector. This
technique is commonly used for two-dimensional (2D) X-ray
inspection. 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.
7. Cont.
• Beam penetration technology: Beam penetration technology, also
known as penetrating X-ray or transmission X-ray, is based on the
principle of X-ray penetration through materials. This technique is
typically used for three-dimensional (3D) X-ray inspection. The Beam-
Penetration method has been used with random-scan monitors. In
this method, the CRT screen is coated with two layers of phosphor,
red and green and the displayed color depends on how far the
electron beam penetrates the phosphor layers. This method produces
four colors only, red, green, orange and yellow. A beam of slow
electrons excites the outer red layer only; hence screen shows red
color only. A beam of high-speed electrons excites the inner green
layer. Thus screen shows a green color. Only 4 colors are possible.
8. Direct view storage tubes:
• A Display Storage Tube (DST), also known as a Storage Tube or a Storage
Oscilloscope, is a specialized type of cathode ray tube (CRT) used in
electronic display systems. It was primarily used in older computer
terminals and oscilloscopes.
• The Display Storage Tube functions as a combination of a regular CRT and a
temporary storage medium. It allows the persistent display of an image
even after the original signal has been removed. This is accomplished by
introducing a phosphor coating on the screen that can retain the image for
an extended period, typically several minutes or longer.
• It is not possible to erase specific part of image.
• Not suitable for dynamic display devices.
• Slow processing rate but cheap.
9. Working:
• Electron Beam Scanning: Similar to a regular CRT, a Display
Storage Tube consists of an electron gun that emits an electron
beam. The beam is focused and accelerated towards the screen,
which is coated with a phosphor material.
• Phosphor Coating: The phosphor coating on the Display Storage
Tube screen is designed to have a longer persistence than the
phosphor used in regular CRTs. This allows the image to remain
visible for an extended period after the electron beam has
passed.
• Writing and Erasing: When an electrical signal is applied to the
electron beam, it scans across the screen, exciting the phosphor
and causing it to emit light. This creates the visible image. The
phosphor coating retains the charge and continues to emit light
even after the beam has moved to another location.
• Image Persistence: The stored image on the Display Storage Tube
screen remains visible until it is erased. Erasing is usually done by
either applying a blanking signal to the electron beam or by
flooding the screen with an intense light source that dissipates
the stored charge.
10. Flat Panel display:
• The Flat-Panel display refers to a class of video devices that
have reduced volume, weight and power requirement compared
to CRT.
• Example: Small T.V. monitor, calculator, pocket video games,
laptop computers, an advertisement board in elevator.
11. Cont.
• Emissive Display: The emissive displays are devices that
convert electrical energy into light. Examples are Plasma Panel,
thin film electroluminescent display and LED (Light Emitting
Diodes).
• Non-Emissive Display: The Non-Emissive displays use optical
effects to convert sunlight or light from some other source into
graphics patterns. Examples are LCD (Liquid Crystal Device).
12. Basic terminology:
• Pixel: smallest point in display
• Resolution: total number of pixel in picture or screen
Resolution = Width X Height
Width = number of horizontal pixels
Height = number of vertical pixels
• Pixel per inch (PPI): number of pixel per inch computed from diagonal distance
• Aspect ratio: ratio of height and width commonly 4:3
• Frame buffer: storage area used to display graphics content (picture, image)
• Persistence: Amount of time a frame takes to be displayed before refreshing.
13. Illustration:
Width = 1920
Height = 1080
Resolution = 1920 x 1080
PPI =√ a2 + b2
= √ 19202 + 10802
√ 3686400 + 1166400
= 2202/5 inch
= 440 PPI
15. Cathode ray tube:
• A cathode ray tube (CRT) is a specialized vacuum tube in which
images are produced when an electron beam strikes a
phosphorescent surface. It modulates, accelerates, and deflects
electron beam(s) onto the screen to create the images. Most desktop
computer displays make use of CRT for image-displaying purposes.
16. Working:
Electron Beam Generation:
Inside the CRT, an electron gun emits a focused beam of electrons. The electron gun consists
of a cathode that emits electrons and an anode that accelerates and focuses the electrons
into a narrow beam.
Deflection:
The electron beam is then deflected by electromagnetic coils or plates located around the
neck of the CRT. These electromagnetic fields steer the beam horizontally and vertically,
allowing it to scan across the entire screen.
Phosphor-Coated Screen:
The front of the CRT screen is coated with a layer of phosphors. Phosphors are chemical
compounds that emit light when struck by electrons. Different phosphors can emit different
colors of light.
Pixel Intensity Control:
The pixel intensity is controlled by modulating the strength of the electron beam. A higher
intensity results in a brighter pixel, while a lower intensity results in a dimmer pixel.
17. Cont.
Scanning the Screen:
The electron beam scans the screen line by line, starting from the top left
corner and moving horizontally across each line. As the beam moves, it emits
electrons that strike the phosphor-coated screen.
Light Emission:
When the electron beam hits the phosphor-coated screen, the phosphors
emit light in response to the energy transferred by the electrons. The
emitted light corresponds to the color of the phosphor and the intensity of
the electron beam.
Persistence:
Phosphors have a property called persistence, which means they continue to
emit light for a short period even after the electron beam has moved away.
This persistence helps maintain the image on the screen until the next scan.
19. Scanning techniques
There are different strategies followed by different system.
1) Vector/Random scan display
2) Raster scan display
20. Vector/random scan display:
• In Random-Scan Display electron beam is directed only to the areas of
screen where a picture has to be drawn. It is also called vector display, as it
draws picture one line at time. It can draw and refresh component lines of
a picture in any specified sequence. Pen plotter is an example of random-
scan displays.
• The number of lines regulates refresh rate on random-scan displays. An
area of memory called refresh display files stores picture definition as a set
of line drawing commands. The system returns back to first-line command
in the list, after all the drawing commands have been processed. High-
quality vector systems can handle around 100, 00 short lines at this refresh
rate. Faster refreshing can burn phosphor. To avoid this every refresh cycle
is delayed to prevent refresh rate greater than 60 frames per second.
21. Cont.
ADVANTAGES:
• Higher resolution as compared to raster scan display.
• Produces smooth line drawing.
• Less Memory required.
DISADVANTAGES:
• Realistic images with different shades cannot be drawn.
• Color limitations.
22.
23. Raster scan display:
• Raster Scan Displays are most common type of graphics monitor which employs CRT. It
is based on television technology. In raster scan system electron beam sweeps across
the screen, from top to bottom covering one row at a time. A pattern of illuminated
pattern of spots is created by turning beam intensity on and off as it moves across
each row. A memory area called refresh buffer or frame buffer stores picture
definition. This memory area holds intensity values for all screen points. Stored
intensity values are restored from frame buffer and painted on screen taking one row
at a time. Each screen point is referred to as pixels.
• In raster scan systems refreshing is done at a rate of 60-80 frames per second. Refresh
rates are also sometimes described in units of cycles per second / Hertz (Hz). At the
end of each scan line, electron beam begins to display next scan line after returning to
left side of screen. The return to the left of screen after refresh of each scan line is
known as horizontal retrace of electron beam. At the end of each frame electron
beam returns to top left corner and begins the next frame.
24.
25. Cont.
ADVANTAGES:
• Real life images with different shades can be displayed.
• Color range available is bigger than random scan display.
DISADVANTAGES:
• Resolution is lower than random scan display.
• More memory is required.
• Data about the intensities of all pixel has to be stored.
26. Interlaced scan display:
Interlaced scan is a display technique where the image is split
into two fields, displaying odd-numbered lines in one pass
(called the odd field) and even-numbered lines in the next pass
(called the even field). The screen is scanned in an alternating
pattern, filling in the missing lines with each pass. Interlaced
scan was more prevalent in older display technologies like CRT
televisions and some computer monitors. While it requires
fewer video resources, interlaced scan can sometimes result in
flickering and reduced image quality, especially with fast-
moving content.
27. Progressive scan display:
• Progressive scan display is a way of showing images on a screen in a
smooth and continuous manner. It works by displaying all the lines of
an image one after another, from top to bottom, in a sequence. This
happens very quickly, with each line appearing so fast that our eyes
perceive it as a complete image.
• Imagine you're drawing a picture by filling it in line by line. With
progressive scan, you start at the top of the picture and draw each
line until you reach the bottom. This method ensures that the entire
image is displayed at once, creating a clear and seamless picture.
29. Digital differential analyzer:
• DDA (Digital Differential Analyzer) is a line drawing algorithm used in
computer graphics to generate a line segment between two specified
endpoints. It is a simple and efficient algorithm that works by using
the incremental difference between the x-coordinates and y-
coordinates of the two endpoints to plot the line.
35. Algorithm:
• Input the two endpoints of the line segment, (x1,y1) and (x2,y2).
• Calculate the difference between the x-coordinates and y-coordinates
of the endpoints as dx and dy respectively.
• Calculate the slope of the line as m = dy/dx.
• Set the initial point of the line as (x1,y1).
• Loop through the x-coordinates of the line, incrementing by one each
time, and calculate the corresponding y-coordinate using the
equation y = y1 + m(x – x1).
• Plot the pixel at the calculated (x,y) coordinate.
• Repeat steps 5 and 6 until the endpoint (x2,y2) is reached.
36. The line of equation for step i
yi=mxi+b......................equation 1
Next value will be
m = y2-y1 / x2 – x1 => ∆y / ∆x
We can also extract ∆x and ∆y from above equation
∆y=m∆x
∆x=∆y/m
37. Rules:
Case1: When |∆x| >= |∆y|
Then: Assign ∆x = 1
Xi+1 = xi + ∆x = xi + 1
yi+1 = yi + ∆y = yi + m ∆x = yi + m
Case2: When |∆x| < |∆y|
Then: Assign ∆y = 1
yi+1 = yi + ∆y = yi + 1
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m
46. Solution:
Draw a line from (3,1) to (5,7)
X1 = 3, y1 = 1 & x2 =5, y2 = 7
m = y2-y1 / x2 – x1 => ∆y / ∆x = 7 – 1/ 5 – 3 = 6/2 = 3
Find ∆x & ∆y:
∆y=m∆x = 3 X 2 = 6
∆x=∆y/m = 6/3 = 2
47. Cont.
xi yi xi+1 Yi+1
3 1
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 1 + 1 = 2
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 3 + 1/3 = 3.3
1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
48. Cont.
xi yi xi+1 Yi+1
3 1 3.3 2
3.3 2
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 1 + 1 = 2
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 3 + 1/3 = 3.3
1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
*
49. Cont.
xi yi xi+1 Yi+1
3 1 3.3 2
3.3 2 3.8 3
3.8 3
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 2 + 1 = 3
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 3.5 + 0.3 = 3.8
1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
*
*
50. Cont.
xi yi xi+1 Yi+1
3 1 3.3 2
3.3 2 3.8 3
3.8 3 4.1 4
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 3 + 1 = 4
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 3.8 + 0.3 = 4.1
1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
*
*
*
51. Cont.
xi yi xi+1 Yi+1
3 1 3.3 2
3.3 2 3.8 3
3.8 3 4.1 4
4 4.1 4.4 5
4.4 5
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 4 + 1 = 5
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 4.1 + 0.3 = 4.4
1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
*
*
*
*
52. Cont.
xi yi xi+1 Yi+1
3 1 3.3 2
3.3 2 3.8 3
3.8 3 4.1 4
4 4.1 4.4 5
4.4 5 4.7 6
4.7 6 5 7
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 6 + 1 = 7
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 4.7 + 0.3 = 5
1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
*
*
*
*
*
53. Cont.
xi yi xi+1 Yi+1
3 1 3.3 2
3.3 2 3.8 3
3.8 3 4.1 4
4 4.1 4.4 5
4.4 5 4.7 6
4.7 6 5 7
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 6 + 1 = 7
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 4.7 + 0.3 = 5
1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
*
*
*
*
*
*
54. Cont.
xi yi xi+1 Yi+1
3 1 3.3 2
3.3 2 3.8 3
3.8 3 4.1 4
4 4.1 4.4 5
4.4 5 4.7 6
4.7 6 5 7
Xi, yi = current value , xi+1, yi+1 = next computed value
m = 3
∆x =2 , ∆y = 6
|∆x| < |∆y| (Case#02) 2 = 2
∆y = 1
yi+1 = yi + ∆y = yi + 1 = 6 + 1 = 7
xi+1 = xi + ∆x = xi + ∆y / m = xi + 1/m = 4.7 + 0.3 = 5
Done!! 1 2 3 4 5 6 7
3
2
1
0
4
5
6
7
*
*
*
*
*
*
*
55. Bresenhams’ algorithm:
• The problem with DDA algorithm is that it considers float values
which require extra computation and straight line is not achieved
properly. But bresenham algorithm takes maximum distance b/w two
pixels and generates a smooth and straight line.
56.
57.
58.
59. Algorithm:
1. Compute slop of line ‘m’, ∆x = dy, ∆y = dy, pk = 2dy - dx
2. If m<1:
if p<0:
xi+1 = xi + 1
yi+1 = yi
pk+1 = pk + 2dy
if p>=0:
xi+1 = xi+1
yi+1 = yi+1
pk+1 = pk + 2dy – 2dx
60. Cont.
If m>=1:
if p<0:
xi+1 = xi
yi+1 = yi+1
pk+1 = pk + 2dx
if p>=0:
xi+1 = xi+1
yi+1 = yi+1
pk+1 = pk + 2dx – 2dy
69. Bresenham circle drawing algorithm:
• We only need to compute one slice b/w 90 and 45 degree. All other
values will be computed by just mirroring and swapping x and y co-
ordinate.
70. Algorithm:
1. Compute x0 = starting point, y0 = radius = r
2. Compute decision parameter(P):
p = 3 – 2*R
3. If p<0:
xi+1 = xi + 1
yi+1 = yi
pi+1 = pi + 4xi+1 + 6
If p>=0:
xi+1 = xi + 1
yi+1 = yi - 1
pi+1 = pi + 4(xi+1 – yi+1) + 10
71. Example:
• Generate a circle from origin (0,0) with r = 8.
X0 = 0
Y0 = r = 8
• Calculate the value of initial decision parameter P0 as-
P0 = 3 – 2 x R
P0 = 3 – 2 x 8
P0 = -13
72. Cont.
• As Pinitial < 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-03 is executed similarly until Xk+1 >= Yk+1
Algorithm calculates all the points of octant-1 and terminates!!
73. Cont.
• Just take mirror of upper slice of one quadrant. Change the signs in
another quadrant accordingly.
75. Practice:
• Given the center point coordinates (10, 10) and radius as 10,
generate all the points to form a circle.
• Hint: Don’t apply hint here because origin is not (0,0)
76. Solution:
Step-01:
Assign the starting point coordinates (X0, Y0) as-
X0 = 0
Y0 = R = 10
Step-02:
Calculate the value of initial decision parameter P0 as-
P0 = 3 – 2 x R
P0 = 3 – 2 x 10
P0 = -17
77. Cont.
Step-03:
As Pinitial < 0, so case-01 is satisfied.
Thus,
Xk+1 = Xk + 1 = 0 + 1 = 1
Yk+1 = Yk = 10
Pk+1 = Pk + 4 x Xk+1 + 6 = -17 + (4 x 1) + 6 = -7
Step-04:
This step is applicable here as the given centre point coordinates is
(10, 10).
Xplot = Xc + X0 = 1 + 10 = 11
Yplot = Yc + Y0 = 10 + 10 = 20
78. Cont.
• Step-03 and Step-04 are executed similarly until Xplot => Yplot as
follows-
86. Problem-2:
• Given the center point coordinates (4, -4) and radius as 10,
generate all the points to form a circle.
87. Solution:
• As the origin is other than (0,0), we find co-ordinates by assuming
center as (0,0). After computing, we will add the points.
• Just add 4 in every point
• If quadrant is negative like 2nd one, then subtract
original value from 4.
For example, in 1st row, 4 – 0 = 0 then (4, 14) are
the points of 1st row.
90. Polygon:
• Shape having more than two points connected with each other. Line
segment which forms the boundary of polygon is known as edge
which end sides are vertices. It can be of any shape.
92. Simple polygon:
• Polygon having shape such that no line intersect other.
Not simple due to
intersecting lines
Simple
93. Complex polygon:
• Opposite of simple polygon.
• Shape having lines intersecting other (at least one)
Complex
94. Convex polygon:
• Such shape in which if we take any points which are surely inside the
polygon and if we draw a line joining these points and if all the points
lie inside the polygon, then such a polygon is convex. All the angles of
edges must be less then 180 degree.
95. Concave polygon:
• Such polygon in which if we take two points which are surely inside
the polygon and if we draw a line joining these points and if all the
points are not lying inside the polygon, then such a polygon is
concave polygon. Angle of edges > 180 (at least one)
96. Inside test of polygon:
• It is very important to know if a point is inside or outside the polygon
before starting to fill the polygon. Draw a horizontal line from point
left or right which is required to determined inside, if number of
points intersected by line are even, it is outside the polygon. If odd, it
is inside. There are two rare cases also need to consider discussed
next.
Odd – inside
Even - outside
97. Example:
• Let below point is need to determine whether it is inside or outside
the polygon.
• 1- put the point where required to determine.
98. Cont.
• Draw a horizontal line from point to left or right. Count number of
points intersected by line. In this case, total points are 3. So, point is
inside the polygon.
99. Cont.
• Let check another point in the same shape.
Number of intersected
points are 2(even). So, its
outside the polygon.
100. Issue with inside test method:
• Consider the point g which is outside the polygon, by checking via
algorithm, number of points intersected are 1 or 2??
101. Solution:
• Add extra step in the algorithm that if line is passed from such point
connected two or more line, check whether all the joined lines are
not same side of the or one above and one below or one left and one
right.
• If lines connected with intersected point are on the same side,
consider point as odd otherwise even.
Same side – even
Different side – odd
• Now apply this scheme on previous diagram.
103. Solution:
• As 1st intersected point joins two lines which are on the same side of
point-3, so considering it as even let say 2 and one more point is
intersecting. Total is 3, hence it is inside the polygon.
104. Winding number method:
• Draw a horizontal line on left or right side of point
• Traverse whole shape anti-clockwise and assign +1 if
direction is bottom to top otherwise -1.
• Find the sum of vertices from which point line is passing.
• If sum is non-zero, it is inside the shape otherwise it is outside.
105. Example:
• Consider the point ‘p’ in the diagram
• Sum = (-1) + (1) + (-1) + (1) = 0 (outside the shape)
107. 4-connected algorithm:
• Initially we need to check boundary color not be same to the color
which is filled in the shape and that color is not already filled inside
the boundary.
109. 8-connected vs 4-
connected:
• 4-connected algorithm fails to fill the
below shape which is filled by 8-
connected algorithm properly.
110. Limitations of boundary fill algorithm:
• We are restricted to the different color from boundary.
• Boundary color must be one.
111. Flood fill/seed fill algorithm:
This algorithm works if boundary pixels have different color. It checks
if old color (color inside the boundary) is the color or targeted pixel,
change color.
Limitation: If more than one color exist inside boundary, this
algorithm will fail.
Solution: Use a data structure containing list of old colors exist inside
the boundary and check. This method can be slow.
112. Implementation:
G G B B
G G B
G B B
R R
B R
B B R R R
R R
R
Old Color = White
New color = Yellow
113. Implementation:
G G B B
G G B
G B B
R R
B R
B B R R R
R R
R
Visit 8-neighbours
White != Green
150. Coherence property:
• There can be such a shape where we have to pass through same edge
again and again, we can save time by saving the sorted pairs.
• m = y2 – y1 / x2 – x1
• y2 is always 1 in this algorithm. For example, we have visited from top
to bottom in a scan line with a different in y-axis as 1. y12 to y11 to y10
… y So, Δy is always one. Let x1 = xk and x2 = xk+1
• m = 1/ Δx = 1/xk+1 – xk
• Xk+1 = 1/m + xk
152. 2D operations:
• It is the straight-line movement of an object from one position to
another is called Translation.
• Possible operations:
• Translation
• Rotation
• Scaling
• Shear
• Reflection
153. Translation:
• To translate a point from coordinate position (x, y) to another
(x’, y’), we add algebraically the translation distances Tx and
Ty to original coordinate.
x’=x+Tx
y’=y+Ty (x’, y’)
(x, y)
Translated position
154. Problem-1:
• 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.
155. Solution: Applying the translation equations, we
have-
Xnew = Xold + Tx = 1 + 5 = 6
Ynew = Yold + Ty = 4 + 1 = 5
Thus, New center coordinates of C = (6, 5).
156. Problem-2:
• 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.
158. 2D Scaling:
• Scaling is a process of modifying or altering the size of objects.
• Scaling may be used to increase or reduce the size of object.
• Scaling subjects the coordinate points of the original object to
change.
• Scaling factor determines whether the object size is to be increased
or reduced.
• If scaling factor > 1, then the object size is increased.
• If scaling factor < 1, then the object size is reduced.
159. Cont.
• Let-
• Initial coordinates of the object O = (Xold, Yold)
Scaling factor for X-axis = Sx
Scaling factor for Y-axis = Sy
• New coordinates of the object O after scaling = (Xnew, Ynew)
• This scaling is achieved by using the following scaling equations-
Xnew = Xold x Sx
Ynew = Yold x Sy
160. Cont.
• Why we take 2x2 matrix in case of scaling while 2x1 in case of
translation??
• If we take 2x1 matrix, both values of scaling will be added in both new
coordinates. Putting zero will avoid this and adds Sx to new x-axis and
Sy to new y-axis.
161. Problem-1:
• Given 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.
162. Solution:
• For A(0,3):
Xnew = Xold x Sx = 0 x 2 = 0
Ynew = Yold x Sy = 3 x 3 = 9
• For B(3,3):
Xnew = Xold x Sx = 3 x 2 = 6
Ynew = Yold x Sy = 3 x 3 = 9
• For C(3,0):
Xnew = Xold x Sx = 3 x 2 = 6
Ynew = Yold x Sy = 0 x 3 = 0
• For D(0,0):
Xnew = Xold x Sx = 0 x 2 = 0
Ynew = Yold x Sy = 0 x 3 = 0
163. Rotation:
• 2D Rotation is a process of rotating an object with respect to an angle
in a two-dimensional plane.
Consider a point object O has to be rotated from one angle to
another in a 2D plane.
Let-
Initial coordinates of the object O = (Xold, Yold)
Initial angle of the object O with respect to origin = Φ
Rotation angle = θ
New coordinates of the object O after rotation = (Xnew, Ynew)
165. Formula:
Xnew = Xold x cosθ – Yold x sinθ
Ynew = Xold x sinθ + Yold x cosθ
+
-
For anti-clockwise rotation:
For clockwise rotation:
166. Problem-1:
• Given a line segment with starting point as (0, 0) and ending
point as (4, 4). Apply 30degree rotation anticlockwise direction
on the line segment and find out the new coordinates of the line.
168. Problem-2:
• Given a triangle with corner coordinates (0, 0), (1, 0) and (1, 1).
Rotate the triangle by 90degree anticlockwise direction and find
out the new coordinates.
169. Solution:
• For A =(0,0):
Xnew= Xold x cosθ – Yold x sinθ = 0 x cos90º – 0 x sin90º = 0
Ynew= Xold x sinθ + Yold x cosθ = 0 x sin90º + 0 x cos90º = 0
• For B(1,0):
Xnew= Xold x cosθ – Yold x sinθ= 1 x cos90º – 0 x sin90º= 0
Ynew= Xold x sinθ + Yold x cosθ= 1 x sin90º + 0 x cos90º= 1 + 0=
1
• For C(1,1):
Xnew= Xold x cosθ – Yold x sinθ= 1 x cos90º – 1 x sin90º= 0 –
1= -1
170. Shear:
• Shearing is an ideal technique to change the shape of an existing object. There are two
versions of shearing:
• Shearing in x-axis:
Xnew = Xold + Shx x Yold
Ynew = Yold
• Shearing in y-axis:
Xnew = Xold
Ynew = Yold + Shy x Xold
172. Problem-1:
• Given a triangle with points (1, 1), (0, 0) and (1, 0). Apply shear
parameter 2 on X axis and 2 on Y axis and find out the new
coordinates of the object.
173. Solution:
Shearing along x-axis:
• For A(1,1):
Xnew = Xold + Shx x Yold = 1 + 2 x 1 = 3
Ynew = Yold = 1
• For B(0,0):
Xnew = Xold + Shx x Yold = 0 + 2 x 0 = 0
Ynew = Yold = 0
• For C(1,0):
Xnew = Xold + Shx x Yold = 1 + 2 x 0 = 1
Ynew = Yold = 0
174. Cont.
Shearing along y-axis:
• For A(1,1):
Xnew = Xold = 1
Ynew = Yold + Shy x Xold = 1 + 2 x 1 = 3
• For B(0,0):
Xnew = Xold = 0
Ynew = Yold + Shy x Xold = 0 + 2 x 0 = 0
• For C(1,0):
Xnew = Xold = 1
Ynew = Yold + Shy x Xold = 0 + 2 x 1 = 2
176. Reflection:
• Reflection is a kind of rotation where the angle of rotation is 180.
• The reflected object is always formed on the other side of the mirror.
• The size of reflected object is same as the size of original object.
• Reflection along x-axis:
Xnew = Xold
Ynew = -Yold
• Reflection along y-axis:
Xnew = -Xold
Ynew = Yold
178. Problem-1:
• Given a triangle with coordinate points A(3, 4), B(6, 4), C(5, 6).
Apply the reflection on the X axis Y axis and obtain the new
coordinates of the object.
182. Homogeneous co-ordinate system for
composite transformation:
• If we must apply set of operations one after another, it is difficult to
compute separately one by one using previously discussed methods.
Those methods are suitable where only single operation is required.
• For example, rotation of straight line or any other shape is achieved
by first moving object towards rotation (translation), perform rotation
and then move object to the old origin (translation). So, three
operations are required to compute which are translation, rotation
and then again translation.
• In order to save time, we can just multiply three matrices of required
task and multiplied by original object coordinate matrix.
186. Translation:
Xnew = Xold + Tx (This denotes translation towards X axis)
Ynew = Yold + Ty (This denotes translation towards Y axis)
Znew = Zold + Tz (This denotes translation towards Z axis)
• Matrix representation:
187. Problem-1:
• Given a 3D object with coordinate points A(0, 3, 1), B(3, 3, 2),
C(3, 0, 0), D(0, 0, 0). Apply the translation with the distance 1
towards X axis, 1 towards Y axis and 2 towards Z axis and
obtain the new coordinates of the object.
193. Mathematical representation:
• This scaling is achieved by using the following scaling
equations-
Xnew = Xold x Sx
Ynew = Yold x Sy
Znew = Zold x Sz
• Matrix representation:
194. Problem-1:
• Given a 3D object with coordinate points A(0, 3, 3), B(3, 3, 6),
C(3, 0, 1), D(0, 0, 0). Apply the scaling parameter 2 towards X
axis, 3 towards Y axis and 3 towards Z axis and obtain the new
coordinates of the object.
195. Solution:
• For A(0,3,3):
Xnew = Xold x Sx = 0 x 2 = 0
Ynew = Yold x Sy = 3 x 3 = 9
Znew = Zold x Sz = 3 x 3 = 9
• For B(3,3,6):
Xnew = Xold x Sx = 3 x 2 = 6
Ynew = Yold x Sy = 3 x 3 = 9
Znew = Zold x Sz = 6 x 3 = 18
• For C(3,0,1):
Xnew = Xold x Sx = 3 x 2 = 6
Ynew = Yold x Sy = 0 x 3 = 0
Znew = Zold x Sz = 1 x 3 = 3
• For D(0,0,0):
Xnew = Xold x Sx = 0 x 2 = 0
Ynew = Yold x Sy = 0 x 3 = 0
Znew = Zold x Sz = 0 x 3 = 0
196. Shearing:
• Shearing in X axis is achieved by using the following shearing equations-
Xnew = Xold
Ynew = Yold + Shy x Xold
Znew = Zold + Shz x Xold
• Shearing in Y axis is achieved by using the following shearing equations-
Xnew = Xold + Shx x Yold
Ynew = Yold
Znew = Zold + Shz x Yold
• Shearing in Z axis is achieved by using the following shearing equations-
Xnew = Xold + Shx x Zold
Ynew = Yold + Shy x Zold
Znew = Zold
197. Problem-1:
• Given a 3D triangle with points (0, 0, 0), (1, 1, 2) and (1, 1, 3).
Apply shear parameter 2 on X axis, 2 on Y axis and 3 on Z axis
and find out the new coordinates of the object.
198. Solution:
Shearing along x-axis:
• For A(0,0,0):
Xnew = Xold = 0
Ynew = Yold + Shy x Xold = 0 + 2 x 0 = 0
Znew = Zold + Shz x Xold = 0 + 3 x 0 = 0
• For B(1,1,2):
Xnew = Xold = 1
Ynew = Yold + Shy x Xold = 1 + 2 x 1 = 3
Znew = Zold + Shz x Xold = 2 + 3 x 1 = 5
• For C(1,1,3):
Xnew = Xold = 1
Ynew = Yold + Shy x Xold = 1 + 2 x 1 = 3
Znew = Zold + Shz x Xold = 3 + 3 x 1 = 6
199. Cont.
Shearing along y-axis:
• For A(0,0,0):
Xnew = Xold + Shx x Yold = 0 + 2 x 0 = 0
Ynew = Yold = 0
Znew = Zold + Shz x Yold = 0 + 3 x 0 = 0
• For B(1,1,2):
Xnew = Xold + Shx x Yold = 1 + 2 x 1 = 3
Ynew = Yold = 1
Znew = Zold + Shz x Yold = 2 + 3 x 1 = 5
• For C(1,1,3):
Xnew = Xold + Shx x Yold = 1 + 2 x 1 = 3
Ynew = Yold = 1
Znew = Zold + Shz x Yold = 3 + 3 x 1 = 6
200. Cont.
Shearing along z-axis:
• For A(0,0,0):
Xnew = Xold + Shx x Zold = 0 + 2 x 0 = 0
Ynew = Yold + Shy x Zold = 0 + 2 x 0 = 0
Znew = Zold = 0
• For B(1,1,2):
Xnew = Xold + Shx x Zold = 1 + 2 x 2 = 5
Ynew = Yold + Shy x Zold = 1 + 2 x 2 = 5
Znew = Zold = 2
• For C(1,1,3):
Xnew = Xold + Shx x Zold = 1 + 2 x 3 = 7
Ynew = Yold + Shy x Zold = 1 + 2 x 3 = 7
Znew = Zold = 3
203. Mathematical representation:
• This rotation is achieved by using the following rotation equations-
Xnew = Xold
Ynew = Yold x cosθ – Zold x sinθ
Znew = Yold x sinθ + Zold x cosθ
• This rotation is achieved by using the following rotation equations-
Xnew = Zold x sinθ + Xold x cosθ
Ynew = Yold
Znew = Yold x cosθ – Xold x sinθ
• This rotation is achieved by using the following rotation equations-
Xnew = Xold x cosθ – Yold x sinθ
Ynew = Xold x sinθ + Yold x cosθ
Znew = Zold
This is for clockwise rotation. For anti-clockwise, just revert the sign of Sinθ
204. Problem-1:
• Given a homogeneous point (1, 2, 3). Apply rotation 90 degree
towards X, Y and Z axis and find out the new coordinate points.
205. Solution:
• Along x-axis:
Xnew = Xold = 1
Ynew = Yold x cosθ – Zold x sinθ = 2 x cos90° – 3 x sin90° = 2 x 0 – 3 x 1 = -3
Znew = Yold x sinθ + Zold x cosθ = 2 x sin90° + 3 x cos90° = 2 x 1 + 3 x 0 = 2
• Along y-axis:
Xnew = Zold x sinθ + Xold x cosθ = 3 x sin90° + 1 x cos90° = 3 x 1 + 1 x 0 = 3
Ynew = Yold = 2
Znew = Yold x cosθ – Xold x sinθ = 2 x cos90° – 1 x sin90° = 2 x 0 – 1 x 1 = -1
• Along z-axis:
Xnew = Xold x cosθ – Yold x sinθ
Ynew = Xold x sinθ + Yold x cosθ
Znew = Zold
207. Problem-1:
• Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4, 2),
C(5, 6, 3). Apply the reflection on the XY plane and find out the
new coordinates of the object.
209. Problem-2:
• Given a 3D triangle with coordinate points A(3, 4, 1), B(6, 4, 2),
C(5, 6, 3). Apply the reflection on the XZ plane and find out the
new coordinates of the object.
211. Inverse transformation:
• Like linear algebra matrix transformation, we can use this feature to
save a lot of computations but just computing inverse transformation.
For example, I have rotated a shape anti-clockwise and want to return
it to its original place in game to fulfill reset requirement. I can just
rotate the matrix in opposite direction without measuring the
coordinates again.
• Just put change the sign of the respective parameter in matrix like Shy
in shear, Sx in scaling, Tx in translation and many more patterns.
214. Character generation:
• In computer graphics, character can be generated using software or
hardware.
• Software provides a lot of options as compared to hardware.
• Three basic methods are:
1) Stroke method
2) Vector method or bitmap method
3) Starbust method
215. Stroke method:
• In this method, different shapes especially lines are combined to
generate character. Shapes can be circle, curve, lines or any other.
• We can change the size of character in this method.
• Font faces are few one.
Word generated by combining lines
and circle.
216. Bitmap/vector method:
• This method uses a data-structure commonly a matrix to store zero’s
and one’s. while scanning of each pixel intensity is done while reading
the data and displayed on screen. Matrix can be of rbg format.
• For example, a matrix of zero’s and one generate a pattern where
there are ones in the matrix and ignore that place (black by default)
where zeros are encountered.
221. Starbust method:
• In this method, a fixed pattern of lines is used to generate the
character.
• In this method, we use combination of 24 bit line segment.
• In 24-bit line segment, each bit represent a single line.
• To highlight a line, we put bit 1 in 24 bit line segment code and 0
otherwise.
226. Clipping:
“The process of ensuring whether a certain shape or component is inside or
outside the viewport.”
• Clipping is a fundamental concept in computer graphics that refers to the
process of determining which portions of an object or primitive should be
displayed or rendered on the screen. It is essential for efficiently displaying
graphics on a two-dimensional display device, such as a monitor, while
working with three-dimensional objects or primitives.
• When rendering 3D objects, it is common for portions of those objects to
extend beyond the boundaries of the display window or viewport. Clipping
ensures that only the visible parts of these objects are drawn, while the
portions outside the viewing window are discarded.
227. Point clipping:
• Point Clipping is used to determining, whether the point is inside the
window or not. For this following conditions are checked.
if (x >= xmin) && (x <= xmax) && (y >= ymin) && (y <= ymax)
Point is inside
else
Point is outside the viewport!!
228. Text Clipping:
• Several methods are available for clipping of text. Clipping method is
dependent on the method of generation used for characters. A simple
method is completely considered, or nothing considers method. This
method is also called as all or none. If all characters of the string are inside
window, then we will keep the string, if a string character is outside then
whole string will be discarded.
• Two methods are used: 1) Based on whole string 2) Based on individual
character
• Based on whole string, if whole half string is outside, whole will be
rejected.
• Based on individual character, if few characters are outside the window,
then only those characters will be rejected.
232. Example:
if (x >= xmin) && (x <= xmax) && (y >= ymin) && (y <= ymax)
(xmin, ymin) -> (xmax, ymax) = (2,2) -> (4,4)
Point (x1,y1) = (3,1) ??
If (3 >= 2) && (3 <= 4) && (1 >= 2) && (1 <= 4)
So, point is outside the window!!
(Xmin , ymin) Xmax
Ymax
2 3 4
2
3
4
(x1,y2)
233. Cohn Sutherland line clipping algorithm:
• It is used to determine a line outside, inside or partially inside the
window.
234. Bit code assignment:
• Window is divided into 9 different parts to detect at which portion
line is available. A TBRL (Top, Bottom, Right, Left)rule is used to check
the availability.
235. Algorithm:
1) Assign the region codes to both endpoints.
2) Perform OR operation on both of these endpoints.
3) if OR = 0000, then it is completely visible (inside the window).
else
Perform AND operation on both these endpoints.
i) if AND ≠ 0000, then the line is invisible and not inside the window.
Also, it can’t be considered for clipping.
ii) else
AND = 0000, the line is partially inside the window and considered for
clipping.
236. Cont.
• 4) 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)
a) If the line passes through top or the line intersects with the top boundary of the window.
x = x + (y_wmax – y)/m
y = y_wmax
b) If the line passes through the bottom or the line intersects with the bottom boundary of the
window.
x = x + (y_wmin – y)/m
y = y_wmin
c) If the line passes through the left region or the line intersects with the left boundary of the
window.
y = y+ (x_wmin – x)*m
x = x_wmin
237. Cont.
d) If the line passes through the right region or the line intersects with
the right boundary of the window.
y = y + (x_wmax -x)*m
x = x_wmax
5) Now, overwrite the endpoints with a new one and update it.
6) Repeat the 4th step till your line doesn’t get completely clipped
238. Derivation:
• Left:
x = xmin
m = y2- y1 / x2 – x1 = y – y1/ x – x1 = y- y1 / xmin – x1
y = y1 + m( xmin - x1)
• Right:
x = xmax
m = y2- y1 / x2 – x1 = y – y1/ x – x1 = y- y1 / xmax – x1
y = y1 + m( xmax - x1)
239. Cont.
• Top:
y = ymax
m = y2- y1 / x2 – x1 = y – y1/ x – x1 = ymax- y1 / x2 – x1
x = x1 + (ymax – y1)/m
• Bottom:
y = ymin
m = y2- y1 / x2 – x1 = y – y1/ x – x1 = ymin- y1 / x2 – x1
x = x1 + (ymin – y1)/m
240. Example:
1 2 3 4 5 6 7 8 9
9
8
7
6
5
4
3
2
1
(9,6)
(5,2)
Let A = (x1, y1) = (5,2), B = (x2, y2) = (9,6)
1) Applying TBLR rule
A = 0000, B = 0001
A AND B = 0 (Partially outside)
2) Applying right formula:
x = xmax= 1
y = y1 + m( xmax - x1)
m = 6 – 2 / 9 – 5 = 4/4 = 1
y = 2 + 1(7 – 5) = 4
So, intersection point is (1,4)
Ignore the remaining part from (1,4) to (9,6).
241. Possible cases:
Visible Partially outside Not visible Partially inside,
No operation required Find intersection Ignore find intersection
and ignore line for two points
outside the box
242. Cont.
1 2 3 4 5 6 7 8 9
8
7
6
5
4
3
2
1
What if line passes through
diagonal??
In the given case,
(xmax, ymax) are the points
intersecting. So, we already
have values in case of diagonal
intersection.
243. Sutherland hodgeman polygon clipping
algorithm:
• This algorithm is used for the clipping of polygons. We start from left
side of window and then clip all the sides.
254. Problem-2:
• Apply Sutherland hodgeman algorithm to clip the polygon and apply
cohn Sutherland line clipping algorithm on the edge C to D. (Assume
coordinates on your own).
255. Weiler Athorton polygon clipping algorithm:
• This algorithm maintains two list one for path and other for
intersection points. It also handles the issue of Sutherland hodgeman
algorithm.
272. Cyrus beck line clipping algorithm:
• Cohn Sutherland algorithm works only for rectangular window. But If
we have window of any other pattern, this algorithm fails.
• Cyrus beck line clipping algorithm works for all kind of windows.
• Normal for every edge is computed
• Vector for the clipping line is computed
• This algorithm uses one parametric equation and find the intersection
points through this.
273. Algorithm:
1) Draw and compute normal vector for each edge.
2) Find the edge points of the shape if not given already.
3) Compute all the values of ‘t’ for each edge using formula:
P(t) = P0 + t(P1 – P0)
x = Ni (P(t)- Pei)
X > 0 -> Outside the clipping window, x<0 -> Inside the clipping window, X = 0 -> Intersection point
4) We have to find the intersection point, so we will take equation x = 0
Ni(P(t) - Pei) = 0
Ni ( P0 + t(P1 – P0) - Pei ) = 0
NiP0 + NitP1 – NitP0 – NiPei = 0
NitP1 – NitP0 = NiPei - NiP0
t( NiP1 – NiP0) = Ni(Pei – P0)
t = Ni(Pei – P0) / Ni (P1 – P0)
5) Compute value of t for each edge.
6) If denominator < 0 (Entering edge), If denominator > 0 (Leaving edge
7) Find maximum from entering edge and minimum from leaving edge
8) Two ‘t’ coordinates came out, then put them into formula P(t) = P0 + t(P1 – P0) one by one
P0 = starting point of intersecting line
P1 = ending point of intersecting line
Ni = Normal to the selected edge
Pei = edge coordinates
277. Cont.
Find maximum from entering list and minimum from leaving list
Max(Entering) = t1 = -4/-10 = 2/5
Min(Leaving) = t5 = 7/8
Put values into equation: P(t) = P0 + t(P1 – P0)
Let t0 = t1, t1 = t5
P(t0) = (-2, 1) + 2/5 [(6,3) – (-2,1)] = (-2,1) + 2/5 (8,2) = (6/5, 9/5)
P(t1) = (-2, 1) + 7/8 [(6,3) – (-2,1)] = (-2,1) + 7/8 (8,2) = (5, 11/4)
So, intersection points are (6/5, 9/5) & (5, 11/4).
278. Problem-1:
• Let a clipping polygon be defined by the vertices (5, 5), (20, 2), (16,
10), (10, 10). Find intersection point using cyrus beck algorithm.
280. Liang barsky line clipping algorithm:
• Like cohn Sutherland algorithm, this algorithm also works only for
rectangular window but faster and more efficient. While cyrus beck is
more general and work for all kinds of windows.
• This algorithm uses parametric equations and solves 4 inequalities.
297. Introduction:
• Fractals are intricate and infinitely complex mathematical patterns
that exhibit self-similarity at various scales. They are often
characterized by repeating patterns that can be observed regardless
of the level of magnification. Fractals can be found in nature, art, and
various scientific fields, and they have gained popularity in computer
graphics and digital art due to their visually appealing and fascinating
properties.
298. Properties:
• Self similarity: When broken into smaller and smaller pieces, the new
piece look exactly the same as the original
• Dimension: How much an object fills the space
• ‘S’ represents scaling factor and is always a natural number
• ‘N’ represents the number of smaller self similar figures
306. Iterated function system:
• IFS (iterated function system) is another way of generating fractals. It
is based on the taking a point or figure and substituting it with several
other identical ones.
309. Problem-1:
• Given sierpinski carpet pattern, what could be dimension of the 2nd
shape generate by this pattern. (Hint: Reverse back to small size to
compute)
312. Curve:
• Shape formed by sketching without lifting the pen.
• In computer graphics, shape formed without any gap is curve.
• Fact: Straight line is also curve.
314. Implicit curves:
• Implicit curves are defined by an implicit equation that relates the
coordinates (x, y, z) of a point on the curve. The equation typically
involves a polynomial or algebraic expression. When evaluating the
equation for a given point, it results in a value that determines
whether the point is on the curve (value equals zero) or outside the
curve (value greater or less than zero). Implicit curves can represent a
wide range of shapes, including complex and irregular curves.
f(x,y) = 0
315. Explicit curves:
• Explicit curves, also known as parametric curves, are defined by
explicit equations that directly describe the coordinates (x, y, z) of
points on the curve as functions of one or more parameters, such as
time or a parameter t. The equations provide explicit formulas for the
x, y, and z coordinates at any given point along the curve. Parametric
curves are often used to represent smoothly varying curves and allow
for more intuitive control over the curve's shape and behavior.
y = f(x)
‘y’ is dependent of on the value of ‘x’, while ‘x’ is independent.
316. Parametric curves:
• Parametric curves are defined by a set of equations that describe the
position of points along the curve as a function of one or more parameters.
These curves allow for precise control over shape and are used in various
applications, such as animation and curve fitting.
• Peace-wise – linear, polynomial
• Linear equation curve – less smooth and abrupt change
• Polynomial curves – more smooth and flexible with less abrupt changes
x(t) = a3t3 + a2t2 + a1t + a0
y(t) = b3t3 + b2t2 + b1t + b0
z(t) = c3t3 + c2t2 + c1t + c0 (These equations can also be represented via
matrix form)
318. Parametric continuity:
• When we join two or more curves, we need to observe its smoothness to
ensure the continuity (regularity). There are three basic types of
parametric continuity:
• Zero-order continuity: if joining points of two curve are same. Let say we
have joined two curves A and B then at joining point: A(t=1) = B(t=0)
• It is represented as C0
319. Cont.
• First-order continuity: if joining points of two curve are same. Let say
we have joined two curves A and B then at joining point:
• A’(t=1) = B’(t=0) (1st order derivate of joining point is same)
• It is represented as C1
320. Cont.
• Second-order continuity: if joining points of two curve are same. Let
say we have joined two curves A and B then at joining point:
• A’’(t=1) = B’’(t=0) (2nd order derivate of joining point is same)
• It is represented as C2
321. Geometric continuity:
• We have check for parameters of piecewise polynomial in parametric
continuity while in geometric, we consider the tangent of curve to
observe how well shape is formed.
322. Cont.
• Zero-order geometric continuity: Same as zero-order parametric
continuity
• First-order geometric continuity: Point of junction of curves have first
order derivative directly proportional to each other (not magnitude always)
A’(t=1) = k(B’(t=0))
• First-order geometric continuity: Point of junction of curves have second
order derivative directly proportional to each other (not magnitude always
A’’(t=1) = k(B’’(t=0))
These are represented by Gn. Where ‘n’ is the order.
In simple words, tangent line of both curves’ junction point must be same
which will indicate the slope of change.
323. Spline curves:
• A spline curve is a mathematical representation for which it is easy to
change the curve design put changing the control points (points taken
as reference for future modification). It is flexible enough an can be
used to adjust in any shape. If a spline curves’ control points form a
polygon, then it is convex hull.
324. Cont.
• Interpolation spline: A spline curve which passes through all the
control points.
• Approximation spline: A spline curve which passes through not all
the control points.
325. Bezier curve:
• A type of spline curve which is used to generate polygon. It forms
approximate spline curve (curve must pass from starting and ending
point but not necessary to pass through all other points). Convex hull
is formed if complete curve lie inside the control points.
• Degree of polynomial is always one less than total no. of control
points. For example, if 2 control point -> linear, 3 control points ->
quadratic.
• A Bezier curve must pass from starting and ending control point.
• The slope at the beginning of the curve is along the line joining the
first two control points and the slope at the end of the curve is along
the line joining the last two points of convex hull.
326. Properties of Bezier curve:
• Bezier curve is always contained within polygon called as convex hull
of its control points.
• The first and last points of the curve are coincident with the first and
last points of the defining polygon.
• The degree of the polynomial defining the curve segment is one
less than the total number of control points.
327. Cubic Bezier curve:
• Cubic bezier curve is a bezier curve with degree 3.
• The total number of control points in a cubic bezier curve is 4.
328. Bezier equation:
•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
•Jn,i(t) = Blending function = C(n,i)ti(1-t)n-i where C(n,i) = n! / i!(n-i)!
329. Example:
• Given cubic Bezier curve:
• 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.
331. Problem-1:
• Given a Bezier curve having 4-control points: (1,0), (3,3), (6,3), (8,1)
Determine any 5 points lying on the curve. Also, draw a rough sketch of
the curve.
332. Solution:
• 5 points are allowed to take: 0 <= u <= 1
1/ u-1 = 1/5-1 = ¼ = 0.25
taking 5 points with increment of 0.25
u = [0.0, 0.25, 0.50, 0.75, 1.0]
As total control points are 4, so order of polynomial is n-1 = 3
Q(t) = Σn
i=0 Bi,n (u) * Pi = Q(t) = Σ3
i=0 Bi,3 (u) * Pi
Now we need to compute B0,3 B1,3 B2,3 B3,3
333. Cont.
B0,3(u) = 3C0 * (u)0 * (1-u)3-0 = (1 - u)3
B1,3(u) = 3C1 * (u)1 * (1-u)3-1 = 3u(1 - u)2
B2,3(u) = 3C2 * (u)2 * (1-u)3-2 = 3u2(1 - u)2
B3,3(u) = 3C3 * (u)3 * (1-u)3-3 = u3
Q(u) = P0*(1 - u)3 + P1*3u(1 - u)2 + P3*3u2(1 - u)2 + P4*u3
As we now Bezier curve takes starting and ending point from the same
shape, so we need to compute intermediate 3 points.
X(u) = x0*(1 - u)3 + x1*3u(1 - u)2 + x3*3u2(1 - u)2 + x4*u3
y(u) = y0*(1 - u)3 + y1*3u(1 - u)2 + y3*3u2(1 - u)2 + y4*u3
334. Cont.
• For u = 0.0
P(0) = [1 0](1-0)3 + [3 3]3(0)(1-t)2 + [6 3]3(0)2(1-0) + [8 1](0)3
P(0) = [1 0] + 0 + 0 + 0
P(0) = [1 0]
• For u = 0.25
P(0.2) = [1 0](1-0.2)3 + [3 3]3(0.2)(1-0.2)2 + [6 3]3(0.2)2(1-0.2) + [8 1](0.2)3
P(0.2) = [1 0](0.8)3 + [3 3]3(0.2)(0.8)2 + [6 3]3(0.2)2(0.8) + [8 1](0.2)3
P(0.2) = [1 0] x 0.512 + [3 3] x 3 x 0.2 x 0.64 + [6 3] x 3 x 0.04 x 0.8 + [8 1]
x 0.008
P(0.2) = [1 0] x 0.512 + [3 3] x 0.384 + [6 3] x 0.096 + [8 1] x 0.008
P(0.2) = [0.512 0] + [1.152 1.152] + [0.576 0.288] + [0.064 0.008]
P(0.2) = [2.304 1.448]
335. Cont.
• For u = 0.50
P(0.5) = [1 0](1-0.5)3 + [3 3]3(0.5)(1-0.5)2 + [6 3]3(0.5)2(1-0.5) + [8 1](0.5)3
P(0.5) = [1 0](0.5)3 + [3 3]3(0.5)(0.5)2 + [6 3]3(0.5)2(0.5) + [8 1](0.5)3
P(0.5) = [1 0] x 0.125 + [3 3] x 3 x 0.5 x 0.25 + [6 3] x 3 x 0.25 x 0.5 + [8 1] x 0.125
P(0.5) = [1 0] x 0.125 + [3 3] x 0.375 + [6 3] x 0.375 + [8 1] x 0.125
P(0.5) = [0.125 0] + [1.125 1.125] + [2.25 1.125] + [1 0.125]
P(0.5) = [4.5 2.375]
• For u = 0.75
P(t) = [1 0](1-t)3 + [3 3]3t(1-t)2 + [6 3]3t2(1-t) + [8 1]t3
P(0.7) = [1 0](1-0.7)3 + [3 3]3(0.7)(1-0.7)2 + [6 3]3(0.7)2(1-0.7) + [8 1](0.7)3
P(0.7) = [1 0](0.3)3 + [3 3]3(0.7)(0.3)2 + [6 3]3(0.7)2(0.3) + [8 1](0.7)3
P(0.7) = [1 0] x 0.027 + [3 3] x 3 x 0.7 x 0.09 + [6 3] x 3 x 0.49 x 0.3 + [8 1] x 0.343
P(0.7) = [1 0] x 0.027 + [3 3] x 0.189 + [6 3] x 0.441 + [8 1] x 0.343
P(0.7) = [0.027 0] + [0.567 0.567] + [2.646 1.323] + [2.744 0.343]
P(0.7) = [5.984 2.233]
336. Cont.
• For u = 1.0
P(1) = [1 0](1-1)3 + [3 3]3(1)(1-1)2 + [6 3]3(1)2(1-1) + [8 1](1)3
P(1) = [1 0] x 0 + [3 3] x 3 x 1 x 0 + [6 3] x 3 x 1 x 0 + [8 1] x 1
P(1) = 0 + 0 + 0 + [8 1]
P(1) = [8 1]
So, Bezier curve points are: (0,1), (2.3,1.4), (4.5, 2.3), (5.9,2.2),
(8,1)
337. Problem-2:
• Given control points of Bezier curve: (0,0), (1,2), (3,3), (4,0)
Find the Bezier curve taking arbitrary number of points. The more
points you take, curve will be smoother.
339. B-spline curve:
• Concept of B-spline curve came to resolve the disadvantages having
by Bezier curve, as we all know that both curves are parametric in
nature. In Bezier curve we face a problem, when we change any of
the control point respective location the whole curve shape gets
change. But here in B-spline curve, the only a specific segment of the
curve-shape gets changes or affected by the changing of the
corresponding location of the control points.
• In the B-spline curve, the control points impart local control over the
curve-shape rather than the global control like Bezier-curve.
• Points of junction is often called as knot points.
340. Cont.
As we can see, local change does not affect the global curve.
341. NURBS
• Non-uniform b-spline curve is a type of b-spline curve in which gap
between curves is not uniform. Periodic spline curves has repeating
pattern with equal gap.
342. Catmull-Rom curves:
Catmull-Rom curves are a type of cubic interpolation curve used in computer graphics and
animation. Given a set of control points P₀, P₁, P₂, ..., Pₙ₋₁, the Catmull-Rom curve C(t) is
defined as a piecewise cubic polynomial that smoothly passes through each consecutive
pair of control points.
• The formula for the Catmull-Rom curve between control points Pᵢ and Pᵢ₊₁ is:
• C(t) = ((-t³ + 2t² - t)Pᵢ + (3t³ - 5t² + 2)Pᵢ₊₁ + (-3t³ + 4t² + t)Pᵢ₊₂ + (t³ - t²)Pᵢ₊₃) / 2
• where t is the parameter ranging from 0 to 1, determining the position along the curve.
• The Catmull-Rom curve calculation is based on a local control scheme, meaning that the
shape of the curve is determined by the positions of the adjacent control points. This
local influence allows for easy manipulation and adjustment of the curve's shape.
• Catmull-Rom curves exhibit several desirable properties, including passing through the
control points, maintaining continuity, and providing smoothness in the resulting curve.
343. Hermite curve:
• A Hermite curve, named after Charles Hermite, is a type of
interpolation curve used in computer graphics and mathematics. It is
often used to create smooth and continuous curves defined by
specified control points and their associated tangents.
• It is an interpolation spline curve.
• The Hermite curve calculation incorporates both the position and
tangent information, allowing for precise control over the curve's
shape and direction. The tangents determine the slope or direction of
the curve at each control point, influencing the curve's behavior
between the points.
344. Example:
• Let say we have a hermite curve with pk as initial and pk+1 as final point.
Value is between ‘0’ & ‘1’.
• Pk = P(0) = initial point
• Pk+1 = P(1) = end point
• Pk’ = DPk = derivative of ‘pk’
• Pk+1’ = DPk+1 = derivative of ‘pk+1’
345. Cont.
• P(u) = au3 + bu2 + cu + d , where 0 <= u <= 1
Px(u) = axu3 + bxu2 + cxu + dx
Py(u) = ayu3 + byu2 + cyu + dy
Pz(u) = azu3 + bzu2 + czu + dz
P’(u) = 3au2 + 2bu + c
P(0) = a*0 + b*0 + c*0 + d
P(1) = a*1 + b*1 + c*1 + d
P’(0) = 3a*0 + 2b*0 + c
P’(1) = 3a*1 + 2b*1 + c
348. Introduction:
• Animation refers to the movement on the screen of the display device
created by displaying a sequence of still images. Animation is the
technique of designing, drawing, making layouts and preparation of
photographic series which are integrated into the multimedia and
gaming products. Animation connects the exploitation and
management of still images to generate the illusion of movement.
349. Applications:
• Education & training
• Entertainment
• Computer Aided Design (CAD)
• Advertising
• Presentation
350. Animation functions:
• Morphing: Morphing is an animation function which is used to
transform object shape from one form to another is called Morphing.
It is one of the most complicated transformations. This function is
commonly used in movies, cartoons, advertisement, and computer
games.
351. Cont.
• Wrapping: Wrapping function is similar to morphing function. It
distorts only the initial images so that it matches with final
images and no fade occurs in this function.
• Tweening: Tweening is the short form of 'inbetweening.'
Tweening is the process of generating intermediate frames
between the initial & last final images. This function is popular in
the film industry.
353. Tilting:
• In animation, tilting refers to the movement of an object or camera
along a vertical axis. It involves changing the vertical angle or
orientation of the object or camera to create a sense of tilt or slant.
• When an object or camera tilts in an animation, it appears to lean or
pivot around the vertical axis. This movement can be used to add
dynamics, depth, and visual interest to a scene.
354. Cont.
• Panning: Usually Panning refers to rotation of the camera in
horizontal Plane. In computer graphics, Panning relates to the
movement of fixed size window across the window object in a
scene. In which direction the fixed sized window moves, the
object appears to move in the opposite direction.
355. Cont.
• Zooming: the window is fixed an object and change its size, the
object also appear to change in size. When the window is made
smaller about a fixed center, the object comes inside the
window appear more enlarged. This feature is known
as Zooming In.
• When we increase the size of the window about the fixed
center, the object comes inside the window appear small. This
feature is known as Zooming Out.
356. Cont.
• Rigging: The process of defining internal structure of a character like
bones/skeleton. It is the initial phase in animation where internal
design is first prepared. After then skinning is done to provide outer
structure of the animation character like skin, clothes.
Rigging Skinning
357. Cont.
• Key frame animation: The process of generating only key/important
frames of the animation and remaining/intermediate frames are
automatically added by software (tweening).
• Motion capture: Creating animation based on real life objects like
creating a character on a specific human.
• Texture mapping: The process of applying a specific pattern in
animation to make it more realistic in 3D. For example, I have a cube
involved in my animation of black color, I want to make cube made of
wood, then I will wrap the cube inside the wood color (texture) to
make the illusion of looking like a wooden cube.
359. Types of animation:
• Procedural: In this process, objects are animated with a procedure (set of
rules). Animator specifies the rules to be followed.
• Behavioral: Animator determines actions required to take on certain
frame. The process put more action in animation.
• Dynamics: Unlike key framing and motion picture, simulation uses the laws
of physics to generate motion of pictures and other objects. Simulations
can be easily used to produce slightly different sequences while
maintaining physical realism. Secondly, real-time simulations allow a higher
degree of interactivity where the real person can maneuver the actions of
the simulated character. These animations are created in physics engines
where physical behaviors can be scripted, even those with minute details
such as fluids or smoke.
360. Raster animation:
• Raster images are collection of a large number of pixels stored in a
buffer in shape of matrix in bitmap format.
• When these raster images are displayed in a particular sequence, it is
raster animation. Each raster image is a frame in animation. Frame
buffer is refreshed iteratively.
361. Traditional raster animation:
• Used low detailed animation using sprite sheets
• Sprite sheet is a single image having different motions in different
cells. In simple words, it encloses animation in a single image but
limited number of frames are stored.
362. Vector animation:
• It stores images as a sequence of points. Vector animation does not
provide much clarity as compared to raster animation.
• Raster animations are high resolution as compared to vector
animation.
363. Color table animation:
• Color table animation, also known as palette animation or indexed
color animation, is a technique used to create animations in which
the colors of the image or scene change over time. It is commonly
used in older systems or graphics formats that have limited color
capabilities.
• In color table animation, instead of directly changing the colors of
individual pixels in the image or scene, a fixed color table or palette is
used. The color table contains a limited set of colors, often referred to
as color indices. Each pixel in the image is assigned a color index that
corresponds to a specific color in the color table.
364. Double buffering:
• Double buffering is a technique used in animation and computer graphics
to prevent flickering and create smoother, more visually appealing
animations.
• In computer graphics, the image displayed on the screen is updated and
refreshed multiple times per second. Without buffering, when an image is
being drawn on the screen, there is a possibility of seeing incomplete or
partially drawn frames, resulting in flickering or visual artifacts.
• Double buffering solves this issue by introducing two buffers: a front buffer
and a back buffer. The front buffer represents the currently displayed
image on the screen, while the back buffer is a hidden or off-screen buffer
where the next frame of the animation is prepared.
366. Direct motion specification:
• We explicitly give the rotation angles and translation vectors.
• Then the geometric transformation matrices are applied to transform
co-ordinate positions.
• These methods can be used for simple user programmed sequences.
367. Goal directed system:
• We an specify the motions that are to take place in general terms that
abstractly describes the actions.
• These systems are referred to as goal directed because they
determine specific motion parameters given the goals of the
animation. For example, we could specify that we want an object to
“walk” or to “run” to a particular destination.
368. Kinematics and dynamics:
• Kinematics: motion of study (position, velocity, acceleration)
• The movement of object from one place to another
• Measured over a time interval such as s, min,h
• Relative to the position of the observer or reference point
• Dynamics: Full consideration of time varying phenomenon in the
interaction between motion, forces and material properties
• Typically, there is a time-integration process where result from one
time frame effect the result on the next time frame.
369. Virtual/augmented reality:
• Advance sub-field of animation
• Process of creating real world animation with more and more realism
• AVATAR like movies based on this technology
371. Introduction:
• Given an illumination incident at a point on a surface, quantification is
required to compute the intensity.
• Used to compute interaction of light with surfaces
• Factors determining lighting effect:
- Light source, surface, eye (camera)
372. Light sources:
• Point source: All lights originate at a point and radially diverge. A
reasonable approximation for sources whose dimensions are small
compared to the object size. For example, bulb in a room.
• Parallel source: Light is distributed parallelly in all directions. For
example, tube-light in a room.
• Distributed source: Light is scattered with unequal length. For
example, disco lights in party and functions.
Point Parallel Distributed
373. Ambient light:
• Non-directional
• Amount of light incident is constant on all surfaces
• Background light
• Not very realistic
• Indirect light source
• Can be natural/artificial, sun-light is reflected equally on all sources
374. Beer Lamberts’s law:
• It states that intensity of color observed from any reflecting surface is
directly proportional to cosine of the angle between direction of
incident light and the normal surface.
375. Diffuse light:
• Scattered along all points equally. (parallel source)
• Surface that are rough or grainy tend to scatter the reflected light in all
directions
• Measured by angle made by taking normal to the point where light is
incident to the light source making a cosine angle. Or it can be specified
as product of N.L (N = normal to the vector, L = light direction)
• A surface only illuminates light if the angle of incidence is in between 0
and 90 degree because cosine must be between 0 and 1.
• When cosine is negative, light source is behind the surface.
376. Specular reflection:
• Model for shiny and glossy surfaces like metals
• An ideal specular surface reflects light in one direction
384. Shading:
• The process of manipulating color of the shape to make it more
realistic is shading. It has four main types:
• Flat/Constant shading
• Gouraund shading
• Phong shading
385. Flat shading:
• A fast and straight forward method for rendering an object with
polygon surface is constant or flat shading. In this method, a single
intensity is computed by taking a normal to the specific/desired side
of shape and energy of light is computed by multiplying reflectivity
and refractivity. All points with-in the surface are assigned the same
color. It is the fastest one but less realistic and can make image more
worse with respect to intensity. It can be used to display the general
appearance of the shape.
386. Cont.
• If shape has more than one side, normal at each face is computed at
that intensity is applied to corresponding face only.
• It provides intensity discontinuity which causes match band effect.
387. Gouraud shading:
• This method uses interpolation by rasterizing the shape line by line.
• Step1: Find adjacent vertex's normal
• Step2: Apply illumination model at each polygon vertex to determine
polygon vertex intensity.
• Step3: Linearly interpolate the vertex intensity over the surface of
polygon.
388. Example:
• Step1: Along vertex ‘V’ adjacent edges are N1, N2, N3
• Taking a 2D shape to interpolate easily step 2
• Lets’ find the interpolation for ‘a’, ‘p’ & ‘b’.
389. Cont.
• Intensity of a = Ia = ya – y2 / y1 – y2 (I1) + y1 – ya/ y1 - y2(I2)
• Intensity of b = Ib = yb – y2 / y2 – y3 (I3) + y3 – yb/ y2 – y3(I2)
• Intensity of p = Ip = xb – xp / xb – xa (Ia) + xp – xa/ xb – xa(Ib)