21
Graphic Standards The heart of any CAD model is the component database. This includes the graphics entities like points, lines, arcs, circles etc. and the co-ordinate points, which define the location of these entities. This geometric data is used in all downstream applications of CAD, which include finite element modeling and analysis, process planning, estimation, CNC programming, robot programming, programming of co-ordinate measuring machines, ERP system programming and simulation. In order to achieve at least a reasonably high level of integration between CAD, analysis and manufacturing operations, the component database must contain: i. Shapes of the Components (based on solid models) ii. Bill of Materials (BOM), of the assembly in which the components are used. iii. Material of the Components iv. Manufacturing, test and assembly procedures to be carried out to produce a component so that it is capable of functioning as per the requirements of design. In designing a data structure for CAD database the following factors are to be considered: i. The data must be neutral. ii. The data structure must be user-friendly. iii. The data must be portable. In order to achieve the above requirements, some type of standardization has to be followed by the CAD software designers. The basic elements associated with a CAD system are: • Operator ȋuserȌ • Graphics Support System • Other User )nterface Support System • Application Functions • Database

Graphics Standards and Algorithm

Embed Size (px)

Citation preview

Page 1: Graphics Standards and Algorithm

Graphic Standards

The heart of any CAD model is the component database. This includes the graphics entities like points, lines,

arcs, circles etc. and the co-ordinate points, which define the location of these entities. This geometric data is

used in all downstream applications of CAD, which include finite element modeling and analysis, process

planning, estimation, CNC programming, robot programming, programming of co-ordinate measuring

machines, ERP system programming and simulation.

In order to achieve at least a reasonably high level of integration between CAD, analysis and manufacturing

operations, the component database must contain:

i. Shapes of the Components (based on solid models)

ii. Bill of Materials (BOM), of the assembly in which the components are used.

iii. Material of the Components

iv. Manufacturing, test and assembly procedures to be carried out to produce a component so that it is

capable of functioning as per the requirements of design.

In designing a data structure for CAD database the following factors are to be considered:

i. The data must be neutral.

ii. The data structure must be user-friendly.

iii. The data must be portable.

In order to achieve the above requirements, some type of standardization has to be followed by the CAD

software designers. The basic elements associated with a CAD system are: • Operator user • Graphics Support System • Other User )nterface Support System • Application Functions • Database

Page 2: Graphics Standards and Algorithm

A diagrammatic presentation of these elements is given in Figure. The reasons for evolving a graphic standard

thus include: • Need for exchanging graphic data between different computer systems. • Need for a clear distinction between modeling and reviewing aspects. Standards for Graphics Programming

(i) GKS (Graphical Kernel System):

It is an ANSI and ISO standard. GKS standardizes two dimensional graphics functionality at a relatively low

level. The primary purposes of the standard are: • To provide for portability of graphics application programs. • To aid in the understanding of graphics method by application programmers. • To provide guidelines for manufacturers in describing useful graphics capabilities. The GKS (ANSI X3.124-1985) consists of three basic parts:

i. An informal exposition of contents of the standard, which includes such things as positioning of text, filling

of polygons etc.

ii. A formalization of the expository material outlined in (i) by way of abstracting the ideas into functional

descriptions (input/output parameters, effect of each function etc.).

iii. Language bindings, which are the implementations of the abstract functions, described in (ii) in a specific

computer language like FORTRAN, Ada or C.

The features of GKS include:

i. Device Independence: The standard does not assume that the input or output devices have any particular

features or restrictions.

ii. Text/Annotations: All text or annotations are in a natural language like English.

iii. Display Management: A complete suite of display management functions, cursor control and other

features are provided.

iv. Graphics Functions: Graphics functions are defined in 2D or 3D.

The drivers in GKS also include metafile drivers. Metafiles are devices with no graphic capability like a

disc unit. The GKS always works in a rectangular window or world coordinate system. The window also

defines a scaling factor used to map the created picture into the internal co-ordinate system of GKS

called Normalized Device Co-Ordinates. Windows and view ports can then work in this co-ordinate system.

PHIGS:

