SlideShare a Scribd company logo
UNIT-1
Introduction to Computer Graphics
Computer Graphics is the area where we study about
audio,vedeo and animation of the objects or we can also
say that drawing pictures on the screen is also called
computer graphics.
We can also say that its an art of drawing pictures on
computer screen with the help of programming.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 1
APPLICATION OF COMPUTER GRAPHICS
Computer graphics user interfaces (GUIs) – A graphic, mouse-oriented
paradigm which allows the user to interact with a computer.
Cartography – Drawing maps.
Weather Maps – Real-time mapping, symbolic representations.
Satellite Imaging - Geodesic images.
Photo Enhancement - Sharpening blurred photos.
Medical imaging - MRIs, CAT scans, etc. - Non-invasive internal
examination.
Engineering drawings - mechanical, electrical, civil, etc. - Replacing the
blueprints of
the past.
Typography - The use of character images in publishing - replacing the
hard type of
the past.
Architecture - Construction plans, exterior sketches - replacing the
blueprints and hand drawings .
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 2
Types of computer graphics
Basically there are two types of computer graphics
Raster Graphics
Raster graphics can be prepared with the help of individual pixels & Its
also called Bitmap images. A bitmap image contains a grid of individual
images
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 3
Vector Graphics
In this technique, the electron beam is directed only to the part of the
screen where the picture is to be drawn rather than scanning from left to
right and top to bottom as in raster scan. It is also called vector display,
stroke-writing display, or calligraphic display. Its also useses mathematical
relationship between points & path.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 4
Frame Buffer & video controller
A frame buffer is a memory of contiguous location & Typically it is stored
in the memory chips on the video adapter.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 5
Video controller
It is used to control the operation of the display device (Monitor/Screen).
Video controller accesses the frame buffer to refresh the screen. In figure,
the basic refresh operations of the video-controller are shown.
Raster System
Register 1 Register 2
Memory References
Frame Buffer
Pixel
Record
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 6
Line Drawing Algorithms
For drawing a line we need two end points so there are some algorithms
that provide line generation.
We know that Y=Mx + C
Where M=(Y2-Y1)/(X2-X1)
DDAAlgorithm: The full name of this algorithm is Digital
Differential Analyzer & the basics concept of this algo is as follows
1.A line can be specified in the form: Y=mx+c
2.Let m be between 0 to 1, then the slope of the line is between 0 and 45
degrees.
3. For the x-coordinate of the left end point of the line, compute the
corresponding y value according to the line equation. Thus we get the left
end point as (x1,y1), where y1 may not be an integer
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 7
4. Calculate the distance of (x1,y1) from the center of the pixel immediately
above it and call it D1.
5.Calculate the distance of (x1,y1) from the center of the pixel immediately below
it and call it D2.
6.If D1 is smaller than D2, it means that the line is closer to the upper pixel than
the lower pixel, then, we set the upper pixel to on; otherwise we set the pixel.
7. This method assumes the width of the line to be zero.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 8
The Bresenham’s algorithm
This is the another incremental scan conversion algorithm &
The major advantage of this algorithm is that, it uses only
integer calculations not the fraction. Moving across the x axis in
unit intervals and at each step choose between two different y
coordinates.
Step 1 − Input the two end-points of line, storing the left end-
point in (x0,y0).
Step 2 − Plot the point (x0,y0).
Step 3 − Calculate the constants dx, dy, 2dy, and (2dy – 2dx)
and get the first value for the decision parameter as p0=2dy−dx
Step 4 −
If pk < 0, the next point to plot is (xk+1,yk) and
pk+1=pk+2dy
Otherwise,
pk+1=pk+2dy−2dx
Step 5 − Repeat step 4 (dx – 1) times.
For m > 1, find out whether we need to increment x while
incrementing y each time.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 9
Circle Generation Algorithm
The first thing we can notice to make our circle drawing
algorithm more efficient is that circles centred at (0, 0) have
Eight-way symmetry
(x, y)
(y, x)
(y, -x)
(x, -y)(-x, -y)
(-y, -x)
(-y, x)
(-
x,y)
2
R
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 10
Mid Point Circle Generation Algo
Mid Point algo is the one of the circle generation algo which
is depend on eight point symmetry.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 11
BRESENHAM’S CIRCLE ALGORITHM
1. Set X = 0 and Y = R
2.Set D = -(-3 +2R)
3.Repeat While (X < Y)
4. Call Draw Circle(X1, Y1, X, Y)
5. Set X = X + 1
6. If (D < 0) Then
7. D = D + 4X + 6
8. Else
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 12
Continued……
9. Set Y = Y –1
10. D = D + 4(X –Y) + 10
[End of If]
11. Call Draw Circle(X1, Y1, X, Y)
[End of While]
12.Exit
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 13
UNIT-II
Transformations
Basic Transformation
Transformed point=Transformation Matrix*Original Matrix
Translation
Rotation
Scaling
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 14
Matrix Representation
T = 1 0 tx
0 1 ty
0 0 1
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 15
Translation
A translation basically means adding a vector to a point, making a
point transforms to a new point
Changing the position of the object
P’(x’,y’)
Translated Place
P(x,y)
Original Place
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 16
Coordinate System
Rotation
Changing the position with angle
Ø
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 17
Coordinate System
Scaling
Reduces the size of the object(Magnifies)
a’=aSa
b=bSb
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 18
Composite Transformation
It is a special type of transformation which consider various aspects
of transformation compare to basic.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 19
Composite Transformation
Some are as follows
1. Rotation about an arbitrary point
2. Scaling about a arbitrary Point
3. Reflection of an object about any line
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 20
Composite Transformation
Equations
1. RØ,P=TvRØT-v
2. S(Sx,Sy) , P(h,k)=Tv Sxy Sy T-v
3.Mr=TvRØMxR-ØT-v
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 21
Windowing & Clipping
windowing system is a system for sharing a computer's graphical display
presentation resources to various multiple applications at the same time
Clipping is the process of cutting the portion of the object with the help of specific
algorithm or dimension.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 22
Clipping
 We need to clip objects outside the canonical
