Está en la página 1de 55

CAD/CAM Principles and Applications

Ch 3 Computer Graphics

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

Objectives
Convert vector straight lines to raster images to be displayed on a raster terminal utilizing the pixel information Understand the problems associated with displaying vectorial information on a raster terminal Various types of coordinate systems used in displaying CAD information The data requirements of a graphic image and the database storage methods used Different types of geometric transformations used during CAD geometry generation and display and their evaluation Mathematics required to display a 3D image on the 2D screen of the display device Understand the problems associated with the display of graphic images in the display screen such as clipping and hidden line elimination
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 2

3.1 Raster Scan Graphics


DDA or Digital Differential Analyser is one of the first algorithms developed for rasterising the vectorial information. The equation of a straight line is given by Y =m X + C

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

Fig. 3.1 A straight line drawing

y2 y1

x1 x2
CAD/CAM Principles and Applications by P N Rao, 2nd Ed

X
4

Fig. 3.2 Flow chart for line drawing calculation procedure

Calculate dx = x2 - x1 dy = y2 - y1

If |dx| > |dy| No ST = |dy|

Yes

St = |dx|

dx = dx / ST dy = dy / ST X = xi Y = yi Set pixel at X, Y X = X + dx Y = Y + dy

End of Loop? No Yes STOP

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

3.1.2 Bresenham's Algorithm


Bresenham's method is an improvement over DDA since it completely eliminates the floating-point arithmetic except for the initial computations. All other computations are fully integer arithmetic thus is more efficient for raster conversion
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 6

Fig. 3-3 Line drawing using Bresenham algorithm


Y

i+1 y i i i+1

d2 d1

X
7

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

Fig. 3.4 Flow chart for line drawing calculation using Bresenham procedure

Calculate dx = x2 - x1 dy = y2 - y1 C1 = 2 dy C2 = 2 (dy - dx) x = x1 y = y1 p1 = 2 dy - dx Put a pixel at (x1, y1)

x=x+1

If Pi < 0

No

P(i+1) = Pi + C2 Y(i+1) = y(i) + 1

Yes P(i+1) = P(i) + C1 y(i+1) = y(i)

No

End of loop? Yes STOP

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

3.1.3 Antialiasing lines

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

Fig. 3.5 The staircase effect of pixels when drawing inclined lines

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

10

Fig. 3.6 The staircase effect of pixels when drawing inclined lines decreases with increased resolution

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

11

Fig. 3.7 Antialiasing of pixels proportional to the portion of pixel occupied by the line

8 7 6 5 4 3 2 1 1 2 3 4 5 6 7 8

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

12

Fig. 3.8 Unequal number of lines displayed with the same number of pixels

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

13

3.2 Co-ordinate systems

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

14

Fig. 3.9 A typical component to be modelled


50 90

60

120

40

40

20

15 0

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

30

15

World Co-ordinate System


This refers to the actual co-ordinate system used as master for the component. Some times it may also be called as model co-ordinate system.

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

16

Fig. 3.10 A typical component with its associated WCS

Z Y

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

17

User Co-ordinate System


However, sometimes it becomes difficult to define certain geometries if they are to be defined from the WCS. In such cases alternate co-ordinate systems can be defined relative to the WCS. These co-ordinate systems are termed as user co-ordinate systems (UCS) or working co-ordinate systems.
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 18

Fig. 3.11 A typical component with its associated UCS

Z' Z Y X' X Y'

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

19

Display Co-ordinates
This refers to the actual co-ordinates to be used for displaying the image on the screen.

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

20

Fig. 3.12 A typical component with its various view positions


TOP

Z Y FRONT X
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 21

RIGHT SIDE

Fig. 3.13 Various views generated from the model shown in Fig 3.12
60 90 20

Y X

Z
50

TOP
60

120

X Y

30

Z
150

40

Z Y X RIGHT SIDE

FRONT

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

20

22

3.3 Database Structures for Graphic Modelling

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

23

3.3 Database Structures for Graphic Modelling


Organisational data Identification number, Drawing number, Design origin and status of changes, Current status, Designer name, Date of design, Scale, Type of projections, Company. Technological data Geometry, Dimensions, Tolerances, Surface finishes, Material specifications or reference, Manufacturing procedures, Inspection procedures.
24

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

Fig. 3.14 Data structure for geometric models


SOLID EDGE

VERTEX VERTEX SURFACE

SURFACE

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

25

Fig. 3.15 Complete data structure for geometric models of products


Product Assembly Dimensions Single parts Attributes

Solid body

Faces

Edges Vertices

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

26

Fig. 3.16 Relational data structure for geometric models


solid body Face list Edges X Vertices Y Z

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