P()GS Programmer’s (ierarchical )nteractive Graphics Standard includes in its functionality three

dimensional output primitives and transformations. It has dynamic control over the visual appearance of

attributes of primitives in a segment. The PHIGS standard defines a set of device-independent logical

concepts. Application programmers can use these concepts within a set of PHIGS rules. The major concepts

are the Logical Input Device, PHIGS structure, Structure Networks, Structure Manipulation, Search and

Page 3: Graphics Standards and Algorithm

Inquiry, Structure Traversal and Display, the Name Set mechanism, the viewing pipeline, and the PHIGS

workstation.

Fig. GKS Implementation in a CAD Workstation

PHIGS, a programming library for 3D graphics, was developed and maintained by ISO. It is most commonly

used on the X Windows system. The PHIGS high level graphics library contains over 400 functions ranging

from simple line drawing to lighting and shading. Before displaying a picture, the application first stores its

graphics information in the PHIGS graphic database. Therefore PHIGS is referred to as a display list system.

The application then appears on one or more display devices and then passes the list to them.

Exchange of CAD Data between Software Packages

Necessity to translate drawings created in one drafting package to another often arises. For example you may

have a CAD model created in PRO/E package and you may wish that this might be transferred to I-DEAS or

Uni-Graphics. It may also be necessary to transfer geometric data from one software to another. This situation

arises when you would want to carry out modeling in one software, say PRO/E and analysis in another

software, say ANSYS. One method to meet this need is to write direct translators from one software to

another. This means that each system developer will have to produce its own translators. This will

necessitate a large number of translators. If we have three software packages we may require six translators

among them. This is shown in Fig.

Page 4: Graphics Standards and Algorithm

Fig. Direct Data Translation

A solution to this problem of direct translators is to use neutral files. These neutral files will have standard

formats and software packages can have pre-processors to convert drawing data to neutral file and

postprocessors to convert neutral file data to drawing file. Figure illustrates how the CAD data transfer is a

accomplished using neutral file. Three types of neutral files are discussed here:

i. Drawing Exchange Files (DXF)

ii. IGES Files

iii. STEP Files

Fig. CAD Data Exchange Using Neutral Files

DXF Files

DXF file (Drawing Exchange File) is a popular data exchange format adopted by many CAD system vendors.

DXF format is easy to interpret though it is a lengthy file. The data pertaining to the drawing entities are

included in the entities section. Fig. shows a plate with a hole.

Initial Graphics Exchange Specification (IGES) Graphics Standard

The IGES committee was established in the year 1979. The CAD/CAM Integrated Information Network (CIIN)

of Boeing served as the preliminary basis of IGES. IGES version 1.0 was released in 1980. IGES continues to

undergo revisions. IGES is a popular data exchange standard today. Figure shows a CAD model of a plate with

a centre hole. The wire frame model of the component is shown in Fig. There are eight vertices (marked as

Page 5: Graphics Standards and Algorithm

PNT 0 - PNT 8), 12 edges and two circles that form the entities of the model. Table shows the IGES output of

the wire frame model.

Fig. 3-D Model of a Plate Fig. Wire-frame Model of the Component

IGES files can also be generated for:

i. Surfaces

ii. Datum curves and points

Product Data Exchange Specification (PDES)

A likely alternative to IGES is the Product Data Exchange Specification (PDES) developed by IGES

organization. PDES is aimed at defining a more conceptual model. Parts will be based on solids and defined in

terms of features such as holes, flanges, or ribs. Instead of dimensions PDES will define a tolerance

envelope for the parts to be manufactured. PDES will also contain non-geometric information such as

materials used, manufacturing process and suppliers. PDES will be a complete computer model of the part.

Point and Line, Line Drawing Algorithms

Page 6: Graphics Standards and Algorithm

In the case of the computer graphics we have a digitized raster environment so xy are defined as integer

coordinates and we need to actually find out what are those coordinates which fall on the line before we

draw it. So that is the problem in the digitized space, we do not have continuous values of x and y like the

analog world. And hence in the case we need an algorithm by which we draw a line. Display devices raster in