view volume
 Clipping lines (Cohen-Sutherland algorithm)
 Clipping polygons (Sutherland-Hodgman algorithm)
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 23
Clipping
aaa
X Axis
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 24
Clipping
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 25
Line Clipping Algo.
1. Cohen Sutherland Line clipping algo.
2.Liang Barsky line clipping algo.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 26
Cohen–Sutherland algo
 This algo is used for line clipping & follow the divide-and-
conquer strategy.
 The algorithm divides a two-dimensional space into 9 regions
 Efficiently determines the lines and portions of lines that are
visible in the centre region of interest (the viewport).
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 27
Cohen–Sutherland algo
 Given a line segment with endpoint A(q1,q2) and B(q2,q3)
 Compute the 4-bit codes for each endpoint.
If both codes are 0000,(bitwise OR of the codes yields 0000 )
line lies completely inside the window
If both codes have a 1 in the same bit position (bitwise AND
of the codes is not 0000), the line lies outside the window.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 28
Continued….
 If a line cannot be trivially accepted or rejected, at least one of the
two endpoints must lie outside the window and the line segment
crosses a window edge.
 Examine one of the endpoints, say P1=(q1,q2) . Read P1 as 4-bit code
in order: Left-to-Right, Bottom-to-Top.
 When a set bit (1) is found, compute the intersection I of the
corresponding window edge with the line from to . P1 to P2 Replace
P1 with I and repeat the algorithm.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 29
Continued….
After clipping
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 30
Liang Barsky algorithm
Liang and Barsky have created an algorithm that uses floating-point
arithmetic but finds the appropriate end points with at most four
computations
 Express line segments in parametric form.
 Derive equations for testing if a point is inside the window
 Compute new parameter values for visible portion of line segment, if
any
 Display visible portion of line segment
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 31
Liang Barsky algorithm
 Read two end points of line P1 (x1, y1) and P2 (x2, y2)
 Read two corner vertices, left top and right bottom of
window: (XwMIN, YwMAX) and (XwMAX, YwMIN)
 Calculate values of parameters pi and qi for I =1, 2, 3, 4
