Cgmini
Cgmini
Floating point arithmetic in DDA algorithm is still • One method of doing this is to construct a line segment
time consuming. • The algorithm is orientation between a point in question i.e. point to test whether
dependent. Hence end point accuracy is poor. • inside or outside, and a point which is surely outside the
Although DDA is fast, the accumulation of round-off polygon. But ow we are going to find out a point which is
error in successive additions of floating point surely outside the polygon? It is very easy to find out that
increment, however can cause the calculation pixel point. • For example, pick a point with an x co-ordinate
position to drift away from the true line path for smaller than the smallest coordinate of the polygons
long line segment. • Rounding-off in DDA is time vertices and the y co-ordinate will be any y value, or for
consuming. • Because of round off, errors are simplicity we will take y value same as the y value of point
introduced and causes the calculated pixel position in question. • In this case point A is one, which we want to
to drift away from the true line path. • Because of check i.e. whether point A is inside polygon or not. • As we
floating point operation the algorithm is time are using arrays to store vertices of polygon we can easily
consuming. come to know the vertex which is having lowest value of x
and that is x1. So we have to select a point smaller than x1
ALIASING ANTIALIASING WITH ONE EXAMPLE and generally we select same value of y as that of point A,
• In computer graphics, the process by which smooth curves • Antialiasing is a term for techniques that are designed to mitigate
and other lines become jagged because the resolution of the in order to draw straight line. But even if you select any y
the effects of aliasing. • The idea is that when a pixel is only
graphics device or file is not high enough to represent a smooth value for outside point, it will not make any difference.
partially covered by a shape, the colour of the pixel should be a
curve. • In the line drawing algorithms, we have seen that all mixture of the colour of the shape and the colour of the
rasterized locations do not match with the true line and we background. • When drawing a black line on a white background,
have to select the optimum raster locations to represent a the colour of a partially covered pixel would be grey, with the
straight line. This problem is severe in low resolution screens. In shade of grey depending on the fraction of the pixel that is covered
such screens line appears like a stair-step, as shown in the by the line. • The technique of anti-aliasing is: • Prefiltering: This is
figure below. This effect is known as aliasing. It is dominant for technique that determines pixel intensity based on the amount of
lines having gentle and sharp slopes. that particular pixel coverage by the object in the scene i.e. It
computes pixel colours depending on the objects coverage. • It
means how much part or fraction of that pixel is covered by the
object and depending on that, it sets the value of the pixel. It
requires large number of calculations and approximations.
Prefiltering generates more accurate antialiasing effect. But due to
its high complexity of calculations it is not used.
LIANG BARSKY
• The Liang-Barsky algorithm uses the parametric equation of a
line and inequalities describing the range of the clipping box to
determine the intersections between the line and clipping box.
With these intersections it knows which portion of the line
should be drawn. This algorithm is more efficient than Cohen-
Sutherland. The ideas for clipping line of Liang-Barsky and cyrus-
Beck are the same. The only difference is Liang-Barsky algorithm
has been optimized for an upright rectangular clip window. So we
will study only the idea of Liang Barsky. • Liang and Barsky have
created an algorithm that uses floating-point arithmetic but finds
the appropriate ends points with at most four computations. This
algorithm uses the parametric equations for a line and solves for
inequalities to find the range of the parameter for which the line
BEZEIR CURVES AND ITS PROPERTIES.
is in the viewport.
Bezier Curves in Computer Graphics are simple and easy to draw.
Bezier Curves are actually approximation curves. They need not pass
through each and every control point. They are generally suitable for
Parallel Projection: i. In parallel projection, Z coordinate is automobile design and making arcs. I think we should see the
discarded and parallel lines from each vertex on the object are properties of Bezier curves first. Then we will see the way to represent
extended until they intersect the view plane. ii. The point of them and create them.Bezier Curve and its important
intersection is the projection of the vertex. iii. We connect the properties:1.Bezier curve always passes through the first and last
projected vertices by line segments which correspond to control point.The other control points affect the shape of the curve,
connections on the original object. iv. A parallel projection but it does not pass through them.2.Bezier segments have the
preserves relative proportions of objects. v. Accurate views of property that they always stay inside the convex hull of their control
the various sides of an object are obtained with a parallel points.3.The slope of the curve initially is along the line joining the
projection. But not a realistic representation. first two control points. While the slope(tangent) at the end is along
Perspective projection: the lines of projection are not parallel. the line joining the last two control points.4.Bezier blending functions
ii. Perspective Projection transforms object positions to the are all positive and their sum is always 1.
view plane while converging to a center point of projection. iii.
In this all the projections are converge at a single point called
the “center of projection” or “projection reference point”. iv.
Perspective projection produces realistic views but does not
preserve relative proportions. v. Projections of distant objects
are smaller than the projections of objects of the same size
that are closer to the projection plane.
• The Koch curve can be drawn by dividing line into 4 equal
segments with scaling factor 1/3 and middle two segments are so
adjusted that they form adjacent sides of an equilateral triangle
• A fractal is defined as a rough or fragmented geometric shape as shown in the Fig. 16(a) .This is the first approximation to the
that can be split into parts, each of which is approximately a koch curve. • To apply the second approximation to the Koch
reduced-size reproduction of the complete shape based on the curve we have to repeat the above process for each of the four
property known as self- similarity. It was derived from the Latin segments. The resultant curve is shown in Fig.16.b() WINDOW AND VIEWPORT
word fractus which means broken or fractured. Natural objects Window: 1. A world-coordinate area selected for display is called
can be realistically described using fractal geometry methods. a window. 2. In computer graphics, a window is a graphical
Example.- cloud, mountains, trees, stone etc. • Fractal methods control element. 3. It consists of a visual area containing some of
use procedures rather than equations to model objects. so it uses the graphical user interface of the program it belongs to and is
procedural modelling. The major characteristic of any procedural framed by a window decoration. 4. A window defines a
model is that the model is not based on data ,but rather on the rectangular area in world coordinates. You define a window with
implementation of the procedure following a particular set of a GWINDOW statement. You can define the window to be larger
rules. • A fractal combines the following characteristic: • Its parts than, the same size as, or smaller than the actual range of data
have the same form or structure as a whole, except that they are values, depending on whether you want to show all of the data or
at a different scale and may be slightly deformed. • Its form is only part of the data. Viewport: 1. An area on a display device to
extremely irregular or fragmented, and remains so, whatever the which a window is mapped is called a viewport. 2. A viewport is a
scale of examination. • It is formed by iteration i.e. the procedure polygon viewing region in computer graphics. The viewport is an
is used repeatedly(recursively) • Example: if P0 = (X0, Y0, Z0) is a area expressed in rendering-device-specific coordinates, e.g.
selected initial position, the successive levels P1 = F (P0), P2 = F • From the above figures we can easily note following pixels for screen coordinates, in which the objects of interest are
(P1), …… Pn = F (Pn-1) are generated by a transformation function points about the koch curve : o Each repetition increases going to be rendered. 3. A viewport defines in normalized
F. • Fractional dimensions. the length of the curve by factor 4/3. o Length of curve is coordinates a rectangular area on the display device where the
infinite. o Unlike Hibert's curve, it doesn’t fill an area. o It image of the data appears. You define a viewport with the GPORT
doesn’t deviate much from its original shape. command. You can have your graph take up the entire display
device or show it in only a portion, say the upper-right part.
FLOOD FILL APPROACH FOR 8 CONNECTED METHOD PROVE THAT TWO SUCCESSIVE ROTATIONS ARE ADDITIVE
• The limitations of boundary fill algorithm are overcome in flood fill
algorithm. Like boundary fill algorithm this algorithm also begins with
seed point which must be surely inside the polygon. • Now instead of
checking the boundary colour this algorithm checks whether the pixel
is having the polygons original colour i.e. previous or old colour. • If
yes, then fill that pixel with new colour and uses each of the pixels
neighbouring pixel as a new seed in a recursive call. If the answer is no
i.e. the colour of pixel is already changed then return to its caller. •
Sometimes we want to fill an area that is not defines within a single
colour boundary. Here edge AB, BC, CD, DA are having red, blue,
green and pink colour, respectively.• We can paint such areas by
replacing a specified interior colour instead of searching for a
boundary colour value. Here we are setting empty pixel with new
colour till we get any coloured pixel. • Flood fill and boundary fill
algorithms are somewhat similar. A flood fill algorithm is particularly
useful when the region or polygon has no uninformed coloured
boundaries. • The flood fill algorithm is sometimes also called as seed
fill algorithm or forest fill algorithm. Because it spreads from a single
point i.e. seed point in all direction. • The following procedure • Resolution: In computers, resolution is the number of pixels
illustrates a recursive method for flood fill by sing 8- connected (individual points of colour) contained on a display monitor,
method. f-fill (X, Y, newcolour) { Current = getpixel(X, Y); If(Current != expressed in terms of the number of pixels on the horizontal axis
newcolor) {Putpixel(X, Y, newcolour); f-fill(X-1, Y, newcolour); f- and the number on the vertical axis. The sharpness of the image
fill(X+1, Y, newcolour); f-fill(X, Y-1, newcolour); f-fill(X, Y+1, on a display depends on the resolution and the size of the
newcolour); f-fill(X+1, Y+1, newcolour); f-fill(X-1, Y+1, newcolour); f- monitor. The same pixel resolution will be sharper on a smaller
fill(X-1, Y-1, newcolour); f-fill(X+1, Y-1, newcolour); } } monitor and gradually lose sharpness on larger monitors because
the same number of pixels are being spread out over a larger
number of inches. • Aspect Ratio: An aspect ratio is an attribute
that describes the relationship between the width and height of
WEILER ARTHERTON ALGORITHM: an image. Aspect ratio is expressed by the symbolic notation: X:Y.
The Weiler-Atherton algorithm can clip a concave polygon. The values of X and Y are not the actual width and height of the
convex polygon : Interior angles < 1800 image, but describe the relationship between them. Aspect ratio
concave polygon : one or more Interior angles >1800 is generally used to determine the relative horizontal and vertical
This algorithm defines-the Polygon to be clipped as a subject Polygon sizes of computer graphics. For example, if a computer graphic
and the clipping region is the clip Polygon.The algorithm describes has an aspect ratio of 3:1, this means the width of the graphic is
both the subject and the clip polygon by a circular list of vertices. three times of the height of the image. Aspect ratio plays an
The boundaries of the subject polygon and the clip polygon may or important role in resizing. During resizing, the aspect ratio must
may not intersect. If they intersect,then the intersections occur in remain same in order to keep the image undistorted. A distorted
pairs.One of the intersections occurs when a subject polygon edge aspect ratio leads to stretching of the image.
enters the inside of the clip Polygon and one when it leaves.
• Control Points
• We define curves with the help of some points and these
points are control points.• Then we join these control Properties of B-spline Curve :
points to draw the curve,• There are two approaches for Each basis function has 0 or +ve value for all parameters.
joining these points.• If the curve passes through each and Each basis function has one maximum value except for k=1.
every control point then it is Interpolation Spline. The degree of B-spline curve polynomial does not depend on the
• However, for Approximation Spline it is not necessary number of control points which makes it more reliable to use than
that it touches all or any control point. Bezier curve.B-spline curve provides the local control through control
Convex hull points over each segment of the curve.The sum of basis functions for
• Convex hull is basically a boundary that covers all the a given parameter is one.
control points.• That is, all the control points are inside this
boundary or on the boundary.• Convex hull ensures that
curve properly follows the shape defined by control points
Z BUFFER