all that we can visualize ourselves the digitized space or a raster space as the matrix or an array of pixels and

definitely if we draw an arbitrary line, not all of this square pixel blocks or raster position will fall on a line. So

we are talking of approximately representing line in that sense truly of course in analog environment you can

say there are basically infinite points which lie on the line. That is not the case, we have a finite set of pixels

which fall on a line and you have to find out which are those finite pixels.

When we define a line we can think of the equation of a line or the staring point x1 y1 and the finishing point

x2 y2 of a line and we can simply draw a line by a scale that is fine. But in the case of a graphic screen which

we are viewing now in a TV or a CRT monitor we have to find out what are those pixels staring from x0 y0 and

so on up to an end point x and y or x1 and y1. What are those points or the addressable pixels is the term used

here in the problem definition which falls in this line. Given the specification of a straight line either in the

form of an equation or the staring point and the end point, if that is given find the collection of addressable

pixels which most closely approximates this line.

The goals of line drawing algorithms:

a) Straight line should appear straight.

b) It should start and end accurately, matching end points with connecting lines.

c) Lines should haze constant brightness.

d) Lines should be drawn as rapidly as possible.

Two line drawing algorithms are:

a) DDA (Digital Differential Analyzer)

b) Bresenham s line drawing algorithm

a) DDA (Digital Differential Analyzer)

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.

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 lower pixel to on.

7) Then increment x by 1 and repeat the same process until x reaches the right end point of the line.

8) This method assumes the width of the line to be zero.

Page 7: Graphics Standards and Algorithm

DDA Algorithm:

1. Define the nodes, i.e end points in form of (x1, y1) and (x2, y2).

2. Calculate the distance between the two end points vertically and horizontally, i.e dx = |x1- x2| and dy =|y1 -

y2|.

3. Define new variable name pixel , and compare dx and dy values,

if dx > dy then

pixel = dx

else

pixel = dy.

4. dx = dx/pixel; and dy = dy/pixel

5. x = x1; y = y1;

6. while (i <= pixel) compute the pixel and plot the pixel with x = x + dx and y = y + dy.

b) Bresenham's Line Algorithm

1. Input the two line endpoints and store the left endpoint in (xo, yo)

2. Load (xo, yd) into the frame buffer; that is, plot the first point.

3. Calculate constants Δx, Δy, 2Δy, and 2Δy – 2Δx, and obtain the starting value for the decision parameter as

po = 2Δy - Δx

4. At each xk along the line, starting at k = 0, perform the following test: If pk < 0, the next point to plot is

(xk+1, yk) and pk+1 = pk - 2Δy

Otherwise, the next point to plot is (xk+1, yk+1) and pk+1 = pk + 2Δy - 2Δx

5. Repeat step 4 Δx times.

Mid Point Circle Algorithm

1) Input radius r and circle center (x, y,), and obtain the first point on the circumference of a circle centered

on the origin as (x0, y0) = (0, r)

2) Calculate the initial value of the decision parameter as p0 = 5\4 – r

3) At each xk position, starting at k = 0, perform the following test: If pk < 0, the next point along the circle

centered on (0,0) is (xk+1, yk) and pk+1 = pk +2xk+1+1

Otherwise, the nest point along the circle is (xk+1, yk+1) and pk+1 = pk+2xk+1 + 1 - 2yk+1

where 2xk+1= 2xk + 2 and 2yk+1= 2yk - 2.

4. Determine symmetry points in the other seven octants.

5. Move each calculated pixel position (x, y) onto the circular path centered on (xc, yc) and plot the coordinate

values: x = x + xc, y = y + yc

Page 8: Graphics Standards and Algorithm

6. Repeat steps 3 through 5 until x >= y.

Basic Transformation

Animations are produced by moving the 'camera' or the objects in a scene along animation paths. Changes in

orientation, size and shape are accomplished with geometric transformations that alter the coordinate

descriptions of the objects. The basic geometric transformations are translation, rotation, and scaling. Other

transformations that are often applied to objects include reflection and shear.

Use of Transformation in CAD