such that
p1 = -Δx
q1 = x1 – XwMIN
p2 = Δx
q2 = XwMAX – xi
q1 = – Δy
q3 = y1 – YwMIN
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 32
Continued….
q2 = Δy
q4 = YwMAX – y1
 If pi = 0 then,
{
Line is parallel to ith boundary.
If qi < 0 then,
{
Line is completely outside the boundary. Therefore, discard
line segment and Go to Step 10.
}
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 33
Continued….
else
If line endpoints lie within the bounded area then
use them to draw line. Otherwise use boundary
coordinates to draw line. Go to Step 10.
 Initialize t1 = 0 and t2 = t1
 Calculate values for qi/pi for i= 1,2,3,4
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 34
Continued….
 Select values of qi/pi where pi<0 and assign maximum out of them
as t1.
 Select values of qi/pi where pi>0 and assign maximum out of them
as t2.
 If (t1 < t2)
{
Calculate endpoints of clipped line:
xx1 = x1 + t1 Δx
xx2 = x1 + t2 Δx
yy1 = y1 + t1 Δy
yy2 = y1 + t2 Δy
Draw line (xx1, yy1, xx2, yy2)
}
 Stop.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 35
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 36
Polygon clipping
1.Sutherland Hodgeman Algorithm
2. Weiler and Atherton polygon clipping
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 37
Sutherland Hodgeman Algorithm
 Polygons can be clipped against each edge of the window one at a
time. windows/edge intersections, if any, are easy to find since the X or
Y coordinates are already known.
 Vertices which are kept after clipping against one window edge are
saved for clipping against the remaining edges
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 38
Sutherland …….
 Note that the number of vertices usually changes and will often
increases.
 We are using the Divide and Conquer approach.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 39
Conditions of Polygon Clipping Algo
C 1 : Wholly inside visible region - save endpoint
C 2: Exit visible region - save the intersection
C 3 : Wholly outside visible region - save nothing
C 4 : Enter visible region - save intersection and end point .
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 40
Steps of Sutherland …….
Step 1: Clip Right of the Boundary
Step 2: Clip Bottom Boundary
Step 3:Clip Left Boundary
Step 4:Clip Top Boundary
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 41
Weiler and Atherton polygon clipping
This algorithm is used for clipping concave polygons
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 42
Weiler and Atherton Algo.
 In this algorithm we take a starting vertex like I1
 And traverse the polygon like I1, V3, I2.
 Leaving intersection the algorithm follows the clip polygon vertex list from
leaving vertex in downward direction.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 43
Weiler and Atherton Algo.
 At occurrence of entering intersection the algorithm follows subject
polygon vertex list from the entering intersection vertex.
 This process is repeated till we get starting vertex.
 This process has to be repeated for all remaining entering
intersections which are not included in the previous traversing of
vertex list.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 44
TYPE OF TEXT CLIPPING
A. Stardust
B. Bitmap
C. Stroke
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 45
STARDUST
 This method of character generation is called
stardust method because of its characteristics
appearance.
 a code conversion software is used in it to display a
character .
 A character quality is also poor.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 46
BITMAP
 In bitmap method characters are represented by array of dots in the
matrix form.
 It is 2D array that means having rows and columns.
 Each dot in the matrix is pixel.
 The value of pixel control the intensity of the pixel.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 47
STROKE
 This method uses small line segments to generate a character
 we can built our own stoke method character generate by call through the
line drawing algorithm.
 In this method a fixed pattern of line segments are used to generate the
characters.
 There are 24 line segments. out of these 24 line segments the segments
required to display for a particular character are highlighted.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 48
UNIT-III
3D Geometric Primitives
 Polygon meshes and polyhedra are the geometric figures that are created
with a surface modeler.
 A polygon mesh is a collection of edges, vertices and polygons connected
in such a way that each edge is shared by at most two polygons.
 Polyhedra are volumetric solids, such as the cube or a sphere, represented
as facets.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 49
3D Object Representation
 Polygon and Quadric surfaces
 Spline surfaces and construction
 Procedural methods
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 50
3D Transformation
Rotation
Scaling
Translation
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 51
Rotation
In 3D rotation, we have to specify the angle of rotation along with the axis
of rotation
Rotation about x-axis
X-Axis
Y Axis
Z Axis1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 52
Y Axis
X Axis
Z Axis
Rotation About Y Axis
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 53
Y Axis
X Axis
Z Axis
Rotation About Z Axix
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 54
3D Viewing
For representing 3D-objects on a 2D -screen in a nice or recognizable
way, many techniques are combined. First, the projection has to be
defined, which will be described in the next paragraph
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 55
Possible Qualities
Wire-Frame-Representation: Only the edges of polygons are drawn.
Depth-Cueing = Edges or parts which are nearer to the viewer are displayed
with more intensity.
Correct Visibility = Surface-elements (edges, polygons), which are occluded
by other surface-elements, are not drawn so that only visible areas are shown.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 56
3D-Viewing-Pipeline
Object
Coordinate
world Co. Viewing Co.
Projection Co.
Normdivice Co.
Device Coordinate
Creation of
Object
Creation of
Object
Definition Projection
Mapping
Transform to
specific region
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 57
Projections
Process of moving in positive with time through imaging of future events or
calculation based on past trends.
However, in computer graphics mainly only the parallel and the perspective
projection are used generally. In geometry science various types of
projections are known
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 58
Projections
Y
Z
X
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 59
Projections
Parallel Projection
Perspective Projection
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 60
Perspective
Projections
One Point
Two Point
Three Point
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 61
For parallel projections, we specify a direction of projection instead of a
Centre of projection
There are two types of parallel projections:
Orthographic projection – DOP perpendicular to PP
Oblique projection --- DOP not perpendicular to PP
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 62
3D Clipping
In 3D clipping you do everything in 3D space. Map graphics
are clipped to one side of an arbitrary clipping plane in one
or more clipping stages.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 63
Cohen Sutherland 3D Clipping Algo
The outcode for 3D clipping is a 6-bit code
 Bit 1 - point above view volume
 Bit 2 - point below view volume
 Bit 3 - point to the right of view volume
 Bit 4 - point to the left of view volume
 Bit 5 - point behind view volume
 Bit 6 - point in front of view volume
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 64
UNIT-IV
Bézier curve
A Bézier curve approximates any number of control points for a curve section
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 65
Curves and Surfaces
Quadric surfaces
X
Y
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 66
X
Y
Quadratic Surfaces
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 67
Blobby Object
 A Blobby Object is non rigid object like
 Like rubber,liquids,water droplets cloths etc.
 These objects tend to exhibit a degree of fluidity
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 68
Continued….
 Several models have been developed to handle
these kind of objects.
 One technique is to use a combination of Gaussian
density functions (Gaussian bumps)
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 69
Spline Representations
 A spline is a flexible strip used to produce a smooth curve through a designated
set of points
 Small weights would be distributed along the strip to hold
 it in position on the drafting table
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 70
Spline Specifications
There are three different ways to specify splines
 state the set of boundary conditions that are imposed on the spline
 state the matrix that characterizes the spline
 state a set of blending/basis function that determines how specified constraints
on the curve are combined to calculate positions along the curve path
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 71
Boundary Condition Example
 Boundary conditions may be the coordinates of x(0), x(1) and the derivatives
x’(0), x’(1). These four numbers are enough to fix ax, bx, cx, dx
 After this representation we can connected to the other representations.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 72
Interpolation and Approximation Splines
To specify a spline we need to give a set of coordinate positions called control
points
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 73
Hidden Lines and Surfaces
 Back-Face Detection
 Depth-Buffer Methods
 A-Buffer Methods
 Scan-Line Methods
 Depth-Sorting Method
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 74
Basic illumination models
 Light Sources
 Basic Illumination Models
 Displaying Light Intensities
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 75
Ambient Light
 Approximates the indirect illumination
 Equal amount of light from all directions
 I K=(I is intensity of ambient light & K=percentage of the light
reflected by the object)
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 76
Lighting at a point on surface surface
I = Ikdcosθ
I=intensity of light
K=coefficient of diffuse reflection
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 77
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 78
A
B
C
Surface
P
Diffuse reflection
I = Idkd(N.L)
Id(N.L) is like the irradiance
kdI is like the reflectivit
No dependency on viewer
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 79
Specular reflection and Phong model
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 80
P
A
A2
Specular Component Component
 One area depend on other
 Some time depends on both
 Numbers controls the view dependency.
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 81
Intensity Attenuation
 Providing enough control so that one can simulate
effect via trial and error of many different
parameters
 May be not be close to the physical phenomenon
 If we see different brightness of the same light can
be used for different component computation
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 82
Properties of Bézier curves
 Passes through start and end points P0 & Pn.
 First derivates at start and end
 Lies in the convex hull
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 83
Shading
 Independent of the Illumination model used
 Phong Shading and Phong Illumination
 Simple and hence widely used
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 84
Phong Shading
 Calculate the illumination at every pixel using rasterization
 Interpolate the normal across the triangle
 Slower than Gauaurd
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 85
Gouraud Shading Shading
 Edges get same color, irrespective of which triangle
they are rendered from Shading is continuous at edges
 Tends to spread sharp illumination spots over the triangle
THANKS
1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 86

More Related Content

What's hot

Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Ketan Jani
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
Ankit Garg
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
Thirunavukarasu Mani
 
Polynomial and thier graphs
Polynomial and thier graphsPolynomial and thier graphs
Polynomial and thier graphs
Jessica Garcia
 
Lecture 15 section 5.4 graph of sin & cos
Lecture 15   section 5.4 graph of sin & cosLecture 15   section 5.4 graph of sin & cos
Lecture 15 section 5.4 graph of sin & cos
njit-ronbrown
 

What's hot (20)

Trigonometric graphs
Trigonometric graphsTrigonometric graphs
Trigonometric graphs
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGAScientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
Scientific Computing II Numerical Tools & Algorithms - CEI40 - AGA
 
Clipping
ClippingClipping
Clipping
 
Calc 3.6b
Calc 3.6bCalc 3.6b
Calc 3.6b
 
Teknik Simulasi
Teknik SimulasiTeknik Simulasi
Teknik Simulasi
 
Calc 3.6a
Calc 3.6aCalc 3.6a
Calc 3.6a
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 
Computer graphics question for exam solved
Computer graphics question for exam solvedComputer graphics question for exam solved
Computer graphics question for exam solved
 
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)bresenham circles and polygons in computer graphics(Computer graphics tutorials)
bresenham circles and polygons in computer graphics(Computer graphics tutorials)
 