27

3.4 Transformation of Geometry


Translation Scaling Reflection or Mirror Rotation

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

28

Fig. 3-17 Some of the possible geometric transformations


Y Y

dX

dY

Translation

Scaling
Y

25

30

X
25

Rotation Reflection
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 29

Fig. 3.18 Translation of geometry


Y Y' Z' P P*

X' Z

X
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 30

Fig. 3.19 Translation of geometry in 2D


Y Y'
dY

P*

P X'
dX

X
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 31

Fig. 3.20 Scaling of geometry in 2D


Y

P*

sY

P
Y

X sX

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

32

Fig. 3.21 Reflection of geometry in 2D


Y Y

28 25

28

X
25

-X

-X

-Y

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

33

Fig. 3.22 Example for reflection transformation


Y

P y

X P* -y
CAD/CAM Principles and Applications by P N Rao, 2nd Ed

34

Fig. 3-23 Example for rotation transformation

Y P* y* P

r y

x*

X x
35

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

Fig. 3.24 Example

13.66

8.66

10
30

3.66 5 8.66

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

36

3.4.5 Concatenation of transformations


[P*] = [Tn] [Tn-1] [Tn-2] .. [T3] [T2] [T1]

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

37

3.4.6 Homogeneous Representation


x * 1 0 dX x y * = 0 1 dY y [P *] = 1 0 0 1 1

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

38

Rotation about an arbitrary point


Translate the point P to O, the origin of the axes system. Rotate the object by the given angle Translate the point back to its original position.

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

39

Fig. 3.25 Rotation about an arbitrary point


Y

P* r A dY P

X dX
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 40

Reflection about an arbitrary line


Translate the mirror line along the Y-axis such that the line passes through the origin, O Rotate the mirror line such that it coincides with the X-axis. Mirror the object through the X-axis. Rotate the mirror line back to the original angle with X-axis. Translate the mirror line along the Y-axis back to the original position.
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 41

Fig. 3.26 Example for reflection transformation about an arbitrary line


Y P* P

O
CAD/CAM Principles and Applications by P N Rao, 2nd Ed

X
42

3.5 3D Transformations
x * 1 y * 0 = z * 0 1 0 0 0 dX 1 0 dY 0 1 dZ 0 0 1 x y z 1

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

43

3.6 Mathematics of Projection

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

44

Fig. 3.27 The principle of projection


Projector Drawing Object

Projecting plane

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

45

Fig. 3.28 An object enclosed in a cube to obtain various parallel projections

B E

C Y

A D

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

46

Fig. 3.29 Orthographic projection of an object


B E B C Y D X A D LEFT SIDE VIEW FRONT VIEW Z A X TOP VIEW X Z C E Y

Y RIGHT SIDE VIEW REAR VIEW

BOTTOM VIEW

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

47

3.7 Clipping

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

48

Fig. 3.30 Clipping of geometry for display


T

B
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 49

Fig. 3.31 The 4-digit coding of the line end points for clipping

1001 0001 0101

1000 0000 0100

1010 0010 0110


50

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

Fig. 3.32 Identical line clipping of two different geometries

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

51

Fig. 3.33 Clipping produced for different geometries by polygon clipping

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

52

Fig. 3.34 Back-face removal using the face normal and projecting ray

Z Y P X
CAD/CAM Principles and Applications by P N Rao, 2nd Ed

N
53

Summary
In order to display the graphical information, which is vectorial in nature, it is necessary to convert it into raster format. For converting lines into raster format, DDA algorithm is simplest while Bresenhams algorithm reduces the computations into integer format thereby making it a faster alternative. It is necessary to modify the pixel information for display to get more realistic visual experience. Depending upon the type of graphic display used, it is necessary to be familiar with a number of different coordinate systems to facilitate the graphic construction as well as display. In addition to the actual graphic information, a large amount of additional data such as organizational and technological data is stored with the product data.

CAD/CAM Principles and Applications by P N Rao, 2nd Ed

54

Summary
Geometric transformations can be handled conveniently using matrix algebra. For this purpose it is necessary to use homogenous representation of vertex data. Various transformations that are quite useful are translation, rotation, scale and reflection. The 2D transformation methods can be easily extended into 3D. The 3D geometry data needs to be converted into 2D by adopting a suitable projection system such as orthographic, isometric or perspective projection. Since only part of the geometric model will be displayed most of the time, it is necessary to clip the information outside the display window. Also it is necessary some times to remove the hidden lines to make the display easier to understand. For this purpose back face removal and depth buffer (Z) are used.
CAD/CAM Principles and Applications by P N Rao, 2nd Ed 55

También podría gustarte