In mathematics, "Transformation" is the elementary term used for a variety of operation such as rotation,

translation, scaling, reflection, shearing etc. CAD is used throughout the engineering process from conceptual

design and layout, through detailed engineering and analysis of components to definition of manufacturing

methods. Every aspect of modeling in CAD is dependent on the transformation to view model from different

directions we need to perform rotation operation. To move an object to a different location translation

operation is done. Similarly Scaling operation is done to resize the object.

Coordinate Systems

In CAD three types of coordinate systems are needed in order to input, store and display model geometry and

graphics. These are the Model Coordinate System (MCS), the World Coordinate System (WCS) and the Screen

Coordinate System (SCS).

1. Model Coordinate System (MCS):

The MCS is defined as the reference space of the model with respect to which all the model geometrical data is

stored. The origin of MCS can be arbitrary chosen by the user.

2. World Coordinate System (WCS)

Every object has its own MCS relative to which its geometrical data is stored. Incase of multiple objects in the

same working space then there is need of a World Coordinate System which relates each MCS to each other

with respect to the orientation of the WCS.

3. Screen Coordinate System (SCS)

In contrast to the MCS and WCS the Screen Coordinate System is defined as a two dimensional device-

dependent coordinate system whose origin is usually located at the lower left corner of the graphics display

as shown in the picture below. A transformation operation from MCS coordinates to SCS coordinates is

performed by the software before displaying the model views and graphics.

Page 9: Graphics Standards and Algorithm

Viewing Transformations

As discussed that the objects are modeled in WCS, before these object descriptions can be projected to the

view plane, they must be transferred to viewing coordinate system. The view plane or the projection plane is

set up perpendicular to the viewing zv axis. The World coordinate positions in the scene are transformed to

viewing coordinates, and then viewing coordinates are projected onto the view plane. The transformation

sequence to align WCS with Viewing Coordinate System is.

1. Translate the view reference point to the origin of the world coordinate system.

2. Apply rotations to align xv, yv, and zv with the world xw, yw and zw axes, respectively.

Translation

A translation is applied to an object by repositioning it along a straight line path from one coordinate location

to another. We translate a two-dimensional point by adding translation distances, tx and ty, to the original

coordinate position (x,y) to move the point to a new position (x',y')

′ = +

′ = +

The translation distance pair (tx, ty) is called translation vector or shift vector. �� � � � � � � , [ ′ ′ ] = [ ] + [ + ] This allows us to write the two-dimensional translation equations in the matrix form: �′ = � +

Rotation

A two-dimensional rotation is applied to an object by repositioning it along a circular path in the x-y plane.

When we generate a rotation we get a rotation angle θ and the position about which the object is

rotated (xr ,yr) this is known as rotation point or pivot point. The transformation can also be described as a

rotation about rotation axis that is perpendicular to x-y plane and passes through the pivot point.

Positive values for the rotation angle define counter-clockwise rotations about the pivot point and the

negative values rotate objects in the clockwise direction. Suppose the pivot point be at origin, to understand

the relationship between angular and coordinate points of original and transformed position

r - Constant distance of the point from the origin; Φ - Original angular position of the point from the

horizontal; θ - Rotation angle

We can express the transformation by the following equations

′ = �� � + � ′ = � � � + �

We know the coordinate of x and y in polar form

′ = �� � ′ = � � �

on expanding and equating we get

′ = � � − � � ; ′ = � � − � �

Page 10: Graphics Standards and Algorithm

The same equations we can write in matrix form as �′ = �.

Where the rotation matrix R is

= [ � � � �− � � � �]

Hence it is

[ ′ ′] = [ ] [ � � � �− � � � �]

Scaling

Scaling is a kind of transformation in which the size of an object is changed. Remember the change in size

does not mean any change in shape. This kind of transformation can be carried out for polygons by

multiplying each coordinate of the polygon by the scaling factor. Sx and Sy which in turn produces new

coordinate of (x,y) as (x',y'). The equation would look like

[ ′ ′] = [ ] [ ]

�′ = �.

here S represents the scaling matrix.

