CG Full Sem
CG Full Sem
CG Full Sem
algorithm
Homogenous Coordinates
Translation
Reflection On Y-Axis:
This reflection is achieved by using the following reflection
equations-
Xnew = -Xold
Ynew = Yold
In Matrix form, the above reflection equations may be
represented as-
For homogeneous coordinates, the above reflection matrix may be
represented as a 3 x 3 matrix as-
PRACTICE PROBLEMS BASED ON 2D
REFLECTION IN COMPUTER GRAPHICS-
Problem-01:
Given a triangle with coordinate points A(3, 4), B(6, 4), C(5, 6).
Apply the reflection on the X axis and obtain the new coordinates
of the object.
Solution-
Given-
Old corner coordinates of the triangle = A (3, 4), B(6, 4),
C(5, 6)
Reflection has to be taken on the X axis
For Coordinates A(3, 4)
Let the new coordinates of corner A after reflection = (Xnew, Ynew).
Applying the reflection equations, we have-
Xnew = Xold = 3
Ynew = -Yold = -4
Thus, New coordinates of corner A after reflection = (3, -4).
Sutherland-Hodgeman Polygon Clipping:
It is performed by processing the boundary of polygon against each window
corner or edge. First of all entire polygon is clipped against one edge, then
resulting polygon is considered, then the polygon is considered against the
second edge, so on for all four edges.
1. If the first vertex is an outside the window, the second vertex is inside
the window. Then second vertex is added to the output list. The point
of intersection of window boundary and polygon side (edge) is also
added to the output line.
2. If both vertexes are inside window boundary. Then only second vertex
is added to the output list.
3. If the first vertex is inside the window and second is an outside
window. The edge which intersects with window is added to output list.
4. If both vertices are the outside window, then nothing is added to
output list.
Following figures shows original polygon and clipping of polygon against four
windows.
4. Entertainment:
Computer graphics finds a major part of its utility in the movie
industry and game industry. Used for creating motion
pictures , music video, television shows, cartoon animation
films. In the game industry where focus and interactivity are
the key players, computer graphics helps in providing such
features in the efficient way.
5. Education:
Computer generated models are extremely useful for teaching
huge number of concepts and fundamentals in an easy to
understand and learn manner. Using computer graphics many
educational models can be created through which more
interest can be generated among the students regarding the
subject.
6. Training:
Specialised system for training like simulators can be used for
training the candidates in a way that can be grasped in a short
span of time with better understanding. Creation of training
modules using computer graphics is simple and very useful.
7. Visualisation:
Today the need of visualise things have increased drastically,
the need of visualisation can be seen in many advance
technologies , data visualisation helps in finding insights of the
data , to check and study the behaviour of processes around
Write a boundary fill procedure to fill 8-
connected region. Polygon Filling:-
Filling the polygon means highlighting all the pixels which lie inside the
polygon with any colour other than background colour. Polygons are easier
to fill since they have linear boundaries.
Another approach to fill the polygon is to apply the inside test i.e. to check
whether the pixels is inside the polygon or outside the polygon and then
highlight pixels which lie inside the polygon. This approach is known
as scan-line algorithm It avoids the need for seed pixel it requires some
computation.
Seed Fill :-
Procedure:-
8-connected boundary / edge fill Algorithm:-
Parallel Projection
Parallel Projection use to display picture in its true shape and size. When projectors are
perpendicular to view plane then is called orthographic projection. The parallel
projection is formed by extending parallel lines from each vertex on the object until they
intersect the plane of the screen. The point of intersection is the projection of vertex.
Parallel projections are used by architects and engineers for creating working drawing of
the object, for complete representations require two or more views of an object using
different planes.
1. Isometric Projection: All projectors make equal angles generally angle is of 30°.
2. Dimetric: In these two projectors have equal angles. With respect to two principle axis.
3. Trimetric: The direction of projection makes unequal angle with their principle axis.
4. Cavalier: All lines perpendicular to the projection plane are projected with no change in
length.
5. Cabinet: All lines perpendicular to the projection plane are projected to one half of their
length. These give a realistic appearance of object.
Difference Between Parallel Projection And Perspective
Projection :
SR.N
O Parallel Projection Perspective Projection
Scan-Line Method
It is an image-space method to identify visible surface. This
method has a depth information for only single scan-line. In
order to require one scan-line of depth values, we must group
and process all polygons intersecting a given scan-line at the
same time before processing the next scan-line. Two important
tables, edge table and polygon table, are maintained for this.
The Edge Table − It contains coordinate endpoints of each line
in the scene, the inverse slope of each line, and pointers into the
polygon table to connect edges to surfaces.
The Polygon Table − It contains the plane coefficients, surface
material properties, other surface data, and may be pointers to
the edge table.
Area-Subdivision Method
The area-subdivision method takes advantage by locating those view areas
that represent part of a single surface. Divide the total viewing area into
smaller and smaller rectangles until each small area is the projection of part
of a single visible surface or no surface at all.
Back-Face Detection
A fast and simple object-space method for identifying the back faces of a
polyhedron is based on the "inside-outside" tests. A point x,y,zx,y,z is
"inside" a polygon surface with plane parameters A, B, C, and D if When an
inside point is along the line of sight to the surface, the polygon must be a
back
face weareinsidethatfaceandcannotseethefrontofitfromourviewin
gpositionweareinsidethatfaceandcannotseethefrontofitfromourviewingposit
ion.
In general, if V is a vector in the viewing direction from the
eye or"camera"or"camera" position, then this polygon is a back face if
In a right-handed viewing system with viewing direction along the
negative ZVZV axis, the polygon is a back face if C < 0. Also, we cannot see
any face whose normal has z component C = 0, since your viewing direction
is towards that polygon. Thus, in general, we can label any polygon as a
back face if its normal vector has a z component value −
C <= 0
A-Buffer Method
The A-buffer method is an extension of the depth-buffer method.
The A-buffer method is a visibility detection method developed at
Lucas film Studios for the rendering system Renders Everything
You Ever Saw REYESREYES.
The A-buffer expands on the depth buffer method to allow
transparencies. The key data structure in the A-buffer is the
accumulation buffer.
Each position in the A-buffer has two fields −
Depth field − It stores a positive or negative real number
Intensity field − It stores surface-intensity information or
a pointer value
Hermite curve
A Hermite curve is a spline where every piece is a third degree
polynomial defined in Hermite form: that is, by its values and
initial derivatives at the end points of the equivalent domain
interval. Cubic Hermite splines are normally used for interpolation
of numeric values defined at certain dispute values x1,x2,x3,
…..xn,to achieve a smooth continuous function. The data should
have the preferred function value and derivative at each Xk. The
Hermite formula is used to every interval (Xk,
Xk+1) individually. The resulting spline become continuous and
will have first derivative.
Cubic polynomial splines are specially used in computer
geometric modeling to attain curves that pass via defined points
of the plane in 3D space. In these purposes, each coordinate of
the plane is individually interpolated by a cubic spline function of
a divided parameter‘t’.
Cubic splines can be completed to functions of different
parameters, in several ways. Bicubic splines are frequently used
to interpolate data on a common rectangular grid, such as pixel
values in a digital picture. Bicubic surface patches, described by
three bicubic splines, are an necessary tool in computer graphics.
Hermite curves are simple to calculate but also more powerful.
They are used to well interpolate between key points.
Animation Functions
1. 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.
The process of Morphing involves three steps:
1. In the first step, one initial image and
other final image are added to morphing
application as shown in fig: Ist & 4th object
consider as key frames.
The second step involves the selection of key
points on both the images for a smooth transition
between two images as shown in 2nd object.
3. In the third step, the key point of the first
image transforms to a corresponding key point of
the second image as shown in 3rd object of the
figure.
2. 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.
3. 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.
2.
4. 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 as shown in fig:
Ro ta te A P o int
Ab o u t An
Arb i tr ary Ax is
(3 Di men si o n s)
(2) rotate space about the x axis so that the rotation axis lies
in the xz plane
(3) rotate space about the y axis so that the rotation axis lies
along the z axis
Note:
Step 1
Translate space so that the rotation axis passes through the origin.
This is accomplished by translating space by -P1 (-x1,-y1,-z1). The
translation matrix T and the inverse T-1 (required for step 7) are
given below
x' x
y' y
= T-1 Rx-1 Ry-1 Rz Ry Rx T
z' z
1 1
Using quaternions
To rotate a 3D vector "p" by angle theta about a (unit) axis "r" one
forms the quaternion
Q1 = (0,px,py,pz)
Q3 = Q2 Q1 Q2*
Q3 = Q2* Q1 Q2
Z-Buffer Algorithm
It is also called a Depth Buffer Algorithm. Depth buffer algorithm is
simplest image space algorithm. For each pixel on the display screen, we
keep a record of the depth of an object within the pixel that lies closest to
the observer. In addition to depth, we also record the intensity that should
be displayed to show the object. Depth buffer is an extension of the frame
buffer. Depth buffer algorithm requires 2 arrays, intensity and depth each of
which is indexed by pixel coordinates (x, y).
Algorithm
For all pixels on the screen, set depth [x, y] to 1.0 and intensity [x, y] to a
background value.
For each polygon in the scene, find all pixels (x, y) that lie within the
boundaries of a polygon when projected onto the screen. For each of these
pixels:
(b) If z < depth [x, y], this polygon is closer to the observer than others
already recorded for this pixel. In this case, set depth [x, y] to z and
intensity [x, y] to a value corresponding to polygon's shading. If instead z >
depth [x, y], the polygon already recorded at (x, y) lies closer to the
observer than does this new polygon, and no action is taken.
3. After all, polygons have been processed; the intensity array will contain
the solution.
3. Graphical language:
B-spline
Jump to navigationJump to search
Spline curve drawn as a weighted sum of B-splines with control
points/control polygon, and marked component curves
In the mathematical subfield of numerical analysis, a B-
spline or basis spline is a spline function that has
minimal support with respect to a given degree, smoothness,
and domain partition. Any spline function of given degree can be
expressed as a linear combination of B-splines of that degree.
Cardinal B-splines have knots that are equidistant from each
other. B-splines can be used for curve-fitting and numerical
differentiation of experimental data.
In computer-aided design and computer graphics, spline
functions are constructed as linear combinations of B-splines with
a set of control points.
Shear