Professional Documents
Culture Documents
Cad Unit I
Cad Unit I
Cad Unit I
OVERVIEW OF SUBJECT
2
INTRODUCTION TO COMPUTER AIDED
DESIGN AND DISPLAY DEVICES
HEMANT M. BANSOD
Assistant Professor, Mechanical Engineering
S. B. Jain Institute of Technology, Management
& Research, Nagpur
3
1. Introduction to Finite Element
Method for engineers –
Chadrupatla and Belegunde
4
UNIT-I
INTRODUCTION TO CAD, CONVENTIONAL
PROCESS,RASTERIZATION TECHNIQUES,
FRAME BUFFER.
5
Computer Aided Design (CAD):-
Computer Aided Design is defined as any design
activity that involves the effective use of the
computer to create, modify, analyze or document
an engineering design.
6
General Design process:-
The general process of design is characterized by “Mechanical Engineering
Design by Shigley” as an iterative process consisting of six phases:
RECOGNITION OF NEED
PROBLEM IDENTIFICATION
SYNTHESIS
EVALUATION
PRESENTATION
7
Design Process using CAD:-
With reference to the six phases of design, a CAD can beneficially be used in
four of design phases, as indicated in table and illustrated in figure as an
overlay on the design process of Mechanical Engineering Design by Shigley.
RECOGNITION OF
NEED
CONVENTIONAL PROCESS
PROBLEM
IDENTIFICATION CAD PROCESS
SYNTHESIS
GEOMETRIC MODELING
ANALYSIS AND
OPTIMIZATION ENGINEERING ANALYSIS
PRESENTATION
AUTOMATED DRAFTING
8
1. Geometric modeling:-
Geometric modeling involves the use of a CAD system to develop
a mathematical description of the geometry of an object.
2. Engineering Analysis:-
The analysis may take the form of stress-strain calculations,
heat transfer analysis, or dynamic simulation. The availability of
software for engineering analysis on a CAD system greatly increases
the designer’s ability and willingness to perform a more types of
analysis. CAD systems include
i) Mass properties analysis
ii) Finite element analysis
iii) Kinematic and dynamic analysis
9
iv) Discrete-event simulation
3. Design Evaluation and Review:-
CAD features that are helpful in evaluating and reviewing a
proposed design include:
i) Automated Dimensioning
ii) Error Checking
iii) Animation of discrete event
iv) Automated Drafting
Benefits of CAD:-
1) Increased Productivity
2) Reduction in time, necessary for the development of conceptual
designing, analysis and documentation.
3) Integration between designing, analysis to manufacturer through
provision of a common data base.
4) Design errors can be eliminated at the early stages of design.
5) Improves documentation and standardization of engineering design.
6) Eliminates tedious task of performing long mathematical
calculations.
7) Provides opportunity for more alternative designs to be produced
before final production. 10
Input Devices:-
The input devices are mainly classified in two classes based
on possible ways of inputting (feeding) the information ,
1. Text input devices:-
Keyboard
Keyboards are used as entering text strings. It is efficient devices for
inputting such a non graphics data as picture label.
b) Digitizer:-
Digitizer is common device for drawing painting or interactively
selecting coordinates position on an object.
13
2. In the Raster scan system, the screen is scanned from left to
right, top to bottom, all the time to generate graphics. This is
similar to the home television scan system, the suggesting the
name “Digital scan”.
14
In raster display, the display screen area is divided horizontally and vertically
into the matrix of small elements called picture element or pixels.
A pixel is the smallest addressable area on the screen.
An N×M resolution defines a screen with N rows and M columns. Each row
defines a scan line.
A rasterization process is needed in order to display either a shaded area or
graphics entities.
In the process, the area or entities are converted into their corresponding
pixels whose intensity and color are controlled by the image display systems.
Pixel
X 15
Difference Between Raster and Random Scan System
Base of Difference Raster Scan System Random Scan System
Electron Beam The electron beam is swept across the
The electron beam is directed only to the parts
screen, one row at a time, from top to
of screen w here a picture is to be drawn.
bottom.
Resolution Its resolution is poor because raster system
Its resolution is good because this system
in contrast produces zigzag lines that are
produces smooth lines drawings because
plotted as discrete point sets.
CRT beam directly follows the line path.
Picture Definition Picture definition is stored as a set of Picture definition is stored as a set of line
intensity values for all screen points, called drawing instructions in a display file.
pixels in a refresh buffer area.
The capability of this system to store
These systems are designed for line-
intensity values for pixel makes it well
Realistic Display drawing and can’t display realistic shaded
suited for the realistic display of scenes
scenes.
contain shadow and color pattern.
Screen points/pixels are used to draw an Mathematical functions are used to draw an
Draw an Image
image. image.
16
Display Devices:-
The three existing CRT display that are based on
the random and raster scan technique of scan are as follows,
17
2. Direct view storage tube (DVST):-
18
3. Raster display
19
Frame Buffer :-
In raster scan displays a special area of memory is
dedicated to graphics only. This memory is called.
Frame buffer holds set of intensity values for all the
screen points.
That intensity is retrieved from frame buffer and
display on screen one row at a time.
On a black and white system with one bit per pixel
the frame buffer is commonly called a Bitmap.
20
LINE GENERATION ALGORITHM :-
There are two types of algorithm used for line generation
1. Digital Differential analyzer (DDA)
2. Bresenhem Algorithm
In both these algorithms certain common features are incorporated.
When two end points are known, slope of the line is
m=Δy/Δx
Therefore, Δy = mΔx --- 1
21
1. DIGITAL DIFFERENTIAL ANALYZER (DDA) LINE
GENERATION ALGORITHM
Case 1:- Slope of line is +ve & ≤ 1 & line starting from left to right
Case 2:- Slope of line is +ve & ≤ 1 & line starting from right to left
Case 3:- Slope of line is +ve & ≥ 1 & line starting from left to right
Case 4:- Slope of line is +ve & ≥ 1 & line starting from right to left
Xi+1 ,Yi+1
Δy
Line having m > 1
Xi , Yi Δx
22
Case 1:- Slope of line is +ve & ≤ 1 & line starting from left to right
Let (xi, yi) be any point on the line, as slope of line is less than 1, increment in X-
coordinate is set to unity i.e., Δ x = 1.
The X- coordinate of next point is xi+1 and Y-coordinate of next point i.e., yi+1 is
found out using the basic equation of slope i.e.,
m=Δy/Δx
m =Δy (as Δ x= 1)
Thus, the equation can be written as,
yi+1 – yi = m
yi+1 = yi + m
Using the above equation, it is possible to calculate Y-coordinate of next point, the
procedure is continued till the other end point of the line is reached.
It is necessary to round off the value of Y-coordinate to the next higher integer
because pixel on computer screen are oriented in integer fashion. This is the
disadvantage associated with DDA algorithm. Rounding off the numbers takes
longer time compared to execution of simple arithmetic operations.
23
Case 2:- Slope of line is +ve & ≤ 1 & line starting from right to left
The procedure is exactly the same as that of Case 1 except the change in X-
coordinate i.e., Δ x= -1
The X- coordinate of next point is xi+1 and Y-coordinate of next point i.e., yi+1 is
found out using the basic equation of slope i.e.,
m=Δy/Δx
- m=Δy (as Δ x= -1)
Thus, the equation can be written as,
yi+1 – yi = - m
yi+1 = yi - m
Using the above equation, it is possible to calculate Y-coordinate of next point, the
procedure is continued till the other end point of the line is reached.
24
Case 3:- Slope of line is +ve & ≥ 1 & line starting from left to right
Let (xi, yi) be any point on the line, as slope of line is greater than 1, increment in
Y-coordinate is set to unity i.e., Δ y = 1.
The Y- coordinate of next point is yi+1 and X-coordinate of next point i.e., xi+1 is
found out using the basic equation of slope i.e.,
m=Δy/Δx
m=1/Δx (as Δ y= 1)
Δx=1/m
Thus, the equation can be written as,
xi+1 – xi = 1 / m
xi+1 = xi + 1 / m
Using the above equation, it is possible to calculate X-coordinate of next point, the
procedure is continued till the other end point of the line is reached.
25
Case 4:- Slope of line is +ve & ≥ 1 & line starting from right to left
In this case, absolute value of the slope is considered. If absolute value of the slope
is less than or equal to 1 then Case 1 or Case 2 is followed.
26
2. BRESENHEM’s LINE GENERATION ALGORITHM
Two important points must be noted in case of this algorithm,
1. Line is always drawn from left to right, out of two end points given by user, the
bresenhem’s algorithm decides the one which is lying to the left as the starting point.
2. The equation of line y = mx + c is used to generate a line where c is the y –intercept.
yi + 1
d2
y
d1
yi
xi + 1 27
As the slope of line is less than 1, increment in x-coordinate is set to unity i.e., Δx = 1
Let (xi, yi) be any point on the line, the x-coordinate of next point will be xi+1 while y-
coordinate of the next point i.e., yi or yi+1 is decided by defining two parameters d1 and
d2 (decision parameters).
d1 = y – yi
d2 = yi + 1 –y
Where,
y = m (xi + 1)+ c
Substituting the value of y in the expression of d1 and d2 we have,
d1 = m (xi + 1)+ c – yi
d2 = yi + 1 – m (xi + 1)+ c
d1 - d2 = 2m (xi + 1) – yi – (yi + 1) + 2c
d1 - d2 = 2m (xi + 1) – 2yi + 2c – 1
d1 - d2 = 2(Δy / Δx) (xi + 1) – 2yi + 2c – 1
Δx (d1 - d2 ) = 2(Δy) (xi + 1) – 2 Δx yi + Δx (2c – 1)
Δx (d1 - d2 ) = 2Δy xi – 2 Δx yi + 2 Δy + Δx (2c – 1)
pi = 2Δy xi – 2 Δx yi + b
Where, pi = Δx (d1 - d2 )
& b = 2 Δy + Δx (2c - 1 )
28
The value of b remains constant for the complete line. The value of pixel position, pi is
evaluated to decide the pixel.
If pi < 0 , then select the pixel at position yi.
If pi ≥ 0 , then select the pixel at position yi + 1.
The procedure is continued till we reach the other end point of line.
In this procedure there is no rounding off operation, only the value of pi is to be
evaluated.
The expression of pi consists of simple arithmetic expression, which can be evaluated at
a faster rate on computer.
In this case, absolute value of m is considered and the procedure as laid down in Case 1
& Case 2 is followed except one coordinate increases while other decreases.
29
NUMERICAL ON BRESENHAM’S LINE GENERATION
31
Iterations (xi, yi) Pi (xi+1, yi+1) Pi+1 = Pi + 2 ∆y - 2 ∆x (yi+1 – yi)
0 (35, 40) 2 (36, 41) 2+10 – 16 (41- 40) = - 4
1 (36, 41) -4 (37, 41) - 4 +10 – 16 (41 – 41) = 6
2 (37, 41) 6 (38, 42) 6 + 10 – 16 (42 – 41) = 0
3 (38, 42) 0 ( 39, 43) 0 + 10 – 16 (43 – 42 ) = - 6
4 ( 39, 43) -6 ( 40 , 43) - 6 + 10 -16 (43 – 43 ) = 4
5 ( 40, 43 ) 4 ( 41, 44) 4 + 10 -16 (44 – 43) = - 2
6 ( 41, 44) -2 ( 42, 44) - 2 + 10 -16 ( 44 - 44) = 8
7 ( 42, 44) 8 ( 43, 45) Reach the end coordinates
32
By plotting all co-ordinates
46
45
44 By removing the repeat co-
43 ordinates
46
42
41 45
40 44
39 43
0 20 40 60 42
41
40
39
0 20 40 60
33
Example 2 :- Write bresenham’s algorithm for line generation for
slope is less than 1, using algorithm generate a line from ( 5, 8)
to ( 9, 11) – Summer 2017 for 9 Marks
34
Bresenhum’s Algorithm for Circle Generation :-
Due to symmetry of circle only 1/8th part of the circle is drawn by calculating the
position of the pixel and remaining 7/8th part of the circle is generated by symmetry.
y=x
8 1
7
2
6 3
5 4
35
Mid Point Generating Algorithm (xi+1, yi)
(0,R)
yi
M (xi+1, yi-1/2)
|m|< 1 yi -1
(xi+1, yi-1)
xi
1
Let (xi, yi) be the ith pixel on the circle.
Let (xi+1, yi+1) be the i+1th pixel.
As slope is less than one i.e., |m|< 1 then increment in x- coordinate is set to unity
xi + 1 = xi + 1
yi + 1 = yi or yi - 1
A mid point ‘M’ between two pixel yi and yi – 1 is selected as shown in figure and
position of this point is used to determine whether yi or yi – 1 pixel is closer to circle.
37
Pi +1 − Pi = [( xi + 1 + 1) 2 − ( xi + 1) 2 ] + [( yi + 1 − 1 / 2) 2 − ( yi − 1 / 2) 2 ]
Pi +1 = Pi + [( xi + 1 + 1) 2 − ( xi + 1) 2 ] + [( yi + 1 − 1 / 2) 2 − ( yi − 1 / 2) 2 ]
5
If Pi < 0 then M is inside
xi + 1 = xi + 1
yi + 1 = yi
Pi +1 = Pi + [( xi + 2) 2 − ( xi + 1) 2 ] + [( yi − 1 / 2) 2 − ( yi − 1 / 2) 2 ]
Pi +1 = Pi + [( xi + 2) 2 − ( xi + 1) 2 ]
Pi +1 = Pi + 2 xi + 3 6
38
If Pi > 0 then M is outside
xi + 1 = xi + 1
yi + 1 = yi - 1
Substitute in equation 5, we get,
Pi + 1 = Pi + [( xi + 1 + 1) 2 − ( xi + 1) 2 ] + [( yi − 1 − 1 / 2) 2 − ( yi − 1 / 2) 2 ]
Pi + 1 = Pi + [( xi + 2) 2 − ( xi + 1) 2 ] + [( yi − 3 / 2) 2 − ( yi − 1 / 2) 2 ]
Pi + 1 = Pi + 2 xi + 3 + [( yi 2 − 3 yi + 9 / 4) − ( yi 2 − yi + 1 / 4)]
Pi + 1 = Pi + 2 xi + 3 + [ yi 2 − 3 yi + 9 / 4 − yi 2 + yi − 1 / 4]
Pi + 1 = Pi + 2 xi + 3 + [ −2 yi + 8 / 4]
Pi + 1 = Pi + 2 xi − 2 yi + 5 7
P1 = (0 + 1) 2 + ( R + 1 / 2) 2 − R 2
P1 = 1 + R 2 − R + 1 / 4 − R 2
5
P1 = −R (Float Value)
4
P1 = 1 − R (Integer Value) 8 39
NUMERICAL ON BRESENHAM’S CIRCLE GENERATION
(MIDPOINT CIRCLE GENERATING ALGORITHM)
41
By plotting all co-ordinates
9
8
7
By removing the repeat co-
6
ordinates
5
9
4
8
3
7
2
6
1
5
0
0 5 10 4
3
2
1
0
0 5 10
42
Example 2 :- Write bresenham’s algorithm for circle generation
using algorithm generate a circle with radius 10 units at centre
( 1, 1) up to first octant– Winter 2018 for 9 Marks
43
Iterations (xi, yi) Pi (xi+1, yi+1) Pi+1 = Pi + [ (xi+1 +1)2 – (xi + 1)2] + [ (yi+1 -1/2)2 - (yi – 1/2)2]
44
BRESENHUM’s ALGORITHM FOR GENERATION OF ELLIPSE
Mid – point generating algorithm for ellipse
x2 y2
2
+ 2
=1
Equation of Ellipse is Rx Ry
Due to symmetry of ellipse only 1/4th part of the ellipse is drawn by plotting of pixel
and remaining 3/4th part is generated by symmetry.
|m| < 1
|m| > 1
Ry
Rx
45
To draw 1/4th part of the ellipse, we have to divide it into two parts i.e., Part I and Part II
as shown in figure.
|m| < 1
|m| > 1
(0, Ry)
I
II
x2 y2
Equation of Ellipse is
2
+ 2
=1
Rx Ry
x 2 Ry 2 + y 2 Rx 2 = Rx 2 Ry 2
Differentiate w.r.t. x and y, we get
2 xdxRy 2 + 2 ydyRx 2 = 0
2 xdxRy 2 = −2 ydyRx 2
dy xRy 2
=− 1
dx yRx 2
dy
=m 46
dx
xRy2 < yRx2 xRy2 = yRx2
Put dy
= −1 in equation 1
dx
xRy 2
-1 = −
yRx 2
xRy 2 = yRx 2
47
At a point on ellipse where slope is - 1 condition is
xRy 2 = yRx 2
Ellipse is now divided into two parts,
Part 1 : -
| m | 1
xRy 2 yRx 2
xi + 1 = xi + 1
yi + 1 = yi or yi − 1
Part 2 : -
| m | 1
xRy 2 yRx 2
yi + 1 = yi + 1
xi + 1 = xi or xi + 1
48
MID POINT ALGORITHM TO DRAW PART I OF ELLIPSE WHERE |m| < 1 :-
(xi+1, yi)
yi
M (xi+1, yi-1/2)
|m|< 1 yi -1
(xi+1, yi-1)
xi xi+1
1
ith
Let (xi, yi) be the pixel on the circle.
Let (xi+1, yi+1) be the i+1th pixel.
As slope is less than one i.e., |m|< 1 then increment in x- coordinate is set to unity
xi + 1 = xi + 1
yi + 1 = yi or yi - 1
49
2. If midpoint ‘M’ is outside the circle then,
xi + 1 = xi +1
yi + 1 = yi – 1
x Ry + y Rx − Rx Ry = 0
2 2 2 2 2 2
Let
Pi = xm Ry 2 + ym Rx 2 − Rx 2 Ry 2
2 2
Pi = ( xi + 1) 2 Ry 2 + ( yi − 1 / 2) 2 Rx 2 − Rx 2 Ry 2 2
50
Equation 2 – 3, we get,
Pi +1 − Pi = [( xi + 1 + 1) 2 − ( xi + 1) 2 ]Ry 2 + [( yi + 1 − 1 / 2) 2 − ( yi − 1 / 2) 2 ]Rx 2
Pi +1 = Pi + [( xi + 1 + 1) 2 − ( xi + 1) 2 ]Ry 2 + [( yi + 1 − 1 / 2) 2 − ( yi − 1 / 2) 2 ]Rx 2 4
If Pi 0 then
xi + 1 = xi + 1
yi + 1 = yi
Put in equation 4, we get,
Pi + 1 = Pi + [( xi + 1 + 1) 2 − ( xi + 1) 2 ]Ry 2 + 0
Pi + 1 = Pi + [( xi + 2) 2 − ( xi + 1) 2 ]Ry 2
Pi + 1 = Pi + [ xi 2 + 4 xi + 4 − xi 2 − 2 xi − 1]Ry 2
Pi + 1 = Pi + [2 xi + 3]Ry 2 5
51
If Pi 0 then
xi + 1 = xi + 1
yi + 1 = yi − 1
Put in equation 4, we get,
Pi + 1 = Pi + [2 xi + 3]Ry 2 + [( yi − 1 − 1 / 2) 2 − ( yi − 1 / 2) 2 ]Rx 2
Pi + 1 = Pi + [2 xi + 3]Ry 2 + [( yi − 3 / 2) 2 − ( yi − 1 / 2) 2 ]Rx 2
Pi + 1 = Pi + [2 xi + 3]Ry 2 + [ yi 2 − 3 yi + 9 / 4 − yi 2 + yi − 1 / 4]Rx 2
Pi + 1 = Pi + [2 xi + 3]Ry 2 + [−2 yi + 2]Rx 2
Pi + 1 = Pi + [2 xi + 3]Ry 2 + [2 − 2 yi]Rx 2 6
52
Condition for plotting first pixel
Put xi = 0, yi = Ry, Pi = P1 in equation 2
Pi = ( xi + 1) 2 Ry 2 + ( yi − 1 / 2) 2 Rx 2 − Rx 2 Ry 2
Pi = (0 + 1) 2 Ry 2 + ( Ry − 1 / 2) 2 Rx 2 − Rx 2 Ry 2
Pi = Ry 2 + ( Ry − 1 / 2) 2 Rx 2 − Rx 2 Ry 2
Pi = Ry 2 + ( Ry 2 − Ry + 1 / 4) Rx 2 − Rx 2 Ry 2
Pi = Ry 2 + Ry 2 Rx 2 − RyRx 2 + 1 / 4 Rx 2 − Rx 2 Ry 2
Pi = Ry 2 − RyRx 2 + 1 / 4 Rx 2
Pi = Ry 2 − Rx 2 ( Ry − 1 / 4) for float value
Pi = Ry 2 − Rx 2 Ry for Integer Value
53
MID POINT ALGORITHM TO DRAW PART II OF ELLIPSE WHERE |m| > 1 :-
(xi-1, yi+1)
M (xi-1/2, yi+1)
|m|>1 yi -1
yi (xi, yi+1)
xi-1 xi
1
Let (xi, yi) be the ith pixel on the circle.
Let (xi+1, yi+1) be the i+1th pixel.
As slope is less than one i.e., |m|> 1 then increment in y- coordinate is set to unity
yi + 1 = yi + 1
xi + 1 = xi or xi - 1
54
2. If midpoint ‘M’ is outside the circle then,
yi + 1 = yi +1
xi + 1 = xi – 1
x Ry + y Rx − Rx Ry = 0
2 2 2 2 2 2
Let
Pi = xm Ry 2 + ym Rx 2 − Rx 2 Ry 2
2 2
Pi = ( xi − 1 / 2) 2 Ry 2 + ( yi + 1) 2 Rx 2 − Rx 2 Ry 2 2
55
Equation 2 – 3, we get,
Pi +1 − Pi = [( xi + 1 − 1 / 2) 2 − ( xi − 1 / 2) 2 ]Ry 2 + [( yi + 1 + 1) 2 − ( yi + 1) 2 ]Rx 2 4
If Pi 0 then
yi + 1 = yi + 1
xi + 1 = xi
Put in equation 4, we get,
Pi + 1 = Pi + [( xi − 1 / 2) 2 − ( xi − 1 / 2) 2 ]Ry 2 + [( yi + 1 + 1) 2 − ( yi + 1) 2 ]Rx 2
Pi + 1 = Pi + [( yi + 2) 2 − ( yi + 1) 2 ]Rx 2
Pi + 1 = Pi + [ yi 2 + 4 yi + 4 − yi 2 − 2 yi − 1]Rx 2
Pi + 1 = Pi + [2 yi + 3]Rx 2 5
56
If Pi 0 then
yi + 1 = yi + 1
xi + 1 = xi − 1
Put in equation 4, we get,
Pi + 1 = Pi + [( xi − 1 − 1 / 2) 2 − ( xi − 1 / 2) 2 ]Ry 2 + [2 yi + 3]Rx 2
Pi + 1 = Pi + [−2 xi + 2]Ry 2 + [2 yi + 3]Rx 2 6
57
Condition for plotting first pixel
Put xi = Rx, yi = 0, Pi = P1 in equation 2
Pi = ( Rx − 1 / 2) 2 Ry 2 + (0 + 1) 2 Rx 2 − Rx 2 Ry 2
Pi = ( Rx 2 − Rx + 1 / 4) Ry 2 + Rx 2 − Rx 2 Ry 2
Pi = Rx 2 Ry 2 − RxRy 2 + 1 / 4 Ry 2 + Rx 2 − Rx 2 Ry 2
Pi = Rx 2 − RxRy 2 + 1 / 4 Ry 2
Pi = Rx 2 − Ry 2 ( Rx − 1 / 4) for float value
Pi = Rx 2 − Ry 2 Rx for Integer Value
58
NUMERICAL ON BRESENHAM’S ELLIPSE GENERATION
(MIDPOINT ELLIPSE GENERATING ALGORITHM)
6 (6, 4) 228 (7, 3) Ellipse reached up to part I afterwards the |m| > 1
60
Conditions for plotting part II of ellipse where |m| > 1
Pi +1 = Pi + [( xi + 1 − 1 / 2) 2 − ( xi − 1 / 2) 2 ]Ry 2 + [( yi + 1 + 1) 2 − ( yi + 1) 2 ]Rx 2
(0, 6) Part I
(7,3)
Part II
61
Pi +1 = Pi + [( xi + 1 − 1 / 2) 2 − ( xi − 1 / 2) 2 ]Ry 2 + [( yi + 1 + 1) 2 − ( yi + 1) 2 ]Rx 2
Iterations (xi, yi) Pi (xi+1, yi+1)
62
By plotting all co-ordinates
7
6
5 By removing the repeat co-
4
ordinates
7
3
6
2
5
1
4
0
0 5 10 3
2
1
0
0 5 10
63
THANK YOU.
64