Note: If the values of scaling factor are greater than 1 then the object is enlarged and if it is less that 1 it

reduces the size of the object. Keeping value as 1 does not changes the object.

Uniform Scaling: To achieve uniform scaling the values of scaling factor must be kept equal.

Differential Scaling: Unequal or Differential scaling is produce incases when values for scaling factor are not

equal. As per usual phenomenon of scaling, an object moves closer to origin when the values of scaling factor

are less than 1. To prevent object from moving or changing its position while is scaling we can use a point that

is would be fixed to its position while scaling which is commonly referred as fixed point (xf ,yf).

Reflection

Reflection is nothing more than a rotation of the object by 180o. In case of reflection the image formed is on

the opposite side of the reflective medium with the same size. Therefore we use the identity matrix with

positive and negative signs according to the situation respectively.

The reflection about the x-axis can be shown as:

= [ − ]

The reflection about the y-axis can be shown as:

= [− ]

Page 11: Graphics Standards and Algorithm

Reflection about an Origin:

When both the x and y coordinates are flipped then the reflection produced is relative to an axis that is

perpendicular to x-y plane and that passes through the coordinate origin. This transformation is referred as a

reflection relative to coordinate origin and can be represented using the matrix below.

= [ − − ]

Reflection about an Arbitrary Line:

Reflection about any line y = mx + c can be accomplished with a combination of translate-rotate-reflect

transformations.

Steps are as follows:

1. Translate the working coordinate system (WCS) so that the line passes through the origin.

2. Rotate the WCS such that one of the coordinate axes lies onto the line.

3. Reflect about the aligned axis

4. Restore the WCS back by using the inverse rotation and translation transformation.

Homogeneous Coordinates

We have seen that basic transformations can be expressed in matrix form. But many graphic applications

involve sequences of geometric transformations. Hence we need a general form of matrix to represent

such transformations. This can be expressed as: �′ = �. +

Where P and P' - represent the row vectors.

T1 - is a 2 by 2 array containing multiplicative factors.

T2 - is a 2 element row matrix containing translation terms.

We can combine multiplicative and translational terms for 2D geometric transformations into a single matrix

representation by expanding the 2 by 2 matrix representations to 3 by 3 matrices. This allows us to express

all transformation equations as matrix multiplications, providing that we also expand the matrix

representations for coordinate positions. To express any 2D transformations as a matrix multiplication, we

represent each Cartesian coordinate position (x,y) with the homogeneous coordinate triple (xh,yh,h),such

that [ �] = [ � � ⁄⁄ ] = [ � �⁄⁄ ] Thus, a general homogeneous coordinate representation can also be written as (h.x, h.y, h). For 2D geometric

transformations, we can choose the homogeneous parameter h to any non-zero value. Thus, there is an

infinite number of equivalent homogeneous representations for each coordinate point (x,y).

A convenient choice is simply to h = 1. Each 2D position is then represented with homogeneous

coordinates (x, y, 1). Other values for parameter h are needed, for eg, in matrix formulations of 3D viewing

transformations. Expressing positions in homogeneous coordinates allows us to represent all geometric

Page 12: Graphics Standards and Algorithm

transformation equations as matrix multiplications. Coordinates are represented with three element row

vectors and transformation operations are written as 3 by 3 matrices.

� � � � � � � , [ ′ ′ ] = [ ]. [

]

or �′ = �. ,

� � � � � � , [ ′ ′ ] = [ ]. [ � � � �− � � � � ]

or �′ = �. �

�� � � � � , [ ′ ′ ] = [ ]. [

]

or �′ = �. ,

2D Composite Transformation

With the matrix representations of the transformations, we can set up a matrix for any sequence of

transformations as a composite transformation matrix by calculating the matrix product of the individual

transformations. If two successive transformations T1 and T2 are applied to a coordinate position P, the final

transformed location P' is calculated as: �. = � . = �

Where = . )

1. Translation

In translation, an object is displayed a given distance and direction from its original position. If the

displacement is given by the vector = ̂ + ̂ the new object point P'(x',y') can be found by applying the

