











Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Computer Graphics involves technology to accept, process, transform and present information in a visual form that also concerns with producing images and animations using a computer. This course teach how to make your own design in computer using OpenGl. This lecture includes: Graphics, Primitive, Clipping, Concept, Recangle, Drawn, Illustrate, Default, Extention, Boundries
Typology: Study notes
1 / 19
This page cannot be seen from the preview
Don't miss anything!












27.1 CLIPPING - Concept
It is desirable to restrict the effect of graphics primitives to a sub-region of the canvas, to protect other portions of the canvas. All primitives are clipped to the boundaries of this clipping rectangle ; that is, primitives lying outside the clip rectangle are not drawn.
The default clipping rectangle is the full canvas (the screen), and it is obvious that we cannot see any graphics primitives outside the screen.
A simple example of line clipping can illustrate this idea:
This is a simple example of line clipping: the display window is the canvas and also the default clipping rectangle, thus all line segments inside the canvas are drawn.
The red box is the clipping rectangle we will use later, and the dotted line is the extension of the four edges of the clipping rectangle.
docsity.com
27.2 Point Clipping
Assuming a rectangular clip window, point clipping is easy. we save the point if:
x (^) min <= x <=x (^) max y (^) min <= y <= y (^) max
27.3 Line Clipping
This section treats clipping of lines against rectangles. Although there are specialized algorithms for rectangle and polygon clipping, it is important to note that other graphic primitives can be clipped by repeated application of the line clipper.
27.4 Cohen-Sutherland algorithm - Conclusion
In summary, the Cohen-Sutherland algorithm is efficient when out-code testing can be done cheaply (for example, by doing bit-wise operations in assembly language) and trivial acceptance or rejection is applicable to the majority of line segments. (For example, large windows - everything is inside, or small windows - everything is outside).
27.5 Liang-Barsky Algorithm - Conclusion
In general, the Liang_Barsky algorithm is more efficient than the Cohen_Sutherland algorithm, since intersection calculations are reduced. Each update of parameters u 1 and u 2 requires only one division; and window intersections of the line are computed only once, when the final values of u 1 and u 2 have computed. In contrast, the Cohen- Sutherland algorithm can repeatedly calculate intersections along a line path, even though the line may be completely outside the clip window, and, each intersection calculation requires both a division and a multiplication. Both the Cohen_Sutherland and the Liang_Barsky algorithms can be extended to three-dimensional clipping.
27.6 Polygon Clipping
A polygon is usually defined by a sequence of vertices and edges. If the polygons are un- filled, line-clipping techniques are sufficient however, if the polygons are filled, the process in more complicated. A polygon may be fragmented into several polygons in the clipping process, and the original colour associated with each one. The Sutherland- Hodgeman clipping algorithm clips any polygon against a convex clip polygon. The Weiler-Atherton clipping algorithm will clip any polygon against any clip polygon. The polygons may even have holes.
The following example illustrates a simple case of polygon clipping.
docsity.com
Another approach to check the final vertex list for multiple vertex points along any clip window boundary and correctly join pairs of vertices. Finally, we could use a more general polygon clipper, such as wither the Weiler-Atherton algorithm or the Weiler algorithm described in the next section.
27.10 Weiler-Atherton Polygon Clipping
In this technique, the vertex-processing procedures for window boundaries are modified so that concave polygons are displayed correctly. This clipping procedure was developed as a method for identifying visible surfaces, and so it can be applied with arbitrary polygon-clipping regions.
The basic idea in this algorithm is that instead of always proceeding around the polygon edges as vertices are processed, we sometimes want to follow the window boundaries. Which path we follow depends on the polygon-processing direction(clockwise or counterclockwise) and whether the pair of polygon vertices currently being processed represents an outside-to-inside pair or an inside-to-outside pair. For clockwise processing of polygon vertices, we use the following rules:
For an outside-top inside pair of vertices, follow the polygon boundary For an inside-to-outside pair of vertices, follow the window boundary in a clockwise direction
In following figure, the processing direction in the Wieler-Atherton algorithm and the resulting clipped polygon is shown for a rectangular clipping window.
Inside
go up
go up docsity.com
27.11 3D Concepts
27.12 Coordinate Systems
Coordinate systems are the measured frames of reference within which geometry is defined, manipulated and viewed. In this system, you have a well-known point that serves as the origin (reference point), and three lines(axes) that pass through this point and are orthogonal to each other ( at right angles – 90 degrees).
With the Cartesian coordinate system, you can define any point in space by saying how far along each of the three axes you need to travel in order to reach the point if you start at the origin. Following are three types of the coordinate systems.
27.13 1-D Coordinate Systems:
This system has the following characteristics:
Direction and magnitude along a single axis, with reference to an origin Locations are defined by a single coordinate Can define points, segments, lines, rays Can have multiple origins (frames of reference) and transform coordinates among them
27.14 2-D Coordinate Systems:
Direction and magnitude along two axes, with reference to an origin
Locations are defined by x, y coordinate pairs
Can define points, segments, lines, rays, curves, polygons, (any planar geometry)
Can have multiple origins (frames of reference and transform coordinates among them
docsity.com
Left handed axes often are used for cameras
27.17 Right Handed Rule:
“Right Hand Rule” for rotations: grasp axis with right hand with thumb oriented in positive direction, fingers will then curl in direction of positive rotation for that
axis.
Right handed Cartesian coordinate system describes the relationship of the X,Y, and Z in the following manner:
X is positive to the right of the origin, and negative to the left.
Y is positive above the origin, and negative below it.
Z is negative beyond the origin, and positive behind it.
East
North
West
Sout
Origin
docsity.com
27.18 Left Handed Rule:
Left handed Cartesian coordinate system describes the relationship of the X, Y and Z in the following manner:
X is positive to the right of the origin, and negative to the left.
Y is positive above the origin, and negative below it.
Z is positive beyond the origin, and negative behind it.
27.19 Defining 3D points in mathematical notations
3D points can be described using simple mathematical notations
Thus the origin of the Coordinate system is located at point (0,0,0), while five units to the right of that position might be located at point (5,0,0).
East
North
West
Sout
Origin
docsity.com
27.22 Multiple Frames of Reference in a 3-D Scene:
In fact, there usually are multiple coordinate systems within any 3-D screen
Application data will be transformed among the various coordinate systems, depending on what's to be accomplished during program execution
Individual coordinate systems often are hierarchically linked within the scene
27.23 The Polar Coordinate System
Cartesian systems are not the only ones we can use. We could have also described the object position in this way: “starting at the origin, looking east, rotate 38 degrees northward, 65 degrees upward, and travel 7.47 feet along this line. “As you can see, this is less intuitive in a real world setting. And if you try to work out the math, it is harder to manipulate (when we get to the sections that move points around). Because such polar coordinates are difficult to control, they are generally not used in 3D graphics.
27.24 Defining Geometry in 3-D
Here are some definitions of the technical names that will be used in 3D lectures.
Modeling: is the process of describing an object or scene so that we can construct an image of it.
docsity.com
27.25 Points & polygons:
Points: three-dimensional locations (or coordinate triples)
Vectors: - have direction and magnitude; can also be thought of as displacement
Polygons: - sequences of “correctly” co-planar points; or an initial point and a sequence of vectors
27.26 Primitives
Primitives are the fundamental geometric entities within a given data structure.
docsity.com
3D shapes are represented by polygonal meshes that define or approximate geometric surfaces.
With curved surfaces, the accuracy of the approximation is directly proportional to the number of polygons used in the representation.
More polygons (when well used) yield a better approximation.
But more polygons also exact greater computational overhead, thereby degrading interactive performance, increasing render times, etc.
27.27 Rendering
The process of computing a two dimensional image using a combination of a three- dimensional database, scene characteristics, and viewing transformations. Various algorithms can be employed for rendering, depending on the needs of the application.
27.28 Tessellation
The subdivision of an entity or surface into one or more non-overlapping primitives. Typically, renderers decompose surfaces into triangles as part of the rendering process.
27.29 Sampling
The process of selecting a representative but finite number of values along a continuous function sufficient to render a reasonable approximation of the function for the task at hand.
27.30 Level of Detail (LOD)
To improve rendering efficiency when dynamically viewing a scene, more or less detailed versions of a model may be swapped in and out of the scene database depending on the importance (usually determined by image size) of the object in the current view.
27.31 Transformations
The process of moving points in space is called transformation.
docsity.com
27.32 Types of Transformation
There are various types of transformations as we have seen in case of 2D transformations. These include: a. Translation b. Rotation c. Scaling d. Reflection e. Shearing a) Translation Translation is used to move a point, or a set of points, linearly in space. Since now we are talking about 3D, therefore each point has 3 coordinates i.e. x, y and z. similarly, the translation distances can also be specified in any of the 3 dimensions. These Translation Distances are given by tx, ty and tz. For any point P(x,y,z) after translation we have P(x,y,z) where x = x + tx , y = y + ty , z = z + tz and (tx, ty , tz) is Translation vector
Now this can be expressed as a single matrix equation: P = P + T
Where:
3D Translation Example We may want to move a point “3 meters east, -2 meters up, and 4 meters north.” What would be done in such event? Steps for Translation Given a point in 3D and a translation vector, it can be translated as follows:
Point3D point = (0, 0, 0) Vector3D vector = (10, -3, 2.5) Adding vector to point point.x = point.x + vector.x; point.y = point.y + vector.y; point.z = point.z + vector.z; And finally we have translated point.
Homogeneous Coordinates Analogous to their 2D Counterpart, the homogeneous coordinates for 3D translation can be expressed as :
z
y
x P
z
y
x P
z
y
x
t
t
t T
z
y
x
t
t
t
z
y
x
z
y
x
docsity.com
Rotation about z-axis (i.e. in xy plane): x = x cos – y sin y = x sin + y cos z’ = z
by Cyclic permutation
Rotation about x-axis (i.e. in yz plane): x = x y = y cos – z sin z = y sin + z cos and Rotation about y-axis (i.e. in xz plane): x = z sin + x cos y = y z = z cos – x sin
b) SCALING:-
Coordinate transformations for scaling relative to the origin are
X` = X. Sx
Y` = Y. Sy
Z` = Z. Sz
Uniform Scaling
We preserve the original shape of an object with a uniform scaling
( Sx = Sy = Sz)
Differential Scaling
We do not preserve the original shape of an object with a differential scaling
( Sx <> Sy <> Sz)
Scaling w.r.t. Origin
Projection can be defined as a mapping of point P(x,y,z) onto its image P(x,y,z) in the projection plane or view plane, which constitutes the display surface
z
y
x
docsity.com
Methods of Projection
Parallel Projection is divided into Orthographic and Oblique transformations.
Xp = x + z ( L1 cos () )
Yp = y + z ( L1 sin () )
Where L1 = L/z
docsity.com