Simplex algorithm
Simplex algorithmSimplex algorithm
Simplex algorithm
 
Polynomial and thier graphs
Polynomial and thier graphsPolynomial and thier graphs
Polynomial and thier graphs
 
Lecture 15 section 5.4 graph of sin & cos
Lecture 15   section 5.4 graph of sin & cosLecture 15   section 5.4 graph of sin & cos
Lecture 15 section 5.4 graph of sin & cos
 
Max and min trig values
Max and min trig valuesMax and min trig values
Max and min trig values
 
Rational Function
Rational FunctionRational Function
Rational Function
 
Brute force
Brute forceBrute force
Brute force
 
Bresenham Line Drawing Algorithm
Bresenham Line Drawing AlgorithmBresenham Line Drawing Algorithm
Bresenham Line Drawing Algorithm
 
Mid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer GraphicsMid point line Algorithm - Computer Graphics
Mid point line Algorithm - Computer Graphics
 

Viewers also liked

A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
SlideShare
 
Advance Graphic Design Final Exam 71%
Advance Graphic Design Final Exam 71%Advance Graphic Design Final Exam 71%
Advance Graphic Design Final Exam 71%
Lize Smith
 
Ed tech 105a topic 1 history of edtech
Ed tech 105a topic 1 history of edtechEd tech 105a topic 1 history of edtech
Ed tech 105a topic 1 history of edtech
Maria Theresa
 

Viewers also liked (20)

What Makes Great Infographics
What Makes Great InfographicsWhat Makes Great Infographics
What Makes Great Infographics
 
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
A Guide to SlideShare Analytics - Excerpts from Hubspot's Step by Step Guide ...
 
COMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORTCOMPUTER GRAPHICS PROJECT REPORT
COMPUTER GRAPHICS PROJECT REPORT
 
unit-1-intro
 unit-1-intro unit-1-intro
unit-1-intro
 
Mini Project- 3D Graphics And Visualisation
Mini Project- 3D Graphics And VisualisationMini Project- 3D Graphics And Visualisation
Mini Project- 3D Graphics And Visualisation
 
Computer Graphics Project- The Running Train
Computer Graphics Project- The Running TrainComputer Graphics Project- The Running Train
Computer Graphics Project- The Running Train
 
Computer graphics mini project on bellman-ford algorithm
Computer graphics mini project on bellman-ford algorithmComputer graphics mini project on bellman-ford algorithm
Computer graphics mini project on bellman-ford algorithm
 
Resume
ResumeResume
Resume
 
Lecture 25
Lecture 25Lecture 25
Lecture 25
 
Graphic organizers group coaching
Graphic organizers group coachingGraphic organizers group coaching
Graphic organizers group coaching
 
Graphic Design Projects
Graphic Design ProjectsGraphic Design Projects
Graphic Design Projects
 
3D Graphic Designer Freelance
3D Graphic Designer Freelance   3D Graphic Designer Freelance
3D Graphic Designer Freelance
 
Advance Graphic Design Final Exam 71%
Advance Graphic Design Final Exam 71%Advance Graphic Design Final Exam 71%
Advance Graphic Design Final Exam 71%
 
Ed tech 105a topic 1 history of edtech
Ed tech 105a topic 1 history of edtechEd tech 105a topic 1 history of edtech
Ed tech 105a topic 1 history of edtech
 