transformation Tv to P(x,y) �′ = �

where ′ = + and ′ = +

= ( ) [

] ; = [

]

= + + [

+ + ]

Page 13: Graphics Standards and Algorithm

2. Rotation

A generalized rotation about an arbitrary point (a, b) can be obtained by performing the following

transformations:

1. Translate the object so that the pivot-point position is moved to coordinate origin.

2. Rotate the object about the coordinate origin.

3. Translate the object so that the pivot point is returned to its original position.

4. The composite matrix for this sequence is obtained as: = . .

= [ − − ]

= [ � � � �− � � � � ]

= [ ]

= [ � � � � − � � � � − � � + � � − � � − � � ]

3. Scaling

The animation illustrates a transformation sequence to produce scaling with respect to a selected fixed

position (a,b) using a scaling function that can only scale relative to the coordinate origin.

1. Translate object so that the fixed point coincides with the coordinate origin.

2. Scale the object with respect to the coordinate origin.

3. Use the inverse translation of step 1 to return the object to its original position.

4. The composite matrix for this sequence is obtained as: = . . Where,

= [ − – ] = [ ] = [ ]

= [ − ( − ) ]

3D- Transformations

1. Translation:

In three-dimensional homogeneous coordinate representation, when a point P is translated to P' with

coordinated (x, y, z) and x', y’, z’ can be represented in matrix form as:

P’ = P.T

Where, P = [x y z]; P’ = [x’ y’ z’]; X’ = X + TX ; y’ = y + Ty ; z’ = z + Tz

Page 14: Graphics Standards and Algorithm

= [ ]

2. Rotation

Unlike 2D, rotation in 3D is carried out around any line. The most simple rotations could be around

coordinate axis. As in 2D positive rotations produce counter-clockwise rotations. Rotation in term of general

equation is expressed as

P’ = P.R θ)

Where, P = [x y z]; P’ = [x’ y’ z’]

R = Rotation Matrix

Rotation matrix when an object is rotated about X axis can be expressed as:

= [ � � � �− � � � � ]

Rotation matrix when an object is rotated about Y axis can be expressed as:

= [ � � − � �

� � � � ]

Rotation matrix when an object is rotated about Z axis can be expressed as:

= [ � � � �− � � � �

]

3. Scaling

Scaling an object in three-dimensional is similar to scaling an object in two-dimensional. Similar to 2D scaling

an object tends to change its size and repositions the object relative to the coordinate origin. If the

transformation parameters are unequal it leads to deformation of the object by changing its dimensions. The

perform uniform scaling the scaling factors should be kept equal i.e.

Sx = Sy = Sz ; P’ = P.S

Where, P = [x y z]; P’ = [x’ y’ z’]

= [

]

Page 15: Graphics Standards and Algorithm

Note: A special case of scaling can be represented as reflection. If the value of Sx, Sy or Sz be replaced by -1 it

will return the reflection of the object against the standard plane whose normal would be either x axis, y axis

or z axis respectively.

4. Reflection

In 3D-reflection the reflection takes place about a plane whereas 2D reflection it used take place about an

axis. The matrix in case of pure reflections, along basic planes, viz. X-Y plane, Y-Z plane and Z-X plane are

given below:

Transformation matrix for a reflection through X-Y plane is: = [ − ]

Transformation matrix for a reflection through Y-Z plane is: = [ −

]

Transformation matrix for a reflection through Z-X plane is: = [ −

]

General 3-D Rotation

Rotation in three dimensions is more complex than the rotation in two dimensions. Three dimensional

rotations require the prescription of an angle of rotation and an axis of rotation. The canonical rotations are

defined when one of the positive x, y, z coordinate axis is chosen as the axis of rotation. Then the construction

of rotation transformation proceeds just like that of a rotation in two dimensions about the origin.

Steps to be Performed:

1. Translate origin to A1

= [

]

2. Align vector with axis (say, z)

Rotate to bring vector in yz plane

= [ � � − � �� � � � ]

Rotate to bring vector along z-axis

Page 16: Graphics Standards and Algorithm

