Module 4
Module 4
Module-4
Three Dimensional Graphics
The three-dimensional transformations are extensions of two-dimensional
transformation. In 2D two coordinates are used, i.e., x and y whereas in 3D three
coordinates x, y, and z are used.
Computer Graphics uses CAD. CAD allows manipulation of machine components which
are 3 Dimensional. It also provides automobile bodies, aircraft parts study. All these
activities require realism. For realism 3D is required. In the production of a realistic 3D
scene from 2D is tough. It requires three dimensions, i.e., depth.
To obtain display of a three-dimensional scene that has been modeled in world coordinates. we must
first set up a coordinate reference for the "camera". This coordinate reference defines the position and
orientation for the plane of the carnera film which is the plane we want to us to display a view of the
objects in the scene. Object descriptions are then transferred to the camera reference coordinates and
projected onto the selected display plane. We can then display the objects in wireframe (outline) form,
or we can apply lighting surface rendering techniques to shade the visible surfaces.
1. Parallel Projection
1
COMPUTER GRAPHICS MODULE IV
2. Perspective Projection
• It is a method for generating a view of a three dimensional scene is to project points to the
display plane alone converging paths.
• In a perspective projection, parallel lines in a scene that are not parallel to the display plane are
projected into converging lines.
• Scenes displayed using perspective projections appear more realistic, since this is
the way that our eyes and a camera lens form images.
3. Depth Cueing
• Depth cueing is a method for indicating depth with wire frame displays is to vary the
intensity of objects according to their distance from the viewing position.
2
COMPUTER GRAPHICS MODULE IV
• We can also clarify depth relationships in a wireframe display by identifying visible lines in
some way.
• The simplest method is to highlight the visible lines or to display them in a different color.
• Another technique, commonly used for engineering drawings, is to display the nonvisible lines
as dashed lines.
5. Surface Rendering
• Lighting conditions include the intensity and positions of lightsources and the
background illumination.
3
COMPUTER GRAPHICS MODULE IV
• Exploded and cutaway views of objects can be to show the internal structure
and relationship of the objects parts.
• An alternative to exploding an object into its component parts isthe cut away
view which removes part of the visible surfaces to show internal structure.
Three-dimensional views can be obtained by reflecting a raster image from a vibrating flexible mirror.
The vibrations of the mirror are synchronized with the display of the scene on the CRT. As the mirror
vibrates, the focal length varies so that each point in the scene is projected to a position corresponding to
4
COMPUTER GRAPHICS MODULE IV
its depth. Stereoscopic devices present two views of a scene: one for the left eye and the other for the
right eye
Representation schemes for solid objects are divided into two categories as follows:
It describes a three dimensional object as a set of surfaces that separate the object interior from
the environment. Examples are polygon facets and spline patches.
It describes the interior properties, by partitioning the spatial region containing an object into a set of
small, non-overlapping, contiguous solids(usually cubes). Eg: Octree Representation.
Polygon Surfaces
Polygon surfaces are boundary representations for a 3D graphics object is a set of polygons that
enclose the object interior.
(1)Polygon Tables
The polygon surface is specified with a set of vertex coordinates and associated attribute parameters.
For each polygon input, the data are placed into tables that are to be used in the subsequent processing.
Polygon data tables can be organized into two groups: Geometric tables and attribute tables.
(2)Geometric Tables
Contain vertex coordinates and parameters to identify the spatial orientation of the polygon surfaces.
5
COMPUTER GRAPHICS MODULE IV
(3)Attribute tables
Contain attribute information for an object such as parameters specifying the degree of
transparency of the object and its surface reflectivity and texture characteristics. A
convenient organization for storing geometric data is to create three lists:
Coordinate values for each vertex in the object are stored in this table.
It contains pointers back into the vertex table to identify the vertices for each polygon edge.
It contains pointers back into the edge table to identify the edges for each polygon. This is shown in fig
Listing the geometric data in three tables provides a convenient reference to the individual components
(vertices, edges and polygons) of each object.
The object can be displayed efficiently by using data from the edge table to draw the
component lines.
6
COMPUTER GRAPHICS MODULE IV
Extra information can be added to the data tables for faster information extraction. For
instance, edge table can be expanded to include forward points into the polygon table so
that common edges between polygons can be identified more rapidly.
E1 : V1, V2, S1
E2 : V2, V3, S1
E4 : V3, V4, S2
E5 : V4, V5, S2
E6 : V5, V1, S2
It is useful for the rendering procedure that must vary surface shading smoothly across the edges from
one polygon to the next. Similarly, the vertex table can be expanded so that vertices are cross-referenced
to corresponding edges.
Additional geometric information that is stored in the data tables includes the slope for each edge and
the coordinate extends for each polygon. As vertices are input, we can calculate edge slopes and we can
scan the coordinate values to identify the minimum and maximum x, y and z values for individual
polygons.
The more information included in the data tables will be easier to check for errors. Some of the tests
that could be performed by a graphics package are:
• That if the edge table contains pointers to polygons, every edge referenced by a polygon pointer
has a reciprocal pointer back to the polygon.
7
COMPUTER GRAPHICS MODULE IV
• Plane Equations:
To produce a display of a 3D object, we must process the input data representation for the object
through several procedures such as,
For these processes, we need information about the spatial orientation of the individual
surface components of the object. This information is obtained from the vertex coordinate
value and the equations that describe the polygon planes.
Ax + By + Cz + D = 0
Where (x, y, z) is any point on the plane, and the coefficients A, B, C, and D are constants describing the
spatial properties of the plane. The values of A, B, C, and D can be obtained by solving the set of three
equations using the coordinate values of the non collinear points of the plane. It is assumed that the three
vertices of the plane are (x1, y1, z1), (x2, y2, z2) and (x3, y3, z3).
The equation for the ratios A/D, B/D, and C/D is solved for obtaining the values of A, B, C, and D.
To obtain the above equations in determinant form, apply Cramer’s rule to the above equations.
8
COMPUTER GRAPHICS MODULE IV
Expanding the determinants , we can write the calculations for the plane coefficients in the
form:
Polygon Meshes
A set of polygonal and line segments approximate 3D surfaces and solids. Such surfaces are known as
polygonal meshes. In such meshes each of the edge is shared by at most two polygons. The skin of the
project is a combination of set of polygons or faces.
A broad class of solids/ surfaces are represented by this method. Hidden surface removal algorithms are
used for rendering the polygonal mesh. The mesh is represented in three different ways:
• Explicit representation
• Pointers to a vertex list
• Pointers to an edge list
9
COMPUTER GRAPHICS MODULE IV
One type of polygon mesh is the triangle strip.A triangle strip formed with 11 triangles
connecting 13 vertices.
This function produces n-2 connected triangles given the coordinates for n vertices.
Another similar function in the quadrilateral mesh, which generates a mesh of (n-1) by
(m-1) quadrilaterals, given the coordinates for an n by m array of vertices. Figure shows 20
vertices forming a mesh of 12 quadrilaterals.
Advantages
• Any object can be modelled by this mesh.
• Represented as a collection of vertices.
• Transformation of the mesh is easy.
• Easily can be drawn on the computer screen.
Disadvantages
• Curved surfaces can be describes approximately.
10
COMPUTER GRAPHICS MODULE IV
Sweep Representation
• We can represent such objects by specifying a two dimensional shape and a sweep
that moves the shape through a region of space.
• Other methods for obtaining two-dimensional figures include closed spline curve
constructions and cross-sectional slices of solid objects.
1. Figure below illustrates a translational sweep. The periodic spline curve in Figure
(a) defines the object cross section.
2. At intervals along this path, we replicate the cross-sectional shape and draw a set of
connecting lines in the direction of the sweep to obtain the wireframe representation
shown in Fig (b).
To obtain the wireframe representation we have to replicate the 2D shape and draw
11
COMPUTER GRAPHICS MODULE IV
a set of connecting lines in the direction of shape, as shown in the figure (8)
An example of object design using a rotational sweep is given in Figure below this time, the
periodic spline cross section is rotated about an axis of rotation specified in the plane of the cross
section to produce the wireframe representation shown in Fig (b).
12
COMPUTER GRAPHICS MODULE IV
1. Any axis can be chosen for a rotational sweep. If we use a rotation axis
perpendicular to the plane of the spline cross section in Fig. (a), we generate a two-
dimensional shape.
2. But if the cross section shown in this figure has depth, then we are using one three-
dimensional object to generate another.
In general we can specify sweep constructions using any path. For translation we
can vary the shape or size of the original 2D shape along the sweep path. For
rotational sweeps, we can move along a circular path through any angular distance
from 0° to 360°. These sweeps whose generating area or volume changes in size,
shape or orientation as they are swept and that follow an arbitrary curved trajectory
are called general sweeps .General sweeps are difficult to model efficiently for
example, the trajectory and object shape may make the swept object intersect itself,
making volume calculations complicated. Further more, general sweeps do not
13
COMPUTER GRAPHICS MODULE IV
always generate solids. For example, sweeping a 2D shape in its own plane
generates another 2D shape.
1. Definition
Ray Casting is often used to implement CSG operation when objects are described
with boundary representation. We fire a ray from the plane xy (which represent the screen).
The surface limits for the composite object are determined by the specified set operation
14
COMPUTER GRAPHICS MODULE IV
Union A, D
Intersection C, B
15
COMPUTER GRAPHICS MODULE IV
In 3D computer graphics and CAD, CSG is often used in procedural modeling. CSG can
also be performed on polygonal meshes, and may or may not be procedural and/or
parametric.
Workings
The simplest solid objects used for the representation are called primitives. Typically they
are the objects of simple shape: cuboids, cylinders, prisms, pyramids, spheres, cones. The
set of allowable primitives is limited by each software package. Some software packages
allow CSG on curved objects while other packages do not.
16
COMPUTER GRAPHICS MODULE IV
Union
Merger of two objects into one
Difference
Subtraction of one object from another
Intersection
Portion common to both objects
Ray tracing
Rendering of constructive solid geometry is particularly simple when ray tracing. Ray
tracers intersect a ray with both primitives that are being operated on, apply the operator to
the intersection intervals along the 1D ray, and then take the point closest to the camera
along the ray as being the result.
Quadtrees
• Based on the divided-and-conquer principle, a quadtree is a data structure that recursively
17
COMPUTER GRAPHICS MODULE IV
We will apply quadtrees to storing planar polygons. Our attribute will be whether current
quadrant is filled by the interior of a polygon:
18
COMPUTER GRAPHICS MODULE IV
Octrees
An Octree is a recursive, axis-aligned, spatial partitioning data structure commonly used in computer
graphics to optimize collision detection, nearest neighbor search, and more. Conceptually, an Octree is a
simple data structure.
• Octrees are based on the same principle, but divide regions of 3D space (usually
into cubes).
• The scene is subdivided at each step with three mutually perpendicular planes,
aligned with the Cartesian coordinate planes.
• Individual partitions of 3D space are called Voxels (Volume Elements).
• Applications: raycasting, shadowcasting.
Octrees, like Quadtrees, use a node structure to store the volume elements:
19
COMPUTER GRAPHICS MODULE IV
In this figure, the octree has been refined twice. First, the root is refined into eight cells,
each representing an octant of the root's domain. Then, one of the root's children is refined
yet again.
An Octree is constructed by recursively subdividing space into eight cells until the remaining number
of objects in each cell is below a pre-defined threshold, or a maximum tree depth is reached. Every cell
is subdivided by three axis-aligned planes, which are usually placed in the middle of the parent node.
Thus, each node can have up to eight children. The possibility not to allocate certain child nodes allows,
in contrast to regular grids, to store sparsely populated worlds in Octrees.
20
COMPUTER GRAPHICS MODULE IV
21