Graphic Design Intro
Graphic Design IntroGraphic Design Intro
Graphic Design Intro
 
Ome1
Ome1Ome1
Ome1
 
Gaphic design in brand promotion
Gaphic design in brand promotionGaphic design in brand promotion
Gaphic design in brand promotion
 
Chapter 1 introduction to educational technology
Chapter 1 introduction to educational technologyChapter 1 introduction to educational technology
Chapter 1 introduction to educational technology
 
Transefermation
TransefermationTransefermation
Transefermation
 
A way to professional merchandising
A way to professional merchandisingA way to professional merchandising
A way to professional merchandising
 

Similar to Cg

CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
RajJain516913
 
Object tracking by dtcwt feature vectors 2-3-4
Object tracking by dtcwt feature vectors 2-3-4Object tracking by dtcwt feature vectors 2-3-4
Object tracking by dtcwt feature vectors 2-3-4
IAEME Publication
 

Similar to Cg (20)

Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
Cgm Lab Manual
Cgm Lab ManualCgm Lab Manual
Cgm Lab Manual
 
computer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcodecomputer graphics-C/C++-dancingdollcode
computer graphics-C/C++-dancingdollcode
 
Lecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.pptLecture _Line Scan Conversion.ppt
Lecture _Line Scan Conversion.ppt
 
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdfCD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
CD504 CGM_Lab Manual_004e08d3838702ed11fc6d03cc82f7be.pdf
 
lecture 1.pptx
lecture 1.pptxlecture 1.pptx
lecture 1.pptx
 
Computer graphics lab manual
Computer graphics lab manualComputer graphics lab manual
Computer graphics lab manual
 
Computer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdfComputer Graphics Notes 2.pdf
Computer Graphics Notes 2.pdf
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Unit 2
Unit 2Unit 2
Unit 2
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Object tracking by dtcwt feature vectors 2-3-4
Object tracking by dtcwt feature vectors 2-3-4Object tracking by dtcwt feature vectors 2-3-4
Object tracking by dtcwt feature vectors 2-3-4
 
Gesture Recognition Based Video Game Controller
Gesture Recognition Based Video Game ControllerGesture Recognition Based Video Game Controller
Gesture Recognition Based Video Game Controller
 
DimensionalityReduction.pptx
DimensionalityReduction.pptxDimensionalityReduction.pptx
DimensionalityReduction.pptx
 
Comparison of Various RCNN techniques for Classification of Object from Image
Comparison of Various RCNN techniques for Classification of Object from ImageComparison of Various RCNN techniques for Classification of Object from Image
Comparison of Various RCNN techniques for Classification of Object from Image
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx4 CG_U1_M3_PPT_4 DDA.pptx
4 CG_U1_M3_PPT_4 DDA.pptx
 
An Efficient Multiplierless Transform algorithm for Video Coding
An Efficient Multiplierless Transform algorithm for Video CodingAn Efficient Multiplierless Transform algorithm for Video Coding
An Efficient Multiplierless Transform algorithm for Video Coding
 

Recently uploaded

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
Avinash Rai
 

Recently uploaded (20)

Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
Mattingly "AI & Prompt Design: Limitations and Solutions with LLMs"
 
Industrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training ReportIndustrial Training Report- AKTU Industrial Training Report
Industrial Training Report- AKTU Industrial Training Report
 
Benefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational ResourcesBenefits and Challenges of Using Open Educational Resources
Benefits and Challenges of Using Open Educational Resources
 
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
GIÁO ÁN DẠY THÊM (KẾ HOẠCH BÀI BUỔI 2) - TIẾNG ANH 8 GLOBAL SUCCESS (2 CỘT) N...
 
Home assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdfHome assignment II on Spectroscopy 2024 Answers.pdf
Home assignment II on Spectroscopy 2024 Answers.pdf
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdfINU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
INU_CAPSTONEDESIGN_비밀번호486_업로드용 발표자료.pdf
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx2024_Student Session 2_ Set Plan Preparation.pptx
2024_Student Session 2_ Set Plan Preparation.pptx
 
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdfDanh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
Danh sách HSG Bộ môn cấp trường - Cấp THPT.pdf
 
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptxSolid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
Solid waste management & Types of Basic civil Engineering notes by DJ Sir.pptx
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Salient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptxSalient features of Environment protection Act 1986.pptx
Salient features of Environment protection Act 1986.pptx
 
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptxJose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
Jose-Rizal-and-Philippine-Nationalism-National-Symbol-2.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Forest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDFForest and Wildlife Resources Class 10 Free Study Material PDF
Forest and Wildlife Resources Class 10 Free Study Material PDF
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 