= [ � � � �− � � � � ]

3. Rotate line P1P2 about z-axis which is already aligned with the Rotation axis.

4. Reverse steps 2

5. Reverse step 1

Representing All Transformations as Matrix Multiplications

Two Dimensional coordinates are represented using three-element column vectors, and Transformation

operation is represented by 3 x 3 matrices.

[x’ y’ z’ ] = [x y z].[ ]

which can be written in abbreviated form as P’ = P.T tx , ty)

Capturing Composite Transformations Conveniently

On the basis of the matrix product of the individual transformations we can set up a matrix for any sequence

of transformation known as composite transformation matrix. For row-matrix representation we form

composite transformations by multiplying matrices in order from left to right whereas in column-matrix

representation we form composite transformations by multiplying matrices in order from right to left.

Non Linear Transformations (3D -Perspective Transformations)

Standard Perspective Projection:

A Perspective Transformation is the transformation from one three space in to another three space. In

contrast to the Parallel Transformation, in perspective transformations parallel lines converge, object

size is reduced with increasing distance from the center of projection, and non uniform foreshortening

of lines in the object as a function of orientation and the distance of the object from the center of projection

occurs. All of these effects laid the depth perception of the human visual system, but the shape of the object is

not preserved. Perspective Drawings are characterized by Perspective Foreshortening and Vanishing

Points.

Perspective Foreshortening is the illusion that object and lengths appear smaller as there distance

from the center of projection increases. The illusion that certain sets of parallel lines appear to meet at a

point is another feature of perspective drawings. These points are called Vanishing Points .Principal

vanishing points are formed by the apparent intersection of lines parallel to one of the three x,y or z

axis. The number of principal vanishing points is determined by the number of principal axes interested by

the view plane.

Perspective Anomalies

1. Perspective Foreshortening: The farther an object is from the center of projection, the smaller it appears.

Page 17: Graphics Standards and Algorithm

2. Vanishing Points: Projections of lines that are not parallel to the view plane (i.e. lines that are not

perpendicular to the view plane normal) appear to meet at some point on the view plane. This point is called

the vanishing point. A vanishing point corresponds to every set of parallel lines. Vanishing points

corresponding to the three principle directions are referred to as "Principle Vanishing Points (PVPs)". We

can thus have at most three PVPs. If one or more of these are at infinity (that is parallel lines in that direction

continue to appear parallel on the projection plane), we get 1 or 2 PVP perspective projection.

Transformation Matrix for Standard Perspective Projection

View plane at = ; ′ = − ; ′ = − ; ′ = − ( − � ) ∗

′ = [ ] − ∗ [ − − ( − � )] = −− �

′ = ∗ − = ∗ � −− �

′ = −− �

�imilarl� ′ = −− � ; ′ =

=[ − −

� � ]

Transforming a Point or Transforming the Axis

Graphics applications often require transformation of objects description form one coordinate system to

another. The process of transformation involves steps like translation and rotation. This transformation can

be done in two different ways either by transforming a point of the object or by transforming the axis to a

Page 18: Graphics Standards and Algorithm

point on object. Both of these methods are literally as well as mathematically opposite to each other. For

example the matrix for translating point P(x, y, z) to origin the matrix would be exactly the mathematical

inverse of the matrix for translating Origin to point P.

�ran�la�ion ma�ri� �o �ran�la�� poin� � �o ori�in, = [− − ]

�ran�la�ion ma�ri� �o �ran�la�� ori�in �o poin� � , = [ ]

This is true for rotation matrix also.

How to Determine the Angle of Rotation?

In various situations for performing complex transformations first we need to align an arbitrary line with the

standard axis. To align the standard axis with an arbitrary line it is important to know the angle of rotations.

As show in the figure above the angle θ2 is the angle for rotation about x axis so as to align z axis with the

projection of A1A2 on YZ plane. Thereafter with the same position of z axis rotation of θ2 is taken about Y axis

which aligns the Z axis with the arbitrary line. The angles can be calculated as below.

� = � − √ +√ + + ; � = � − (√ + )

Representing Points at Infinity

Homogeneous coordinates can be used to display a point at infinity. For example

[ ] = [ ] In the above example the point at infinity is presented in the form of homogeneous coordinates. This is often

needed when we want to represent a point at infinity in a certain direction. For instance, for finding the

vanishing point in perspective projections we can transform the point at infinity in the given direction.

Page 19: Graphics Standards and Algorithm

General 3-D Reflection

Some orientations of a three dimensional object cannot be obtained using pure rotations; they require

reflections. In three dimensions, reflection occurs through a plane. By analogy with the previous discussion of

two dimensional reflection three dimensional reflections through a plane is equivalent to rotation about an

axis in three dimensional spaces out in to four dimensional space and back into three dimensional spaces. For

pure reflection the determinant of the reflection matrix is identically -1

Steps to Be Performed:

1. Translate origin to A1

= [

]

2. Align vector with axis (say, z)

Rotate to bring vector in yz plane

= [ � � − � �� � � � ]

3. Rotate to bring vector along z-axis

= [ � � � �− � � � � ]

4. Reflect the line P1P2 through the standard y-z plane.

5. Reverse steps 2

6. Reverse step 1

Orthographic Projection

The simplest of the Parallel projections is the orthographic projection, commonly used for engineering

drawings. They accurately show the correct or true size and shape of single plane face of an object.

Orthographic projections are projections onto one of the coordinate planes x = 0, y = 0, z = 0.The matrix for

projection onto the z plane is

� = [

]

Notice that the third column (the z column) is all zeros. Consequently, the effect of the transformation is to set

the z coordinate of a position vector to zero. Similarly, the matrices for projection on to x = 0 and y = 0 planes

are:

Page 20: Graphics Standards and Algorithm

� = [

] an� � = [

]

Axonometric Projection

A single orthographic projection fails to illustrate the general three-dimensional shape of an object.

Axonometric projections overcome this limitation. An axonometric projection is constructed by

manipulating the object using rotations and translations, such that at least three adjacent faces are

shown. The result is then projected from the center of projection at infinity on to one of the coordinate plane

unless a face is parallel to the plane of projection, an axonometric projection does not show its true shape.

However, the relative lengths of originally parallel lines remain constant, i.e., parallel lines are equally

foreshortened.

Foreshortening Factor

It is the ratio of the projected length of a line to its true length. Types of axonometric projections:

1. Trimetric

2. Dimetric

3. Isometric

Trimetric projection is the least restrictive and isometric projection is the most restrictive.

Trimetric Projection

A trimetric projection is formed by arbitrary rotations in arbitrary order, about any or all of the

coordinate axes, followed by parallel projection on to the z = 0 plane. The wide variety of trimetric

projections precludes giving a general equation for these ratios. For any specific trimetric projection, the

foreshortening ratios are obtained by applying transformation matrix to the unit vector along the principal

axis specifically,

[ ][ ] = [ ] [ ] = [ ∗ ∗∗ ∗∗ ∗ ] where [U] is the matrix of unit vectors along the untransformed x, y and z axes respectively, and [T] is the

concatenated trimetric projection matrix. The foreshortening factors along the projected principal axes are

then

� = √ ∗ + ∗ ; � = √ ∗ + ∗ ; � = √ ∗ + ∗

Oblique Projection:

Oblique projections illustrate the general 3 dimensional shape of the object. However only faces of the object

parallel to the plane of projection are shown at there true size and shape that is angles and lengths are

preserved for these faces only. In fact, the oblique projection of these faces is equivalent to an

orthographic front view.

Page 21: Graphics Standards and Algorithm

Types of Oblique Projections

1. Cavalier

2. Cabinet

Cavalier Projection

A cavalier projection is obtained when the angle between oblique projectors and the plane of projection is 450

degree. In a cavalier projection the foreshortening factors for all three principal directions are equal. The

resulting figure appears too thick. A cabinet projection is used to correct this deficiency.

Cabinet Projection

An oblique projection for which the foreshortening factor for edges perpendicular to the plane of projection is

one half is called a Cabinet Projection.