Cg

  • 1. UNIT-1 Introduction to Computer Graphics Computer Graphics is the area where we study about audio,vedeo and animation of the objects or we can also say that drawing pictures on the screen is also called computer graphics. We can also say that its an art of drawing pictures on computer screen with the help of programming. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 1
  • 2. APPLICATION OF COMPUTER GRAPHICS Computer graphics user interfaces (GUIs) – A graphic, mouse-oriented paradigm which allows the user to interact with a computer. Cartography – Drawing maps. Weather Maps – Real-time mapping, symbolic representations. Satellite Imaging - Geodesic images. Photo Enhancement - Sharpening blurred photos. Medical imaging - MRIs, CAT scans, etc. - Non-invasive internal examination. Engineering drawings - mechanical, electrical, civil, etc. - Replacing the blueprints of the past. Typography - The use of character images in publishing - replacing the hard type of the past. Architecture - Construction plans, exterior sketches - replacing the blueprints and hand drawings . 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 2
  • 3. Types of computer graphics Basically there are two types of computer graphics Raster Graphics Raster graphics can be prepared with the help of individual pixels & Its also called Bitmap images. A bitmap image contains a grid of individual images 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 3
  • 4. Vector Graphics In this technique, the electron beam is directed only to the part of the screen where the picture is to be drawn rather than scanning from left to right and top to bottom as in raster scan. It is also called vector display, stroke-writing display, or calligraphic display. Its also useses mathematical relationship between points & path. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 4
  • 5. Frame Buffer & video controller A frame buffer is a memory of contiguous location & Typically it is stored in the memory chips on the video adapter. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 5
  • 6. Video controller It is used to control the operation of the display device (Monitor/Screen). Video controller accesses the frame buffer to refresh the screen. In figure, the basic refresh operations of the video-controller are shown. Raster System Register 1 Register 2 Memory References Frame Buffer Pixel Record 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 6
  • 7. Line Drawing Algorithms For drawing a line we need two end points so there are some algorithms that provide line generation. We know that Y=Mx + C Where M=(Y2-Y1)/(X2-X1) DDAAlgorithm: The full name of this algorithm is Digital Differential Analyzer & the basics concept of this algo is as follows 1.A line can be specified in the form: Y=mx+c 2.Let m be between 0 to 1, then the slope of the line is between 0 and 45 degrees. 3. For the x-coordinate of the left end point of the line, compute the corresponding y value according to the line equation. Thus we get the left end point as (x1,y1), where y1 may not be an integer 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 7
  • 8. 4. Calculate the distance of (x1,y1) from the center of the pixel immediately above it and call it D1. 5.Calculate the distance of (x1,y1) from the center of the pixel immediately below it and call it D2. 6.If D1 is smaller than D2, it means that the line is closer to the upper pixel than the lower pixel, then, we set the upper pixel to on; otherwise we set the pixel. 7. This method assumes the width of the line to be zero. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 8
  • 9. The Bresenham’s algorithm This is the another incremental scan conversion algorithm & The major advantage of this algorithm is that, it uses only integer calculations not the fraction. Moving across the x axis in unit intervals and at each step choose between two different y coordinates. Step 1 − Input the two end-points of line, storing the left end- point in (x0,y0). Step 2 − Plot the point (x0,y0). Step 3 − Calculate the constants dx, dy, 2dy, and (2dy – 2dx) and get the first value for the decision parameter as p0=2dy−dx Step 4 − If pk < 0, the next point to plot is (xk+1,yk) and pk+1=pk+2dy Otherwise, pk+1=pk+2dy−2dx Step 5 − Repeat step 4 (dx – 1) times. For m > 1, find out whether we need to increment x while incrementing y each time. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 9
  • 10. Circle Generation Algorithm The first thing we can notice to make our circle drawing algorithm more efficient is that circles centred at (0, 0) have Eight-way symmetry (x, y) (y, x) (y, -x) (x, -y)(-x, -y) (-y, -x) (-y, x) (- x,y) 2 R 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 10
  • 11. Mid Point Circle Generation Algo Mid Point algo is the one of the circle generation algo which is depend on eight point symmetry. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 11
  • 12. BRESENHAM’S CIRCLE ALGORITHM 1. Set X = 0 and Y = R 2.Set D = -(-3 +2R) 3.Repeat While (X < Y) 4. Call Draw Circle(X1, Y1, X, Y) 5. Set X = X + 1 6. If (D < 0) Then 7. D = D + 4X + 6 8. Else 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 12
  • 13. Continued…… 9. Set Y = Y –1 10. D = D + 4(X –Y) + 10 [End of If] 11. Call Draw Circle(X1, Y1, X, Y) [End of While] 12.Exit 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 13
  • 14. UNIT-II Transformations Basic Transformation Transformed point=Transformation Matrix*Original Matrix Translation Rotation Scaling 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 14
  • 15. Matrix Representation T = 1 0 tx 0 1 ty 0 0 1 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 15
  • 16. Translation A translation basically means adding a vector to a point, making a point transforms to a new point Changing the position of the object P’(x’,y’) Translated Place P(x,y) Original Place 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 16
  • 17. Coordinate System Rotation Changing the position with angle Ø 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 17
  • 18. Coordinate System Scaling Reduces the size of the object(Magnifies) a’=aSa b=bSb 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 18
  • 19. Composite Transformation It is a special type of transformation which consider various aspects of transformation compare to basic. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 19
  • 20. Composite Transformation Some are as follows 1. Rotation about an arbitrary point 2. Scaling about a arbitrary Point 3. Reflection of an object about any line 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 20
  • 21. Composite Transformation Equations 1. RØ,P=TvRØT-v 2. S(Sx,Sy) , P(h,k)=Tv Sxy Sy T-v 3.Mr=TvRØMxR-ØT-v 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 21
  • 22. Windowing & Clipping windowing system is a system for sharing a computer's graphical display presentation resources to various multiple applications at the same time Clipping is the process of cutting the portion of the object with the help of specific algorithm or dimension. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 22
  • 23. Clipping  We need to clip objects outside the canonical view volume  Clipping lines (Cohen-Sutherland algorithm)  Clipping polygons (Sutherland-Hodgman algorithm) 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 23
  • 24. Clipping aaa X Axis 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 24
  • 25. Clipping 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 25
  • 26. Line Clipping Algo. 1. Cohen Sutherland Line clipping algo. 2.Liang Barsky line clipping algo. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 26
  • 27. Cohen–Sutherland algo  This algo is used for line clipping & follow the divide-and- conquer strategy.  The algorithm divides a two-dimensional space into 9 regions  Efficiently determines the lines and portions of lines that are visible in the centre region of interest (the viewport). 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 27
  • 28. Cohen–Sutherland algo  Given a line segment with endpoint A(q1,q2) and B(q2,q3)  Compute the 4-bit codes for each endpoint. If both codes are 0000,(bitwise OR of the codes yields 0000 ) line lies completely inside the window If both codes have a 1 in the same bit position (bitwise AND of the codes is not 0000), the line lies outside the window. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 28
  • 29. Continued….  If a line cannot be trivially accepted or rejected, at least one of the two endpoints must lie outside the window and the line segment crosses a window edge.  Examine one of the endpoints, say P1=(q1,q2) . Read P1 as 4-bit code in order: Left-to-Right, Bottom-to-Top.  When a set bit (1) is found, compute the intersection I of the corresponding window edge with the line from to . P1 to P2 Replace P1 with I and repeat the algorithm. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 29
  • 30. Continued…. After clipping 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 30
  • 31. Liang Barsky algorithm Liang and Barsky have created an algorithm that uses floating-point arithmetic but finds the appropriate end points with at most four computations  Express line segments in parametric form.  Derive equations for testing if a point is inside the window  Compute new parameter values for visible portion of line segment, if any  Display visible portion of line segment 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 31
  • 32. Liang Barsky algorithm  Read two end points of line P1 (x1, y1) and P2 (x2, y2)  Read two corner vertices, left top and right bottom of window: (XwMIN, YwMAX) and (XwMAX, YwMIN)  Calculate values of parameters pi and qi for I =1, 2, 3, 4 such that p1 = -Δx q1 = x1 – XwMIN p2 = Δx q2 = XwMAX – xi q1 = – Δy q3 = y1 – YwMIN 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 32
  • 33. Continued…. q2 = Δy q4 = YwMAX – y1  If pi = 0 then, { Line is parallel to ith boundary. If qi < 0 then, { Line is completely outside the boundary. Therefore, discard line segment and Go to Step 10. } 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 33
  • 34. Continued…. else If line endpoints lie within the bounded area then use them to draw line. Otherwise use boundary coordinates to draw line. Go to Step 10.  Initialize t1 = 0 and t2 = t1  Calculate values for qi/pi for i= 1,2,3,4 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 34
  • 35. Continued….  Select values of qi/pi where pi<0 and assign maximum out of them as t1.  Select values of qi/pi where pi>0 and assign maximum out of them as t2.  If (t1 < t2) { Calculate endpoints of clipped line: xx1 = x1 + t1 Δx xx2 = x1 + t2 Δx yy1 = y1 + t1 Δy yy2 = y1 + t2 Δy Draw line (xx1, yy1, xx2, yy2) }  Stop. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 35
  • 36. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 36
  • 37. Polygon clipping 1.Sutherland Hodgeman Algorithm 2. Weiler and Atherton polygon clipping 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 37
  • 38. Sutherland Hodgeman Algorithm  Polygons can be clipped against each edge of the window one at a time. windows/edge intersections, if any, are easy to find since the X or Y coordinates are already known.  Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 38
  • 39. Sutherland …….  Note that the number of vertices usually changes and will often increases.  We are using the Divide and Conquer approach. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 39
  • 40. Conditions of Polygon Clipping Algo C 1 : Wholly inside visible region - save endpoint C 2: Exit visible region - save the intersection C 3 : Wholly outside visible region - save nothing C 4 : Enter visible region - save intersection and end point . 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 40
  • 41. Steps of Sutherland ……. Step 1: Clip Right of the Boundary Step 2: Clip Bottom Boundary Step 3:Clip Left Boundary Step 4:Clip Top Boundary 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 41
  • 42. Weiler and Atherton polygon clipping This algorithm is used for clipping concave polygons 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 42
  • 43. Weiler and Atherton Algo.  In this algorithm we take a starting vertex like I1  And traverse the polygon like I1, V3, I2.  Leaving intersection the algorithm follows the clip polygon vertex list from leaving vertex in downward direction. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 43
  • 44. Weiler and Atherton Algo.  At occurrence of entering intersection the algorithm follows subject polygon vertex list from the entering intersection vertex.  This process is repeated till we get starting vertex.  This process has to be repeated for all remaining entering intersections which are not included in the previous traversing of vertex list. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 44
  • 45. TYPE OF TEXT CLIPPING A. Stardust B. Bitmap C. Stroke 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 45
  • 46. STARDUST  This method of character generation is called stardust method because of its characteristics appearance.  a code conversion software is used in it to display a character .  A character quality is also poor. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 46
  • 47. BITMAP  In bitmap method characters are represented by array of dots in the matrix form.  It is 2D array that means having rows and columns.  Each dot in the matrix is pixel.  The value of pixel control the intensity of the pixel. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 47
  • 48. STROKE  This method uses small line segments to generate a character  we can built our own stoke method character generate by call through the line drawing algorithm.  In this method a fixed pattern of line segments are used to generate the characters.  There are 24 line segments. out of these 24 line segments the segments required to display for a particular character are highlighted. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 48
  • 49. UNIT-III 3D Geometric Primitives  Polygon meshes and polyhedra are the geometric figures that are created with a surface modeler.  A polygon mesh is a collection of edges, vertices and polygons connected in such a way that each edge is shared by at most two polygons.  Polyhedra are volumetric solids, such as the cube or a sphere, represented as facets. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 49
  • 50. 3D Object Representation  Polygon and Quadric surfaces  Spline surfaces and construction  Procedural methods 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 50
  • 52. Rotation In 3D rotation, we have to specify the angle of rotation along with the axis of rotation Rotation about x-axis X-Axis Y Axis Z Axis1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 52
  • 53. Y Axis X Axis Z Axis Rotation About Y Axis 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 53
  • 54. Y Axis X Axis Z Axis Rotation About Z Axix 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 54
  • 55. 3D Viewing For representing 3D-objects on a 2D -screen in a nice or recognizable way, many techniques are combined. First, the projection has to be defined, which will be described in the next paragraph 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 55
  • 56. Possible Qualities Wire-Frame-Representation: Only the edges of polygons are drawn. Depth-Cueing = Edges or parts which are nearer to the viewer are displayed with more intensity. Correct Visibility = Surface-elements (edges, polygons), which are occluded by other surface-elements, are not drawn so that only visible areas are shown. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 56
  • 57. 3D-Viewing-Pipeline Object Coordinate world Co. Viewing Co. Projection Co. Normdivice Co. Device Coordinate Creation of Object Creation of Object Definition Projection Mapping Transform to specific region 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 57
  • 58. Projections Process of moving in positive with time through imaging of future events or calculation based on past trends. However, in computer graphics mainly only the parallel and the perspective projection are used generally. In geometry science various types of projections are known 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 58
  • 59. Projections Y Z X 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 59
  • 60. Projections Parallel Projection Perspective Projection 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 60
  • 61. Perspective Projections One Point Two Point Three Point 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 61
  • 62. For parallel projections, we specify a direction of projection instead of a Centre of projection There are two types of parallel projections: Orthographic projection – DOP perpendicular to PP Oblique projection --- DOP not perpendicular to PP 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 62
  • 63. 3D Clipping In 3D clipping you do everything in 3D space. Map graphics are clipped to one side of an arbitrary clipping plane in one or more clipping stages. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 63
  • 64. Cohen Sutherland 3D Clipping Algo The outcode for 3D clipping is a 6-bit code  Bit 1 - point above view volume  Bit 2 - point below view volume  Bit 3 - point to the right of view volume  Bit 4 - point to the left of view volume  Bit 5 - point behind view volume  Bit 6 - point in front of view volume 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 64
  • 65. UNIT-IV Bézier curve A Bézier curve approximates any number of control points for a curve section 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 65
  • 66. Curves and Surfaces Quadric surfaces X Y 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 66
  • 67. X Y Quadratic Surfaces 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 67
  • 68. Blobby Object  A Blobby Object is non rigid object like  Like rubber,liquids,water droplets cloths etc.  These objects tend to exhibit a degree of fluidity 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 68
  • 69. Continued….  Several models have been developed to handle these kind of objects.  One technique is to use a combination of Gaussian density functions (Gaussian bumps) 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 69
  • 70. Spline Representations  A spline is a flexible strip used to produce a smooth curve through a designated set of points  Small weights would be distributed along the strip to hold  it in position on the drafting table 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 70
  • 71. Spline Specifications There are three different ways to specify splines  state the set of boundary conditions that are imposed on the spline  state the matrix that characterizes the spline  state a set of blending/basis function that determines how specified constraints on the curve are combined to calculate positions along the curve path 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 71
  • 72. Boundary Condition Example  Boundary conditions may be the coordinates of x(0), x(1) and the derivatives x’(0), x’(1). These four numbers are enough to fix ax, bx, cx, dx  After this representation we can connected to the other representations. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 72
  • 73. Interpolation and Approximation Splines To specify a spline we need to give a set of coordinate positions called control points 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 73
  • 74. Hidden Lines and Surfaces  Back-Face Detection  Depth-Buffer Methods  A-Buffer Methods  Scan-Line Methods  Depth-Sorting Method 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 74
  • 75. Basic illumination models  Light Sources  Basic Illumination Models  Displaying Light Intensities 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 75
  • 76. Ambient Light  Approximates the indirect illumination  Equal amount of light from all directions  I K=(I is intensity of ambient light & K=percentage of the light reflected by the object) 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 76
  • 77. Lighting at a point on surface surface I = Ikdcosθ I=intensity of light K=coefficient of diffuse reflection 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 77
  • 78. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 78 A B C Surface P
  • 79. Diffuse reflection I = Idkd(N.L) Id(N.L) is like the irradiance kdI is like the reflectivit No dependency on viewer 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 79
  • 80. Specular reflection and Phong model 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 80 P A A2
  • 81. Specular Component Component  One area depend on other  Some time depends on both  Numbers controls the view dependency. 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 81
  • 82. Intensity Attenuation  Providing enough control so that one can simulate effect via trial and error of many different parameters  May be not be close to the physical phenomenon  If we see different brightness of the same light can be used for different component computation 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 82
  • 83. Properties of Bézier curves  Passes through start and end points P0 & Pn.  First derivates at start and end  Lies in the convex hull 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 83
  • 84. Shading  Independent of the Illumination model used  Phong Shading and Phong Illumination  Simple and hence widely used 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 84
  • 85. Phong Shading  Calculate the illumination at every pixel using rasterization  Interpolate the normal across the triangle  Slower than Gauaurd 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 85
  • 86. Gouraud Shading Shading  Edges get same color, irrespective of which triangle they are rendered from Shading is continuous at edges  Tends to spread sharp illumination spots over the triangle THANKS 1/11/2017 Amit Kr Pathak(CSE Deptt) Asst.Prof. 86