GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: INTRODUCTION TO COMPUTER GRAPHICS
1.1
COMPUTER GRAPHICS
The study of computer graphics is a sub-field of computer science which studies methods for
digitally synthesizing and manipulating visual content. Although the term often refers to
three-dimensional computer graphics, it also encompasses two-dimensional graphics and
image processing.
As an academic discipline, computer graphics studies the manipulation of visual and
geometric information using computational techniques. It focuses on the mathematical and
computational foundations of image generation and processing rather than purely aesthetic
issues. Computer graphics is often differentiated from the field of visualization, although the
two fields have many similarities.
The term Computer Graphics has several meanings:
1. The representation and manipulation of pictorial data by a computer
2. The various technologies used to create and manipulate such pictorial data
3. The sub-field of computer science which studies methods for digitally synthesizing and
manipulating visual content, see study of computer graphics.
Today computers and computer-generated images touch many aspects of our daily life.
Computer imagery is found on television, in newspapers, in weather reports, and during
surgical procedures. A well-constructed graph can present complex statistics in a form that is
easier to understand and interpret. Such graphs are used to illustrate papers, reports, theses,
and other presentation material. A range of tools and facilities are available to enable users to
visualize their data, and computer graphics are used in many disciplines.
1.2
INPUT/OUTPUT DEVICES
A. Input devices
It is used to put data & instructions into a computer. There are 2 main types of input device:
Direct & Manual.
Direct input devices: They can input large amounts of data quickly and accurately without any need for human
intervention. Barcode readers and optical mark readers are examples of direct input devices.
Manual Input Devices: 1
They are used by people to enter data by hand. The most commonly used input
devices are Mouse and the Keyboard.
(a)
Keyboard :It is a text base input device that allows the user to input alphabets, numbers and other
characters. It consists of a set of keys mounted on a board. This way of arranging the keys is
called QWERTY because of the order in which the keys appear on the first row of letters.
This layout was originally designed to separate common letter pairs, in order to prevent
nearby type-bars on a manual typewriter jamming the mechanism when typing at speed.
Keyboards are now available with different layouts designed help users type more quickly
and comfortably.
(b)
Mouse :The mouse is a small device used to point to a particular place on the screen and select in
order to perform one or more actions. It can be used to select menu commands, size windows,
start programs etc. The most conventional kind of mouse has two buttons on top: the left one
being used most frequently.
(c)
Joystick :The joystick is a vertical stick which moves the graphic cursor in a direction the stick is
moved. It typically has a button on top that is used to select the option pointed by the cursor.
Joystick is used as an input device primarily used with video games, training simulators and
controlling robots.
2
(d)
Scanner :Scanner is an input device used for direct data entry from the source document into the
computer system. It converts the document image into digital form so that it can be fed into
the computer. Capturing information like this reduces the possibility of errors typically
experienced during large data entry. Hand-held scanners are commonly seen in big stores to
scan codes and price information for each of the items.
(e)
Bar code Readers :A bar code is a set of lines of different thicknesses that represent a number. Bar Code Readers
are used to input data from bar codes. Most products in shops have bar codes on them. Bar
code readers work by shining a beam of light on the lines that make up the bar code and
detecting the amount of light that is reflected back.
3
(f)
Light Pen :It is a pen shaped device used to select objects on a display screen. It is quite like the mouse
(in its functionality) but uses a light pen to move the pointer and select any object on the
screen by pointing to the object. Users of Computer Aided Design (CAD) applications
commonly use the light pens to directly draw on screen.
(g)
Touch Screen :It allows the user to operate/make selections by simply touching the display screen. Common
examples of touch screen include information kiosks, and bank ATMs.
(h)
Digital camera :A digital camera can store many more pictures than an ordinary camera. Pictures taken using
a digital camera are stored inside its memory and can be transferred to a computer by
connecting the camera to it. A digital camera takes pictures by converting the light passing
through the lens at the front into a digital image.
4
(i)
The Speech Input Device :The “Microphones - Speech Recognition” is a speech Input device. To operate it we require
using a microphone to talk to the computer. Also we need to add a sound card to the
computer. The Sound card digitizes audio input into 0/1s .A speech recognition program can
process the input and convert it into machine-recognized commands or input.
B. Output Devices :Output devices are used to retrieve data and information from computer to certain peripheral
devices. Before an output can be produced by a computer it must have an output device
connected to it.
(a)
Monitor :Monitor is an output device that resembles the television screen and uses a Cathode Ray Tube
(CRT) to display information. The monitor is associated with a keyboard for manual input of
characters and displays the information as it is keyed in. It also displays the program or
application output. Like the television, monitors are also available in different sizes.
5
(b)
Liquid Crystal Display (LCD) :LCD was introduced in the 1970s and is now applied to display terminals also. Its advantages
like low energy consumption, smaller and lighter have paved its way for usage in portable
computers (laptops).
(c)
Printer :Printers are used to produce paper (commonly known as hardcopy) output. Based on the
technology used, they can be classified as Impact or Non-impact printers.
Impact printers use the typewriting printing mechanism wherein a hammer strikes the paper
through a ribbon in order to produce output. Dot-matrix and Character printers fall under this
category.
Non-impact printers do not touch the paper while printing. They use chemical, heat or
electrical signals to etch the symbols on paper. Inkjet, DeskJet, Laser, Thermal printers fall
under this category of printers.
(d)
Plotter :Plotters are used to print graphical output on paper. It interprets computer commands and
makes line drawings on paper using multicolored automated pens. It is capable of producing
graphs, drawings, charts, maps etc.
Computer Aided Engineering (CAE) applications like CAD (Computer Aided Design) and
CAM (Computer Aided Manufacturing) are typical usage areas for plotters.
6
(e)
Audio Output: Sound Cards and Speakers :The Audio output is the ability of the computer to output sound. Two components are needed:
Sound card – Plays contents of digitized recordings, Speakers – Attached to sound card.
1.3
GRAPHIC ELEMENTS
A. Image
In common usage, an image or picture is an artifact, usually two-dimensional, that has a
similar appearance to some subject usually a physical object or a person. Images may be twodimensional, such as a photograph, screen display, and as well as a three-dimensional, such
as a statue. They may be captured by optical devices such as cameras, mirrors, lenses,
telescopes, microscopes, etc. and natural objects and phenomena, such as the human eye or
water surfaces.
A digital image is a representation of a two-dimensional image using ones and zeros (binary).
Depending on whether or not the image resolution is fixed, it may be of vector or raster type.
B. Pixel
In the enlarged portion of the image individual pixels are rendered as squares and can be
easily seen. In digital imaging, a pixel is the smallest piece of information in an image. Pixels
are normally arranged in a regular 2-dimensional grid, and are often represented using dots or
squares. Each pixel is a sample of an original image, where more samples typically provide a
more accurate representation of the original. The intensity of each pixel is variable; in color
systems, each pixel has typically three or four components such as red, green, and blue, or
cyan, magenta, yellow, and black.
C. Rendering
Rendering is the process of generating an image from a model, by means of computer
programs. The model is a description of three dimensional objects in a strictly defined
language or data structure. It would contain geometry, viewpoint, texture, lighting, and
shading information. The image is a digital image or raster graphics image. The term may be
by analogy with an "artist's rendering" of a scene. 'Rendering' is also used to describe the
process of calculating effects in a video editing file to produce final video output.
7
D. 3D projection
3D projection is a method of mapping three dimensional points to a two dimensional plane.
As most current methods for displaying graphical data are based on planar two dimensional
media, the use of this type of projection is widespread, especially in computer graphics,
engineering and drafting.
E. Ray tracing
Ray tracing is a technique for generating an image by tracing the path of light through pixels
in an image plane. The technique is capable of producing a very high degree of photorealism;
usually higher than that of typical scan line rendering methods, but at a greater computational
cost.
F. Shading
Shading refers to depicting depth in 3D models or illustrations by varying levels of darkness.
It is a process used in drawing for depicting levels of darkness on paper by applying media
more densely or with a darker shade for darker areas, and less densely or with a lighter shade
for lighter areas. There are various techniques of shading including cross hatching where
perpendicular lines of varying closeness are drawn in a grid pattern to shade an area. The
closer the lines are together, the darker the area appears. Likewise, the farther apart the lines
are, the lighter the area appears.
G. Texture mapping
Texture mapping is a method for adding detail, surface texture, or colour to a computergenerated graphic or 3D model. A texture map is applied (mapped) to the surface of a shape,
or polygon. This process is akin to applying patterned paper to a plain white box.
Multitexturing is the use of more than one texture at a time on a polygon. Procedural textures
(created from adjusting parameters of an underlying algorithm that produces an output
texture), and bitmap textures (created in an image editing application) are, generally
speaking, common methods of implementing texture definition from a 3D animation
program, while intended placement of textures onto a model's surface often requires a
technique known as UV mapping.
H. Volume rendering
Volume rendered CT scan of a forearm with different colour schemes for muscle, fat, bone,
and blood. Volume rendering is a technique used to display a 2D projection of a 3D
discretely sampled data set. A typical 3D data set is a group of 2D slice images acquired by a
CT or MRI scanner. Usually these are acquired in a regular pattern (e.g., one slice every
millimeter) and usually have a regular number of image pixels in a regular pattern.
I. 3D modeling
3D modeling is the process of developing a mathematical, wireframe representation of any
three-dimensional object, called a "3D model", via specialized software. Models may be
created automatically or manually; the manual modeling process of preparing geometric data
for 3D computer graphics is similar to plastic arts such as sculpting. 3D models may be
created using multiple approaches: use of NURBS curves to generate accurate and smooth
surface patches, polygonal mesh modeling (manipulation of faceted geometry), or polygonal
mesh subdivision (advanced tessellation of polygons, resulting in smooth surfaces similar to
NURBS models). A 3D model can be displayed as a two-dimensional image through a
process called 3D rendering, used in a computer simulation of physical phenomena, or
animated directly for other purposes.
8
1.4
INTRODUCTION TO FINITE ELEMENT METHOD OR ANALYSIS
The finite element method (FEM) is a numerical technique for finding approximate solutions
of partial differential equations as well as of integral equations. The solution approach is
based either on eliminating the differential equation completely, or rendering the PDE into an
approximating system of ordinary differential equations, which are then numerically
integrated using standard techniques such as Euler's method, Runge-Kutta, etc.
In solving partial differential equations, the primary challenge is to create an equation that
approximates the equation to be studied, but is numerically stable, meaning that errors in the
input data and intermediate calculations do not accumulate and cause the resulting output to
be meaningless. There are many ways of doing this, all with advantages and disadvantages.
The Finite Element Method is a good choice for solving partial differential equations over
complex domains , when the domain changes, when the desired precision varies over the
entire domain, or when the solution lacks smoothness. For instance, in a frontal crash
simulation it is possible to increase prediction accuracy in "important" areas like the front of
the car and reduce it in its rear; Another example would be the simulation of the weather
pattern on Earth, where it is more important to have accurate predictions over land than over
the wide-open sea.
The finite-element method originated from the need for solving complex elasticity and
structural analysis problems in civil and aeronautical engineering. Its development can be
traced back to the work by Alexander Hrennikoff (1941) and Richard Courant (1942). While
the approaches used by these pioneers are dramatically different, they share one essential
characteristic: mesh discretization of a continuous domain into a set of discrete sub-domains,
usually called elements. Hrennikoff's work discretizes the domain by using a lattice analogy
while Courant's approach divides the domain into finite triangular subregions for solution of
second order elliptic partial differential equations that arise from the problem of torsion of a
cylinder. Courant's contribution was evolutionary, drawing on a large body of earlier results
for PDEs developed by Rayleigh , Ritz, and Galerkin.
Development of the finite element method began in earnest in the middle to late 1950s for
airframe and structural analysis and gathered momentum at the University of Stuttgart
through the work of John Argyris and at Berkeley through the work of Ray W. Clough in the
1960s for use in civil engineering. By late 1950s, the key concepts of stiffness matrix and
element assembly existed essentially in the form used today and NASA issued request for
proposals for the development of the finite element software NASTRAN in 1965. The
method was provided with a rigorous mathematical foundation in 1973 with the publication
of Strang and Fix's An Analysis of The Finite Element Method, and has since been
generalized into a branch of applied mathematics for numerical modeling of physical systems
in a wide variety of engineering disciplines, e.g., electromagnetism and fluid dynamics.
1.4.1 APPLICATION
With the advent of Computer Aided Design (CAD), the Finite Element Method has been
finding wide variety of applications. Some typical applications of FEM are listed below.
A. PLANE STRESS PROBLEMS :
1. Stress flow around reinforced opening :
In steel pressure vessel and aircraft structures, openings have to be introduced. These result is
stress concentrations in a localized region. The stress analysis can be carried out by simply
discretizing the surface near the edge of the hole by very thin triangular element.
9
2. Dam Subjected To External Pressure
B. AXI-SYMMETRIC PROBLEMS :
1. Application Related To Shell :
A shell is a structure which can be derived from a thin plate by initially forming the middle
plane to a singly curved surface. In Finite Element Method, it is assumed that the behavior of
a continuously curved surface can be adequately represented by the behavior of a surface
built up of small, flat elements. In a shell, the element will be subject both to bending and
“in-plane” stresses.
One common example of shell is Cooling Tower. The tower is subjected to unsymmetrical
wind loading. The tower is divided into small triangular elements for carrying out stress
analysis.
2. Belleville Spring :
The Belleville Spring, also called Belleville Washer, is a conical disk spring. The load is
applied on the periphery of the circle and supported at the bottom. As load is applied in the
axial direction, the supporting edge moves out. Only the rectangular cross-section area needs
to be modeled. Load-deflection characteristics and stress distribution can be obtained by
dividing the area into elements and using a computer program. In the Belleville spring, the
load-deflection curve is non-linear. The stiffness depends on geometry. We can find a good
approximate solution by an incremental approach.
C. APPLICATIONS RELATED TO FLUID FLOW :
1. Aircraft Wing :
FEM can be used to find the lift and drag forces on an aircraft wing in the design stages itself.
Given a cross-section of an aerofoil and its relative speed with respect to air, we can find the
pressure distribution of air around the aerofoil. Basic idea here is to discretize the region
around the aerofoil, thus we can calculate the lift and drag forces on it. The method can also
be used to find the optimum cross-section of the aerofoil for a particular speed.
2. Aerodynamics Of A Vehicle :
FEM can be used to compare the Aerodynamics of various proposed vehicle shapes. It is used
to calculate the air resistance acting on a particular vehicle shape. Here we discretize region
surrounding the vehicle boundary. Thus we can use FEM to get a Sleek body for a vehicle.
D. APPLICATIONS RELATED TO HEAT TRANSFER :
FEM is a very powerful method for Heat Transfer analysis in the design stages.
1. Engine Piston :
To find out various parameters such as area required for heat transfer, cooling fluid flow,
material selection, etc. temperature distribution in a piston must be initially found out.Using
FEM the temperature distribution throughout the piston can be found out.
2. Fins :
Fin is an extended surface of a structure used to increase the rate of Heat Transfer. For
example, fins are used as extension of cylinder head for heat dissipation in engine. Geometry
and arrangement of fins is complex. FEM can be used to find Temperature Distribution and
Heat Transfer in the fins.
10
1.4.2 COMPARISON TO FEM
The finite difference method (FDM) is an alternative way of approximating solutions of
PDEs. The differences between FEM and FDM are:
The most attractive feature of the FEM is its ability to handle complicated geometries
with relative ease. While FDM in its basic form is restricted to handle rectangular shapes
and simple alterations thereof, the handling of geometries in FEM is theoretically
straightforward.
The most attractive feature of finite differences is that it can be very easy to implement.
There are several ways one could consider the FDM a special case of the FEM approach.
One might choose basis functions as either piecewise constant functions or Dirac delta
functions. In both approaches, the approximations are defined on the entire domain, but
need not be continuous. Alternatively, one might define the function on a discrete
domain, with the result that the continuous differential operator no longer makes sense,
however this approach is not FEM.
There are reasons to consider the mathematical foundation of the finite element
approximation more sound, for instance, because the quality of the approximation
between grid points is poor in FDM.
The quality of a FEM approximation is often higher than in the corresponding FDM
approach, but this is extremely problem dependent and several examples to the contrary
can be provided.
Generally, FEM is the method of choice in all types of analysis in structural mechanics
(i.e. solving for deformation and stresses in solid bodies or dynamics of structures) while
computational fluid dynamics (CFD) tends to use FDM or other methods like finite
volume method (FVM). CFD problems usually require discretization of the problem into
a large number of cells/gridpoints (millions and more), therefore cost of the solution
favors simpler, lower order approximation within each cell.
1.4.3
VARIOUS TYPES OF FEM
Generalized finite element method
XFEM
Spectral methods
Meshfree methods
Discontinuous Galerkin methods
1.4.4 SOFTWARE
Algor
General-purpose, low cost finite element package with composite elements. Tons of info
online, including case studies and tutorials. Use their search engine.
ANSYS
A general finite element package comparable in capabilities to NASTRAN. Most online info
is in PDF format.
Bmi3
Buckling analysis of composite shells, including postcritical path, using ABAQUS. Free
executable for DEC/Alpha and SGI UNIX. Site includes full text paper which documents the
program.
COSMOS/M
Mid-range, general-purpose package from SRAC. Lots of info on site, but it's very slow
loading (design problems). Primarily for PCs, but available on some workstations.
Dyna3d User Defined Materials (UDM)
11
Dr. Ever Barbero describes how to use and write a user defined material (UDM) for Dyna3d.
Includes a full example.
FEMAP
General pre-/post-processor for finite element analysis. Not a solver itself, but interfaces with
20 different programs. Has a good interface for defining laminates. SDRC also offers
structural and thermal solver modules based on the I-DEAS engine.
GENOA
Structural analysis, part manufacturability, virtual testing, micromechanics. Supports braids,
weaves, laminates, stitched laminates. Plus much more. From Alpha STAR.
I-DEAS
Full-featured CAD system from SDRC, including built-in FEA (or use as a pre-/postprocessor for other systems). Powerful laminates module with a sometimes awkward
interface.
INERTIA
Modular finite element package from Meridian Marketing. Parametric modeler; structural,
dynamic and thermal analyses; and more. Site is a bit heavy on marketing hype and a bit
weak on program technical details.
LAMPAT
Finite element pre- and post-processor for analyzing thick composite laminates. Integrates
with PATRAN. Originally developed by the U.S. Army Research Laboratory. This is the
only current reference to the program I can find.
LUSAS
A collection of finite element programs, including bridge, structural, civil, composite and
analyst (for general FEA). Detailed product descriptions and case studies.
MECANO
Software for nonlinear analysis, including structures, mechanisms, and cables. For UNIX and
NT.
MI/NASTRAN
PC NASTRAN compatible with FEMAP. ME/NASTRAN included for full feature support.
Fully functional downloadable demo available on site.
MSC/NASTRAN
Probably the best-known of the NASTRANs, running on everything from PCs to CRAYs.
There are several case studies on the site.
MSC/PATRAN
MSC's pre- and post-processor compatible with several codes, now available with weekly,
monthly and annual licenses. Specialized modules include a materials database and laminate
modeler.
NASTRAN and Honeycomb
Simple formulas for honeycomb sandwich plate properties. Follow the link at the bottom for
instructions on creating PSHELL cards for honeycomb panels.
NE/NASTRAN
A PC/Windows version of NASTRAN which includes the composite laminate elements.
Very nice price. Several case studies in PDF format.
NISA/DISPLAY
General-purpose NISA finite element package and pre-/post-processor. My personal favorite
for composites. Available on most platforms. Detailed info about the various modules,
including composites.
Pro/MECHANICA
The simulation portion of Pro/ENGINEER. Run your full analysis within Pro/E, or use it with
an external solver. Not much info online about specific capabilities.
Pro/MECHANICA and Laminated Shells
12
Shows how to calculate and enter the properties needed to run a composite analysis in
PRO/Mechanica. Basically, it's an overview of lamination theory with some P/M screen
shots.
SOLVIA
General purpose FE program with integrated pre- and post-processor. Laminate and concrete
elements. Targeted to civil engineering. PC and workstation versions.
Strand7
Full-featured finite element package for Windows systems. Extensive info about the program,
including composite pre- and post-processing capabilities. Lots of screen shots, examples,
and technical articles. Downloadable demo. From G+D Computing, Australia.
SYSPLY
FE program for design and optimization of composite structures. Extensive capabilities
include micromechanics, 3D stresses, winding options, and more.
13
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM OF LINE BY USING DDA ALGORITHM
1.1
INTRODUCTION
First lets recall some basics about the equation of a line. Given two points in a plane
(x0, y0) and (x1, y1) the slope-intercept form of a line can be defined as
y = m*x + b
Where m is the slope of the line
m =y1 − y0/x1 − x0
The y intercept b can be computed by isolating it, giving you
b = y0 − m*x0
One approach to rasterizing the line is through direct scan conversion, whereby each
x-value in the interval [x0, x1] is plugged into the slope-intercept equation to get the
corresponding y-value. Then we can plot the pixel (x,Round(y)) onto the display. Although
this works we are performing one floating point addition and multiplication to get each yvalue. In turns out that there is a more efficient way of accomplishing the same goal, which
brings us to DDA algorithm (Digital Difference Analyzer).
1.2
DDA
DDA works by using the pixel coordinates computed last and the slope. From the
previous section you can easily compute how far to move over (_x) or how far to move up
(_y) on the screen to draw your next point on the line.
dy=m*dx
dx=dy/m
Given that you already know you want to move over (_x) or up (_y) a certain number
of units (for computers these units equate to pixels on the screen) you then plug these values
into one of the two equations along with the slope and solve.
The DDA algorithm can be then broken down into the following cases:
1. A line with positive slope and 0 _ m _ 1 then you can take _x = 1
and compute successive y values using.
yk+1 = yk + m
Note: remember that because m is not necessarily an integer you must round your result.
14
2. A line with positive slope and m > 1 then you calculate x instead of y and take _y = 1 and
compute succesive x values using
xk+1 = xk +1/m
1.3
ALGORITHM :
Line with Positive slop processed from left to right:
Start
Input two endpoints
(x0,y0) & (xn,yn)
dy = 1
m <= 1
False
xk+1 = xk+ (1/m)
True
Repeat dx
times
dx = 1
yk+1 = yk + m
(xn,yn)
End
Consider first a line with positive slope.
a. if m <= 1,dx = 1
Compute each Successive values of y as,
yk+1 = yk + m
Here k is subscript that can take any integer value starting from 1.
b. if m > 1, dy = 1
Compute each successive values of x as,
xk+1 = xk+ (1/m).
15
Line with Positive slop processed from right to left :
Start
Input two endpoints
(x0,y0) & (xn,yn)
dy = -1
m <= 1
False
xk+1 = xk - (1/m)
True
Repeat dx
times
dx = -1
yk+1 = yk - m
(xn,yn)
End
a. If m < = 1 then dx = -1,
compute each Successive values of y as,
yk+1 = yk - m
b. If m > 1,dy = - 1
compute each successive values of x as,
xk+1 = xk - (1/m).
Note: It is also possible to calculate pixel positions along a line with negative slope.for that
we need to change Values of all parameters.
1.4
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
16
{
int a,b,c,d,s,gm=DETECT,gd,xi,yi,i,xn,yn,x,y;
clrscr();
printf("enter a,b,c,d\n");
scanf("%d\n%d\n%d\n%d",&a,&b,&c,&d);
x=c-a;
y=d-b;
if(x>=y)
s=x;
else
{
s=y;
}
xi=x/s;
yi=y/s;
x=a;
y=b;
initgraph(&gm,&gd,"");
line(0,getmaxy()/2,getmaxx(),getmaxy()/2);
line(getmaxx()/2,0,getmaxx()/2,getmaxy());
for(i=0;i<s;i++)
{
x=x-xi;
y=y-yi;
xn=(getmaxx()/2)+x;
yn=(getmaxy()/2)-y;
putpixel(xn,yn,YELLOW);
delay(50);
}
for(i=0;i<s;i++)
{
x=x+xi;
y=y+yi;
xn=(getmaxx()/2)+x;
yn=(getmaxy()/2)-y;
17
putpixel(xn,yn,RED);
delay(50);
}
for(i=0;i<s;i++)
{
x=x-xi;
y=y-yi;
xn=(getmaxx()/2)+x;
yn=(getmaxy()/2)-y;
putpixel(xn,yn,BLUE);
delay(50);
}
for(i=0;i<s;i++)
{
x=x+xi;
y=y+yi;
xn=(getmaxx()/2)+x;
yn=(getmaxy()/2)-y;
putpixel(xn,yn,GREEN);
delay(50);
}
getch();
closegraph();
}
18
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM OF LINE BY USING BRESENHAM ALGORITHM
1.1
BRESENHAM’S LINE ALGORITHM
It is an efficient method for scan converting a straight line which uses only integer
addition, subtraction and multiplication by 2.The computer can perform the operations of
integer addition and subtraction very rapidly. The computer is also very time efficient when
performing integer multiplication and division by powers of 2.the best approximation of the
true line is by those pixels in the raster that fall the least distance away from the true line.
Then call the distance to those pixels lying immediately above the line as Ti and the distance
to those directly below it as Si. This algorithm identifies the decision variable,
di=Si-Ti.
When di is less than 0, the closed pixel in the raster will be the pixel below the true line.
Conversely, when di is greater than or equal to 0, the pixel immediately above the true line is
closest. To implement the algorithm, all that remains is to calculate and update the various
values of di as follows:
Initially set first value of d as d1
d1=2dy-dx
x1= xs,y1 =ys
where dx=xe-xs,dy=ye-ys
The cycle for calculation is started with i=1 to n
Where, n=xe -xs
In cyclic operation,
if di>0,then x and y are incremented
xi+1=xi +1,yi+1=yi+1
The next d is calculated as,
di+1=di+2(dy-dx)
19
if di<0,then only x is incremented
xi+1=xi+1
The next d is calculated as,
di+1=di+2dy
In the cyclic operation, the values of x and y are calculated by the above procedure
are highlighted.This technique provides efficient method for line whose slope is less than 45
degrees. If the lines have a slope more than 45 degrees, then the reversing of axis is carried
out by making x axis as y axis and y axis as x axis.
1.2
ALGORITHM :
Step 1.
Input the two endpoint and store the left endpoint in (x0,y0)
Step 2.
Load (x0,y0) into the frame buffer, that is plot the first point.
Step 3.
Calculate constants dx,dy,2dy and 2dy – 2dx,and obtain the
Starting value for the decision parameter as,
P0 =2 dy – dx
Step 4.
At each xk along the line,starting at k = 0, performs the following
Test, if pk < 0 ,the next piont to plot is (xk + 1, yk) and
Pk+1 = pk + 2dy
Otherwise the next point to plot is (xk + 1,yk + 1) and
Pk+1 = pk + 2dy – 2dx
Step 5. Repeat step 4 dx times.
20
start
Input two endpoints (x0,y0) &
(xn,yn)
Calculate dx,
dy,2dy, 2(dy-dx)
and obtain P0
Pk < 0
False
(xk + 1,yk + 1)
Pk+1 = pk+ 2dy
– 2dx
True
(xk + 1, yk)
Repeat dx times
Pk+1 = pk+ 2dy
`
(xn,yn)
End
1.3
PROGRAM:
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
#include<dos.h>
void main()
{
int gd=DETECT,gm;
int x0,y0,x1,y1;
int dx,dy,p,i;
int x,y,xe;
printf("enter x0:");
scanf("%d",&x0);
21
printf("enter y0:");
scanf("%d",&y0);
printf("enter x1:");
scanf("%d",&x1);
printf("enter y1:");
scanf("%d",&y1);
initgraph(&gd,&gm,"");
line(getmaxx()/2,0,getmaxx()/2,getmaxy());
line(0,getmaxy()/2,getmaxx(),getmaxy()/2);
x0=getmaxx()/2+x0;
y0=getmaxy()/2-y0;
x1=getmaxx()/2+x1;
y1=getmaxy()/2-y1;
dx=x1-x0;
dy=y1-y0;
p=2*dy-dx;
if(x0>x1)
{
x=x1;
y=y1;
xe=x0;
}
else
{
x=x0;
y=y0;
xe=x1;
}
putpixel(x,y,WHITE);
while(x<xe)
{
x++;
if(p<0)
{
y++;
22
p+=2*(dy-dx);
}
else
{
p+=2*(dy-dx);
}
putpixel(x,y,WHITE);
}
getch();
closegraph();
}
23
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM OF CIRCLE
1.1
CIRCLE
It is a path traced by a point when it is rotated about another point at constant
distance. The circle is designated by centre co-ordinates and radius .The circles are used for
curved graphics. The scan conversion an algorithm is used for drawing of circles. A circle is a
symmetrical figure. Any circle generating algorithm can take the advantage of the symmetry
of circle to plot eight points for each value any algorithm calculates.
Any point on circle can be defined efficiently by Bresenham,s circle algorithm.
BRESENHAM’S CIRCLE ALGORITHM
1.2
The best approximation of the true circle will be described by those pixels in the raster
that fall the least distance away from the true circle. If points are to be generated, each new
point closest to the true circle can be found out by using two actions.
(1) Move in the x direction by one unit.
(2) Move in the x direction one unit and move in the negative i.e. y direction by one unit.
Consider a true point (i) on circle, which has fractional value and hence it has to select
either upper or lower point.
Therefore, a method of selecting between these two choices is all that is necessary to find
the points closest to the true circle.
If
Si=difference of true point with upper point
Ti=difference of true point with lower point
i= location of any point on the circle
Si=(xi-1+1)2+(y2i-1-r2)
24
Ti=(xi-1+1)2+(yi-1 -1)2-r2
The values of Si – positive
Ti-negative
Then the difference di is obtained by substituting values of Si and Ti.
di=Si+Ti
di=(xi-1+1)2+y2i-1 - r2 +(xi-1+1)2 + (yi-1-1)2-r2
To perform this cyclic operation substitute i=1 and d is calculated as d1 when the x0=0 and
y0=r
Where, x0 and y0 are initial values of x and y.
Therefore d1 = 3-2r
The cyclic operations are performed by varying i=1 to n
The cyclic operation is terminated at xn = r and yn=0
In the cyclic operation if di<0 then x is incremented
xi+1=xi+1,
di+1=di+4xi+6
and if di>=0,then x is incremented and y is decremented
xi+1=xi+1,
yi+1=yi-1
25
di+1=di+4(xi-yi)+10
This operation is performed till the values of x=r and y=0.
1.3
ALGORITHM:
Start
Input r , (xc
, yc )
First point =
(0,r)
P0 = (5 / 4) − r
pk <0
False
True
Repeat
dx times
Next point (xk+1, yk -1) &
pk+1 = pk+2xk+1 + 1− 2yk+1
Next point (xk+1, yk )
& pk+1 = pk+2xk+1 + 1
Find next
coordinate
Repeat until
x>=y
Determine
points in seven
remaining
octants
Plot: x = x + xc , y = y + yc
End
Step 1: Input radius r and circle center (xc , yc ), then set the coordinates for the first point
on the circumference of a circle centered on the origin as
(x0, y0) = (0, r )
Step 2:. Calculate the initial value of the decision parameter as
P0 = (5 / 4) − r
Step 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
26
Otherwise, the next 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.
Step 4: Determine symmetry points in the other seven octants.
Step 5: Move each calculated pixel position (x, y) onto the circular path centered at (xc , yc )
and plot the coordinate values:
x = x + xc , y = y + yc
Step 6: Repeat steps 3 through 5 until x ≥ y.
1.4
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,xc=0,yc=0,x,y,r,pk,ch;
printf("\n\nENTER RADIOUS:");
scanf("%d",&r);
printf("\n\nENTER CORDS:");
scanf("%d %d",&xc,&yc);
printf("\n\nENTER CHOICE");
scanf("%d",&ch);
x=0;
y=r;
initgraph(&gd,&gm,"");
line(0,getmaxy()/2,2*getmaxx()/2,getmaxy()/2);
line(getmaxx()/2,0,getmaxx()/2,getmaxy());
putpixel(xc,yc,RED);
pk=1-r;
while(x<y)
{
if(pk<0)
{pk=pk+2*x+1;
x++;}
27
else
{
pk=pk+2*x-2*y+1;
x++;
y--;
}
switch(ch)
{
case 1:
putpixel(getmaxx()/2+xc+x,getmaxy()/2-yc-y,RED);
putpixel(getmaxx()/2+xc+y,getmaxy()/2-yc-x,RED);
break;
case 2:
putpixel(getmaxx()/2+xc-x,getmaxy()/2-yc-y,RED);
putpixel(getmaxx()/2+xc-y,getmaxy()/2-yc-x,RED);
break;
case 3:
putpixel(getmaxx()/2+xc-x,getmaxy()/2-yc+y,RED);
putpixel(getmaxx()/2+xc-y,getmaxy()/2-yc+x,RED);
break;
case 4:
putpixel(getmaxx()/2+xc+x,getmaxy()/2-yc+y,RED);
putpixel(getmaxx()/2+xc+y,getmaxy()/2-yc+x,RED);
break;
}
}
getch();
closegraph();
}
28
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM OF ELLISPSE
1.1
BRESENHAM’S MIDPOINT ELLIPSE ALGORITHM:
The general polynomial equation for the ellipse can be given as:
Where a=major axis length
b=minor axis length
the above given equation can be further evaluated and we will have
implicit equation as:
F(x,y)=b2x2+a2y2-a2b2=0
We have only 4-way symmetry.
There exist two regions:
In region 1 dx>dy, then
29
Increase x at each step.
y may decrease.
In region 2 dx<dy,then
Decrease y at each step
x may increase
At region boundary we have
2xb2+2ya2 (dy÷dx)=0
Therefore dy÷dx= −(b2x÷a2y)
In region 1, |dy÷dx|<1
Therefore we will have
b2x<a2y
Similarly in region 2 |dy÷dx|>1
Therefore we will have
b2x>a2y.
1.2
ALGORITHM:
Step1. Input rx, ry, and ellipse center (xc , yc ), and obtain the first point on an
ellipse centered on the origin as
(x0, y0) = (0, ry)
Step 2. Calculate the initial value of the decision parameter in region 1 as
p10 = r 2y − r 2xry + (1 / 4)r 2x
Step 3.
At each xk position in region 1, starting at k = 0, perform the following
test. If p1k <0, the next point along the ellipse centered on (0, 0)
is (xk+1, yk ) and
p1k+1 = p1k + 2r 2yxk+1 + r 2y
Otherwise, the next point along the ellipse is (xk + 1, yk − 1) and
p1k+1 = p1k + 2r 2yxk+1 − 2r 2x yk+1 + r 2y with
2r 2yxk+1 = 2r 2yxk + 2r 2y, 2r 2x yk+1 = 2r 2x yk − 2r 2x and
continue until 2r 2yx ≥ 2r 2x y.
30
Start
Input rx, ry ,(xc , yc)
First coordinate=(0,ry)
p10 = r
2
y
In region 1
−r
2
x ry
+ (1 / 4)r
2
x
(xk + 1, yk − 1) &
p1k <0
p1k+1 = p1k + 2r
2
yxk+1
− 2r
2
x
yk+1 + r
2
y
(xk+1, yk ) &
p1k+1 = p1k + 2r
until 2r
2
yx
≥ 2r
2
x
2
yxk+1
+r
2
y
y
Calculate
2r 2yxk+1 = 2r 2yxk + 2r 2y,
2r 2x yk+1 = 2r 2x yk − 2r 2x
(xn,yn)
p20 = r
2
y
in region 2
(x0 +1/2)2+ r 2x (y0 − 1)2 − r
2
2
xr y
(xk + 1, yk − 1)
p2k
>0
p2k+1 = p2k + 2r
2
yxk+1
− 2r
2
x
yk+1 + r
2
x
(xk , yk − 1)
until 2r2yx >= 2r2xy
p2k+1 = p2k − 2r
2
x
yk+1 + r
2
x
(xn,yn)
end
31
Step 4: Calculate the initial value of the decision parameter in region 2 as
p20 = r 2y (x0 +1/2)2+ r 2x (y0 − 1)2 − r 2xr 2y
where (x0, y0) is the last position calculated in region 1.
Step 5: At each yk position in region 2, starting at k = 0, perform the following test. If p2k >0,
the next point along the ellipse centered on (0, 0) is (xk , yk − 1) and
p2k+1 = p2k − 2r 2x yk+1 + r 2x
Otherwise, the next point along the ellipse is (xk + 1, yk − 1) and
p2k+1 = p2k + 2r 2yxk+1 − 2r 2x yk+1 + r 2x
using the same incremental calculations for x and y as in region 1.
Continue until y = 0.
Step 6: For both regions, determine symmetry points in the other three quadrants.
Step 7: Move each calculated pixel position (x, y) onto the elliptical path centered
on (xc , yc ) and plot the coordinate values:
x = x + xc , y = y + yc
Step 8: Repeat the steps for region 1 until 2r2yx >= 2r2xy
1.3
PROGRAM
#include<stdio.h>
#include<conio.h>
#include<graphics.h>
void main()
{
int gd=DETECT,gm,t,t1,pk,xc=0,yc=0,r,x,y;
printf("Enter Radius :-");
scanf("%d",&r);
pk=1-r;
x=0;
y=r;
initgraph(&gd,&gm,"");
t=getmaxx()/2;
t1=getmaxy()/2;
line(0,t1,2*t,t1);
line(t,0,t,2*t1);
32
while(x<y)
{
if(pk<=0)
{ x++;
pk=pk+2*x+1;
y=y;
}
else
{
pk=pk+2*x-2*y+1;
x++;
y--;
}
putpixel(getmaxx()/2+x,getmaxy()/2-y,RED);//first
putpixel(getmaxx()/2+y,getmaxy()/2-x,RED); //first
putpixel(getmaxx()/2-y,getmaxy()/2-x,RED); //second
putpixel(getmaxx()/2-x,getmaxy()/2-y,RED); //second
putpixel(getmaxx()/2-x,getmaxy()/2+y,RED); //third
putpixel(getmaxx()/2-y,getmaxy()/2+x,RED); //third
putpixel(getmaxx()/2+y,getmaxy()/2+x,RED); //forth
putpixel(getmaxx()/2+x,getmaxy()/2+y,RED); //forth
}
getch();
closegraph();
}
33
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM FOR 2D TRANSFORMATION (TRANSLATION).
1.1
TRANSLATIONS
Translations change the position of an object. A pure (three dimensional) translation can not
be implemented using a 3x matrix: It is an AFFINE MAP. We must alter our notion of a point
to accommodate translations. A three dimensional point P=[x y z] will be embedded
in THREE DIMENSIONAL HOMOGENEOUS SPACE and represented as a 4tuple
. For now, the homogeneous coordinate w will have the fixed value 1. This
allows us to implement translations using 4x4 matrices, in particular, the matrix
translated the point
1.2
into the point
+
.
The Inverse of a Translation
To undo a translation by
use the matrix
We can now complete scaling about an arbitrary fixed point and rotation about an arbitrary
pivot. To scale about
use the composition of matrices
which when multiplied out yields
So a scaled point [x y z 1] becomes
34
=
=
In a similar manner you can determine that rotation about a pivot R= [
] results in
As an example, consider a triangle defined by three vertices (20,0), (60, 0), and (40, 100)
being translated 100 units to the right along the x-axis ( tx = 100) and 10 units up along the yaxis (ty = 10). The new vertices are (120, 10), (160, 10), and (140, 110), see figure below:
1.3
PROGRAM:
#include<conio.h>
#include<stdio.h>
#include<iostream.h>
#include<graphics.h>
#include<math.h>
void main()
{
clrscr();
int y,dx,dy,steps,i,j,z;
float m;
int gd=DETECT,gm;
35
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\DDA.CPP");
for(i=0;i<getmaxx();i++)
{
putpixel(i,getmaxy()/2,RED);
for(j=0;j<getmaxy();j++)
{
putpixel(getmaxx()/2,j,RED);
}
}
int x1,x2,y1,y2,x3,y3,x4,y4,t,k[3][3],tx,ty;
setcolor(3);
line(getmaxx()/2+x1,getmaxy()/2-y1,getmaxx()/2+x2,getmaxy()/2-y2);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(i==j)
{
k[i][j]=1;
}
else
{
k[i][j]=0;
}
}
}
cout<<"enter initial points";
cin>>x1>>y1;
cout<<"enter final points";
cin>>x2>>y2;
cout<<"translation value of x";
cin>>tx;
cout<<"translation value of y";
cin>>ty;
36
k[0][2]=tx;
k[1][2]=ty;
x3=(x1*k[0][0])+(x1*k[0][1])+k[0][2];
y3=(y1*k[1][0])+(y1*k[1][1])+k[1][2];
x4=(x2*k[0][0])+(x2*k[0][2])+k[0][2];
y4=(y2*k[1][0])+(y2*k[1][1])+k[1][2];
setcolor(5);
line(getmaxx()/2+x3,getmaxy()/2-y3,getmaxx()/2+x4,getmaxy()/2-y4);
getch();
closegraph();
}
37
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM FOR 2D TRANSFORMATION (ROTATION).
1.1
ROTATION
Rotations alter the orientation of an object: They are a little more complex than scales.
Starting in two dimensional rotations is easiest.
1.1.1 Rotations in Two Dimensions
A rotation moves a point along a cirular path centered at the origin (the pivot). It is a simple
trigonometry problem to show that rotating P=[x y] counter-clockwise by radians produces
a new point = [
] given by
For example, pretend P=[1 1] and
. Then
, which you should agree
correctly matches the description.
Of course, we can express the rotation in matrix form
1.1.2 The Pivot of a Rotation
By default the pivot point is the origin
, but we can arrange for an arbitrary
pivot P=[
]by using a three step process similar to the one for scaling about an arbitrary
fixed point described about.
1. Translate P=[
2. Rotate by
3. Translate
] to
to P=[
]
1.1.3 Rotations in Three Dimensions
In three dimensions points are rotated about an axis, which is a line in three dimensional
space. There are three principle axes: the x, y, and z axes. We assume a right-handed
coordinate system, with the convention that positive rotation is counter-clockwise.
Rotating P=[x y z] about the z-axis by
radians produces a new point
=[
] where
38
or in matrix notation
The notations Rz and Rxy are meant to be mneumonics for ``rotate about z'' and ``rotate
from x toward y.''
Rotating P=[x y z] about the x-axis by radians produces a new point =[
] where
or in matrix notation
Rotating P=[x y z] about the y-axis by
radians produces a new point
=[
] where
or in matrix notation
Angles of rotation about the principle axes are called Euler angles.
1.1.4 Rotation About an Arbitrary Axis
Consider an axis through the origin determined by a unit length direction vector
, (the completely arbitrary case will be easily handled after translations are
introduced). We can arrange to rotate by theta radians about this axis using a five step
process
1. Rotate
into the xz plane, call the result
2. Rotate
into the z axis
3. Rotate about the z axis by radians
39
4. Invert the rotation of
into the z axis
5. Invert the rotation of into
This is messy and error-prone when using hand calculation, however, if you carry it out, the
result is
(1
)
You should verify that this matrix reduces to rotations about z, x, and y for appropriate
choices of the direction vector
Below, we'll see that there are better ways to derive this
matrix.
1.2
The Inverse of a Rotation
The inverse of a rotation by radians can be created by rotating by
not the best way to view it. Consider the trigonometic identities
radians, but this is
If you plug these into the arbitrary rotation from equation (1), you'll see that the inverse
of R is the transpose of R. This is an important observation.
For example a triangle (20,0), (60,0), (40,100) rotated 45° clockwise about the origin is
(14.14, -14.14), (42.43, -42.43), (98.99, -42.43)
1.3
PROGRAM:
#include<graphics.h>
#include<math.h>
#include<iostream.h>
40
#include<conio.h>
void main()
{
clrscr();
int gd=DETECT,gm,i,k,x1,x2,y1,y2,o;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
for(i=0;i<=getmaxx();i++)
{
putpixel(i,getmaxy()/2,YELLOW);
}
for(k=0;k<=getmaxy();k++)
{
putpixel(getmaxx()/2,k,YELLOW);
}
setcolor(5);
cout<<"enter the value of co-ordinate";
cin>>x1>>y1>>x2>>y2;
line(x1+getmaxx()/2,-y1+getmaxy()/2,x2+getmaxx()/2,-y2+getmaxy()/2);
setcolor(3);
cout<<"rotation value";
cin>>o;
int x3=x1;
int y3=y1;
int x4=x2*cos(o)-y2*sin(o);
int y4=y2*sin(o)+x2*cos` (o);
line(x3+getmaxx()/2,-y3+getmaxy()/2,x4+getmaxx()/2,-y4+getmaxy()/2);
getch();
}
41
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM FOR 2D TRANSFORMATION (SCALING).
1.1
SCALING
Scaling alters the size of an object. Pretend you are given a point P=(x y z) which is an object
vertex, and let (
) be scale factors in x y z, respectively. Then the point can be scaled to
a new point by the matrix
In particular,
To scale (enlarge or shrink) the size of an object, each object vertex is multiplied by the scale
matrix Sas shown above.
1.1.1 The Fixed Point of a Scale
Note that the origin O=[0 0 0] is unchanged by a scale (it is still the origin). There is always
one fixed point for any scaling operation. By default the fixed point is the origin O=(0 0 0),
but we can select an arbitrary fixed point F=[
] by the following three step
process, which will be more completely defined below.
1. Translate F=[
] to O=[0 0 0]
2. Scale by
]
3. Translate O[0 0 0] to F=[
]
1.1.2 The Inverse of a Scale
As long as we do not scale by zero, a scale can always be inverted (undone) by the matrix
The product SS-1= S-1S=I, the 3x3 identity matrix.
42
1.2
PROGRAM:
#include<graphics.h>
#include<math.h>
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int gd=DETECT,gm,i,k,x1,x2,y1,y2,o;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\bgi");
for(i=0;i<=getmaxx();i++)
{
putpixel(i,getmaxy()/2,YELLOW);
}
for(k=0;k<=getmaxy();k++)
{
putpixel(getmaxx()/2,k,YELLOW);
}
setcolor(5);
cout<<"enter the value of co-ordinate";
cin>>x1>>y1>>x2>>y2;
line(x1+getmaxx()/2,-y1+getmaxy()/2,x2+getmaxx()/2,-y2+getmaxy()/2);
setcolor(3);
cout<<"scaling value of x & y ";
cin>>x>>y;
int x3=x2+x;
int y3=y2+y;
line(x1+getmaxx()/2,-y1+getmaxy()/2,x3+getmaxx()/2,-y3+getmaxy()/2);
getch();
}
43
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
DATE:
AIM: WRITE A PROGRAM FOR 2D TRANSFORMATION (REFLECTION).
1.1
REFLECTION
1.1.1 Reflection through the x-axis (Flip)
The object and image are equidistant from a line of
reflection.
Segments joining corresponding sides of an object
and image are perpendicular to the reflection line.
The object and image are congruent (corresponding
angles and sides are congruent).
1.1.2 Reflection through the y-axis (Flip)
The object and image are equidistant from a line of
reflection.
Segments joining corresponding sides of an object
and image are perpendicular to the reflection line.
The object and image are congruent (corresponding
angles and sides are congruent).
1.1.3 Reflection through y = x (Flip)
The object and image are equidistant from a line of
reflection.
Segments joining corresponding sides of an object
and image are perpendicular to the reflection line.
The object and image are congruent (corresponding
angles and sides are congruent).
1.1.4 Reflection through y = - x (Flip)
The object and image are equidistant from a line of
reflection.
Segments joining corresponding sides of an object and
image are perpendicular to the reflection line.
The object and image are congruent (corresponding
angles and sides are congruent).
44
1.2
SHEARING
A shear is a transformation that distorts the shape of an object along either or both of
the axies. Like scale and translate, a shear can be done along just one or along both of the
coordinate axes. A shear along one axis (say, the x-axis) is performed in terms of the point's
coordinate in the other axis (the y-axis).
Thus a shear of 1 in the x-axis will cause the x-coodinate of the point ot distort by
1*(y-coordinate).
To shear in the x direction the equation is:
x1 = x + ay
y1 = y
Where b = 0
Where x1 and y1 are the new values, x and y are the original values, and a is the scaling
factor in the x direction. The matrix is as follows.
Shearing in the y direction is similar except the roles are reversed.
x1 = x
y1 = y + bx
Where a = 0.
Where x1 and y1 are the new values, x and y are the original values, and b is the scaling
factor in the y direction. The matrix is as follows.
45
1.3
PROGRAM:
#include<conio.h>
#include<stdio.h>
#include<iostream.h>
#include<graphics.h>
#include<math.h>
void main()
{
clrscr();
int y,dx,dy,steps,i,j,z;
float m;
int gd=DETECT,gm;
detectgraph(&gd,&gm);
initgraph(&gd,&gm,"c:\\tc\\DDA.CPP");
for(i=0;i<getmaxx();i++)
{
putpixel(i,getmaxy()/2,RED);
for(j=0;j<getmaxy();j++)
{
putpixel(getmaxx()/2,j,RED);
}
}
int x1,x2,y1,y2,x3,y3,x4,y4,k[3][3],r;
setcolor(3);
line(getmaxx()/2+x1,getmaxy()/2-y1,getmaxx()/2+x2,getmaxy()/2-y2);
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
if(i==j)
{
k[i][j]=1;
}
else
46
{
k[i][j]=0;
}
}
}
cout<<"enter initial points";
cin>>x1>>y1;
cout<<"enter final points";
cin>>x2>>y2;
cout<<"1. reflection about x-axis \n";
cout<<"2. reflection about y-axis \n";
cout<<"3. reflection about 45 deg \n";
cout<<"4. reflection about -45 deg \n";
cin>>r;
if(r==1)
{
k[1][1]=-1;
}
else if(r==2)
{
k[0][0]=-1;
}
else if(r==3)
{
k[0][0]=0;
k[1][1]=0;
k[0][1]=1;
k[1][0]=1;
}
else if(r==4)
{
k[0][0]=0;
k[1][1]=0;
k[0][1]=-1;
k[1][0]=-1;
47
}
x3=(x1*k[0][0])+(y1*k[1][0]);
y3=(x1*k[1][0])+(y1*k[1][1]);
x4=(x2*k[0][0])+(y2*k[0][1]);
y4=(x2*k[1][0])+(y2*k[1][1]);
setcolor(5);
line(getmaxx()/2+x3,getmaxy()/2-y3,getmaxx()/2+x4,getmaxy()/2-y4);
getch();
closegraph();
}
48
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
1.1
DATE:
PROBLEM STATEMENT
A distributed load of 1000 N/m (1 N/mm) will be applied to a solid steel beam with a rectangular cross
section as shown in the figure below. The cress-section of the beam is 10mm x 10mm while the modulus of
elasticity of the steel is 200GPa.
1.2
DEFINING THE PROBLEM .
1. Open preprocessor menu/PRE7
Give example a title
Utility Menu > File > > change Title..
2. Create keypoints
Preprocessor > Modeling > create > Keypoints > In Active CS K,#,x,y
We are going to define 2 keypoints (the beam vertices) for this structure as given in the
following table:
Key point
1
Coordinates(x,y)
(0,0)
49
3. Define lines
Preprocessor > Modeling > create > lines > Lines > Straight Lines
4. Define Elemnet Types
Preprocessor > Element Type > Add/Edit/Delete...
For this problem we will use the BEAM3 element. This element has 3 degrees of freedom (translation
along the X and Y axis's, and rotation about the Z axis). With only 3 degrees of freedom, the BEAM3
element can only be used in 2D analysis.
5. Define Real Constants…>Add
Preprocessor > Real Constants…> Add…
In the ‘Real Constants for BEAM3’ window, enter the following geometric
properties:
i.
Cross sectional area AREA : 100
ii.
Area Moment of Inertia IZZ: 833.333
iii. Total beam height HEIGHT : 10.
This defines an element with a solid rectangular cross section 10mm x 10mm.
1. Define Element Material Properties.
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic >
Isotropic
In the window that appear,
enter the following geometric properties for steel:
i.
Young’s Modulus EX:200000
ii.
Poisson’s Ratio : 0.3.
2. Define Mesh Size.
Preprocessor > Meshing > Size Cntrls > Manual Size > Lines > All lines.
For this example we will use an element length of 100mm.
3. Mesh the frame
Preprocessor > Meshing > Mesh > Lines > All Lines…
For This example we will use an element length of 100mm.
4. Plot Elements.
Utility Menu > Plot > Elements
1.3
ASSIGNING LOADS AND SOLVING.
1. Define Analysis Type
Solution > Analysis Type > New Analysis > Static
2. Apply Constraints
Solution > Define loads > Apply > Structural > Displacement > on Keypoints.
Pin Key points 1 (i.e UX and UY constrained) and fix keypoint 2 in the y
direction (UY contrained).
3. Apply Loads.
50
We will apply a distributed load, of 1000N/m or 1N/mm, over the entire length of the beam.
Solution > Define Loads > Apply > Structural > pressure > on Beams.
4. Solve the system.
Solution > Solve > Current LS Solve
1.4
VIEWING THE RESULTS
1. Plot Deformed shape
General Postproc > Plot Results > Deformed Shape
The applied loads and constraints should now appear as shown in the figure.
51
Solution under the given conditions is shown in figure.
2. Plot Principle stress distribution.
ELEM
1
2
3
4
5
6
7
8
9
10
MINIMUM VALUES
ELEM
4
VALUE
105.00
SMAXI
750.00
405.00
120.00
105.00
270.00
375.00
420.00
405.00
330.00
195.00
MAXIMUM VALUES
1
ELEM
52
750.00
VALUE
3. The below table shows the displacement values at each nodes.
DISPLACEMENT
NODE
UX
UY
UZ
USUM
1
0.0000
0.0000
0.0000
0.0000
2
0.0000
0.0000
0.0000
0.0000
3
0.0000
-3.1500
0.0000
3.1500
4
0.0000
-10.400
0.0000
10.400
5
0.0000
-18.900
0.0000
18.900
6
0.0000
-26.400
0.0000
26.400
7
0.0000
-31.250
0.0000
31.250
8
0.0000
-32.400
0.0000
32.400
9
0.0000
-29.400
0.0000
29.400
10
0.0000
-22.400
0.0000
22.400
11
0.0000
-12.150
0.0000
12.150
MAXIMUM ABSOLUTE VALUES
NODE
VALUE
0
0.0000
8
-32.400
0
0.0000
8
32.400
53
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
1.1
DATE:
PROBLEM STATEMENT
An load of 1000 N/m (1 N/mm) will be applied to a solid steel beam with a rectangular cross section
supported by cantilever beam. The cress-section of the beam is 10mm x 10mm while the modulus of
elasticity of the steel is 200GPa.
1.2
DEFINING THE PROBLEM .
1. Open preprocessor menu/PRE7
Give example a title
Utility Menu > File > > change Title..
2. Create keypoints
Preprocessor > Modeling > create > Keypoints > In Active CS K,#,x,y
We are going to define 2 keypoints (the beam vertices) for this structure as given in the
following table:
Key point
Coordinates(x,y)
1
(0,0)
3. Define lines
Preprocessor > Modeling > create > lines > Lines > Straight Lines
4. Define Elemnet Types
Preprocessor > Element Type > Add/Edit/Delete...
For this problem we will use the BEAM3 element. This element has 3 degrees of freedom (translation
along the X and Y axis's, and rotation about the Z axis). With only 3 degrees of freedom, the BEAM3
element can only be used in 2D analysis.
5. Define Real Constants…>Add
Preprocessor > Real Constants…> Add…
In the ‘Real Constants for BEAM3’ window, enter the following geometric
properties:
iv.
Cross sectional area AREA : 100
v.
Area Moment of Inertia IZZ: 833.333
vi.
Total beam height HEIGHT : 10.
54
This defines an element with a solid rectangular cross section 10mm x 10mm.
6. Define Element Material Properties.
Preprocessor > Material Props > Material Models > Structural > Linear > Elastic >
Isotropic
In the window that appear,
enter the following geometric properties for steel:
iii. Young’s Modulus EX:200000
iv.
Poisson’s Ratio : 0.3.
7. Define Mesh Size.
Preprocessor > Meshing > Size Cntrls > Manual Size > Lines > All lines.
For this example we will use an element length of 100mm.
8. Mesh the frame
Preprocessor > Meshing > Mesh > Lines > All Lines…
For This example we will use an element length of 100mm.
9. Plot Elements.
Utility Menu > Plot > Elements
1.3
ASSIGNING LOADS AND SOLVING.
1. Define Analysis Type
Solution > Analysis Type > New Analysis > Static
2. Apply Constraints
Solution > Define loads > Apply > Structural > Displacement > on Keypoints.
Pin Key points 1 (i.e UX and UY constrained) and fix keypoint 2 in the y
direction (UY contrained).
3. Apply Loads.
We will apply a distributed load, of 1000N/m or 1N/mm, over the entire length of the beam.
Solution > Define Loads > Apply > Structural > pressure > on Beams.
4. Solve the system.
Solution > Solve > Current LS Solve
1.4
VIEWING THE RESULTS
1. Plot Deformed shape
General Postproc > Plot Results > Deformed Shape
The applied loads and constraints should now appear as shown in the figure.
55
Solution under the given conditions is shown in figure.
Solution is shown in figure below
56
4. Plot Principle stress distribution.
ELEM
1
2
3
4
5
6
7
8
9
10
MINIMUM VALUES
ELEM
4
VALUE
105.00
SMAXI
750.00
405.00
120.00
105.00
270.00
375.00
420.00
405.00
330.00
195.00
MAXIMUM VALUES
1
ELEM
57
750.00
VALUE
5. The below table shows the displacement values at each nodes.
DISPLACEMENT
NODE
UX
UY
UZ
USUM
1
0.0000
0.0000
0.0000
0.0000
2
0.0000
0.0000
0.0000
0.0000
3
0.0000
-3.1500
0.0000
3.1500
4
0.0000
-10.400
0.0000
10.400
5
0.0000
-18.900
0.0000
18.900
6
0.0000
-26.400
0.0000
26.400
7
0.0000
-31.250
0.0000
31.250
8
0.0000
-32.400
0.0000
32.400
9
0.0000
-29.400
0.0000
29.400
10
0.0000
-22.400
0.0000
22.400
11
0.0000
-12.150
0.0000
12.150
MAXIMUM ABSOLUTE VALUES
NODE
VALUE
0
0.0000
8
-32.400
0
0.0000
8
32.400
58
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
1.1
DATE:
PROBLEM STATEMENT
Find the maximum axial stress in the plate with a central hole and compare your result with a computation
using published stress concentration factor data.
1.2
PREPROCESSING
1. Start ANSYS, select the Working Directory where you will store the files associated with this
problem.
2. Main menu > Preprocessor > Element Type > Add/Edit/delete > Add > Structural Solid > Quad
4node 42 > OK.
Options (Element behavior K3) > Plane strs w/thk > OK > Close.
3. Main Menu > Preprocessor > Real Constants > Add/Edit/Delete > Add > OK.
4. Main Menu > Preprocessor > Material Props > Material Models (Material Model Number ,
Double click Structural > Linear > Elastic > Isotropic
Enter EX = 2.07E11 and PRXY = 0.29 > OK (Close the Define Material Model Behavior
window.)Create the geometry for the upper right quadrant of the plate by subtracting a 0.2 m
diameter circle from a 0.5 x 0.2 m rectangle. Generate the rectangle first.
5. Main Menu > Preprocessor > Modeling > Create > Areas > Rectangle > By 2 Corners
Enter (lower left corner) VVP X = 0.0, WP Y = 0.0 and Width = 0.5, Height = 0.2 > OK
6. Main Menu > Preprocessor > Modeling > Create > Areas > Circle > Solid Circle Enter \VP
X = 0.0, WP Y = 0.0 and Radius = 0.1 > OK
7. Main Menu > Preprocessor > Modeling > Operate > Booleans > Subtract > Areas > Pick the rectangle >
OK, then pick the circle > OK
Create a mesh of Quadrilateral elements over the quadrant area.
1. Main Menu > Preprocessor > Meshing > Mesh > Areas > Free Pick the quadrant > OK
59
2. Main Menu > Preprocessor > Loads > Define Loads > Apply > Structural > Displacement > On Lines
Pick the Iclt edge of the quadrant > OK > UX = 0. > OK
3. Main Menu > Preprocessor > Loads > Define Loads > Apply > Structural > Displacement > On
Lines Pick the bottom edge of the quadrant > OK > UY = 0. > OK
4. Main Menu > Preprocessor > Loads > Define Loads > Apply > Structural > Pressure > On Lines.
Pick the right edge of the quadrant > OK > Pressure = -1.0 > OK
5. Utility Menu > File > Save as Jobnamc.db (Or Save as ....; use a new name)
1.3
SOLUTION
Main Menu > Solution > Solve > Current LS > OK
The STATUS Command window displays the problem parameters and the Solve Current Load
Step window is shown. Check the solution options in the /STATUS window and if all is OK, select File >
Close.In the Solve Current Load Step window, Select OK, and when the solution is complete, close the
'Solution is Done!' window.
1.4
POSTPROCESSING
We can now plot the results of this analysis and also list the computed values. First examine the
deformed shape.
1. Main Menu > General Postproc > Plot Results > Deformed Shape > Def + Undef. > OK.
The deformed shape looks correct. (The undeformed shape is indicated by the dashed lines.)
The right end moves to the right in response to the tensile load in the x-direction, the circular hole ovals
out, and the top moves down because of Poisson's effect. Note that the element edges on the circular arc
60
are represented by straight lines. This is an artifact of the plotting routine not the analysis. The six-node
triangle has curved sides, and if you pick on a mid-side of one these elements, you will see that a node is
placed on the curved edge.
Meshing is shown in the above figure
2. Main Menu > General Postproc > Plot Results > Contour Plot > Element Solu > Stress > XComponent of stress > OK
3. Use PlotCtrls > Symbols [PSF] Surface Load Symbols (set to Pressures) and Show pre and
convect as (set to Arrows) to display the pressure loads.
61
4.
5.
6.
7.
Main Menu > Preprocessor > Meshing > Modify Mesh > Refine At > Nodes.
(Select the three nodes shown.) > OK (Select the Level of refinement = 1) > OK
Main Menu > Solution > Solve > Current LS > OK
Main Menu > General Postproe > Plot Results > Contour Plot > Element Solu > Stress > XComponent of stress > OK
MAXIMUM ABSOLUTE VALUES FOR DEFORMATION :-
NODE
VALUE
1
0.25715 E-12
22
-0.4545 E -13
0
0.0000
18
0.25810 E -12
MINIMUM VALUE OF STRESSES
ELEMENT
VALUE
213
0.16800E-14
51
0.0000
1
0.0000
52
0.0000
MAXIMUM VALUE OF STRESSES
ELEMENT
VALUE
5
0.23361E-12
20
0.28540
1
0.0000
20
0.32288
62
GANPAT UNIVERSITY
DEPARTMENT OF MECHANICAL AND MECHATRONICS ENGINEERING
U V PATEL COLLEGE OF ENGINEERING
COMPUTER AIDED DESIGN
PRACTICAL NO:
1.1
DATE:
PROBLEM STATEMENT
Determine the nodal deflections, reaction forces, and stress for the truss system shown
below (E = 200GPa, A = 3250mm2).
1.2
PREPROCESSING: DEFINING THE PROBLEM
1. Give the Simplified Version a Title (such as 'Bridge Truss Tutorial').
In the Utility menu bar select File > Change Title:
Enter the title and click 'OK'. This title will appear in the bottom left corner of the
'Graphics' Window once you begin. Note: to get the title to appear immediately, select
Utility Menu > Plot > Replot
2. Enter Keypoints
The overall geometry is defined in ANSYS using keypoints which specify various
principal coordinates to define the body. For this example, these keypoints are the
ends of each truss.
o We are going to define 7 keypoints for the simplified structure as given in the
following table
coordinate
KEY POINT
x
y
1
0
0
2
1800
3118
63
o
o
o
o
3
3600
0
4
5400
3118
5
7200
0
6
9000
3118
7
10800
0
(these keypoints are depicted by numbers in the above figure)
From the 'ANSYS Main Menu' select:
Preprocessor > Modeling > Create > Keypoints > In Active CS
Enter keypoint number 1 in the appropriate box, and enter the x,y coordinates: 0, 0
in their appropriate boxes (as shown above).
Click 'Apply' to accept what you have typed.
Enter the remaining keypoints using the same method.
Units
Note the units of measure (ie mm) were not specified. It is the responsibility of the user to
ensure that a consistent set of units are used for the problem; thus making any conversions
where necessary.
Correcting Mistakes
When defining keypoints, lines, areas, volumes, elements, constraints and loads you are
bound to make mistakes. Fortunately these are easily corrected so that you don't need to
begin from scratch every time an error is made! Every 'Create' menu for generating these
various entities also has a corresponding 'Delete' menu for fixing things up.
3. Form Lines
The keypoints must now be connected
We will use the mouse to select the keypoints to form the lines.
o
o
o
o
o
In the main menu select: Preprocessor > Modeling > Create > Lines > Lines > In Active
Coord. The following window will then appear:
Use the mouse to pick keypoint #1 (i.e. click on it). It will now be marked by a small
yellow box.
Now move the mouse toward keypoint #2. A line will now show on the screen joining
these two points. Left click and a permanent line will appear.
Connect the remaining keypoints using the same method.
When you're done, click on 'OK' in the 'Lines in Active Coord' window, minimize the
'Lines' menu and the 'Create' menu. Your ANSYS Graphics window should look similar to
the following figure.
4. Disappearing Lines
Please note that any lines you have created may 'disappear' throughout your analysis.
However, they have most likely NOT been deleted. If this occurs at any time from the
Utility Menu select:
5. Plot > Lines
64
6. Define the Type of Element
It is now necessary to create elements. This is called 'meshing'. ANSYS first needs to
know what kind of elements to use for our problem:
o
From the Preprocessor Menu, select: Element Type > Add/Edit/Delete. The following
window will then appear:
o For this example, we will use the 2D spar element as selected in the above figure. Select
the element shown and click 'OK'. You should see 'Type 1 LINK1' in the 'Element Types'
window.
o Click on 'Close' in the 'Element Types' dialog box.
7. Define Geometric Properties
We now need to specify geometric properties for our elements:
o
o
o
o
o
In the Preprocessor menu, select Real Constants > Add/Edit/Delete
Click Add... and select 'Type 1 LINK1' (actually it is already selected). Click on 'OK'.
Enter the cross-sectional area (3250mm):
Click on 'OK'.
'Set 1' now appears in the dialog box. Click on 'Close' in the 'Real Constants' window.
8. Element Material Properties
You then need to specify material properties:
o
o
o
o
In the 'Preprocessor' menu select Material Props > Material Models
Double click on Structural > Linear > Elastic > Isotropic
We are going to give the properties of Steel.
Set these properties and click on 'OK'. Note: You may obtain the note 'PRXY will be set to
0.0'. This is poisson's ratio and is not required for this element type. Click 'OK' on the
window to continue. Close the "Define Material Model Behavior" by clicking on the 'X'
box in the upper right hand corner.
9. Mesh Size
The last step before meshing is to tell ANSYS what size the elements should be.
There are a variety of ways to do this but we will just deal with one method for now.
o
In the Preprocessor menu select Meshing > Size Cntrls > ManualSize > Lines > All Lines
65
o
In the size 'NDIV' field, enter the desired number of divisions per line. For this example
we want only 1 division per line, therefore, enter '1' and then click 'OK'. Note that we
have not yet meshed the geometry, we have simply defined the element sizes.
10. Mesh
Now the frame can be meshed.
o
In the 'Preprocessor' menu select Meshing > Mesh > Lines and click 'Pick All' in the 'Mesh
Lines' Window
Your model should now appear as shown in the following window
Plot Numbering
To show the line numbers, keypoint numbers, node numbers...
From the Utility Menu (top of screen) select PlotCtrls > Numbering...
Fill in the Window as shown below and click 'OK'
Saving Your Work
Save the model at this time, so if you make some mistakes later on, you will at least be able
to come back to this point. To do this, on the Utility Menu select File > Save as.... Select the
name and location where you want to save your file.
1.3
SOLUTION PHASE: ASSIGNING LOADS AND SOLVING
You have now defined your model. It is now time to apply the load(s) and
constraint(s) and solve the the resulting system of equations.
Open up the 'Solution' menu (from the same 'ANSYS Main Menu').
1. Define Analysis Type
First you must tell ANSYS how you want it to solve this problem:
o
o
From the Solution Menu, select Analysis Type > New Analysis.
Ensure that 'Static' is selected; i.e. you are going to do a static analysis on the truss
as opposed to a dynamic analysis, for example.
o Click 'OK'.
2. Apply Constraints
It is necessary to apply constraints to the model otherwise the model is not tied down
or grounded and a singular solution will result. In mechanical structures, these
constraints will typically be fixed, pinned and roller-type connections. As shown
66
above, the left end of the truss bridge is pinned while the right end has a roller
connection.
o
In the Solution menu, select Define Loads > Apply > Structural > Displacement > On
Keypoints
o Select the left end of the bridge (Keypoint 1) by clicking on it in the Graphics
Window and click on 'OK' in the 'Apply U,ROT on KPs' window.
o This location is fixed which means that all translational and rotational degrees of
freedom (DOFs) are constrained. Therefore, select 'All DOF' by clicking on it and
enter '0' in the Value field and click 'OK'. You will see some blue triangles in the
graphics window indicating the displacement contraints.
o Using the same method, apply the roller connection to the right end (UY
constrained). Note that more than one DOF constraint can be selected at a time in
the "Apply U,ROT on KPs" window. Therefore, you may need to 'deselect' the 'All
DOF' option to select just the 'UY' option.
3. Apply Loads
As shown in the diagram, there are four downward loads of 280kN, 210kN, 280kN, and
360kN at keypoints 1, 3, 5, and 7 respectively.
o
o
o
o
o
o
Select Define Loads > Apply > Structural > Force/Moment > on Keypoints.
Select the first Keypoint (left end of the truss) and click 'OK' in the 'Apply F/M on
KPs' window.
Select FY in the 'Direction of force/mom'. This indicate that we will be applying the
load in the 'y' direction
Enter a value of -280000 in the 'Force/moment value' box and click 'OK'. Note that
we are using units of N here, this is consistent with the previous values input.
The force will appear in the graphics window as a red arrow.
Apply the remaining loads in the same manner.
The applied loads and constraints should now appear as shown below.
4. Solving the System
We now tell ANSYS to find the solution:
67
o
o
o
1.4
In the 'Solution' menu select Solve > Current LS. This indicates that we desire the
solution under the current Load Step (LS).
The above windows will appear. Ensure that your solution options are the same as
shown above and click 'OK'.
Once the solution is done the following window will pop up. Click 'Close' and close
the /STATUS Command Window.
POSTPROCESSING: VIEWING THE RESULTS
1. Results Using ANSYS
Reaction Forces
A list of the resulting reaction forces can be obtained for this element
o
o
from the Main Menu select General Postproc > List Results > Reaction Solu.
Select 'All struc forc F' as shown above and click 'OK'
Deformation
o
o
In the General Postproc menu, select Plot Results > Deformed Shape.
Select 'Def + undef edge' and click 'OK' to view both the deformed and the undeformed
object.
o
Observe the value of the maximum deflection in the upper left hand corner (DMX=7.409).
One should also observe that the constrained degrees of freedom appear to have a
deflection of 0 (as expected!)
Deflection
o
o
From the 'General Postproc' menu select Plot results > Contour Plot > Nodal Solution. The
following window will appear.
Select 'DOF solution' and 'USUM' as shown in the above window. Leave the other
selections as the default values. Click 'OK'.
68
o
o
Looking at the scale, you may want to use more useful intervals. From the Utility Menu
select Plot Controls > Style > Contours > Uniform Contours...
Fill in the following window as shown and click 'OK'.
o The deflection can also be obtained as a list as shown below. General Postproc > List
Results > Nodal Solution select 'DOF Solution' and 'ALL DOFs' from the lists in the 'List
Nodal Solution' window and click 'OK'. This means that we want to see a listing of all
degrees of freedom from the solution.
NODE
1
2
3
4
UX
0.000
3.0836
0.74604
1.5916
UY
0.000
-3.5033
-6.5759
-7.2363
69
5
6
7
2.3127
-0.49E-01
3.1334
-6.9923
-3.7338
0.000
MAXIMUM ABSOLUTE VALUES
NODE
VALUE
o
o
7
3.1334
4
-7.2363
Are these results what you expected? Note that all the degrees of freedom were
constrained to zero at node 1, while UY was constrained to zero at node 7.
If you wanted to save these results to a file, select 'File' within the results window (at the
upper left-hand corner of this list window) and select 'Save as'.
Axial Stress
For line elements (ie links, beams, spars, and pipes) you will often need to use the
Element Table to gain access to derived data (ie stresses, strains). For this example
we should obtain axial stress to compare with the hand calculations. The Element
Table is different for each element, therefore, we need to look at the help file for
LINK1 (Type help link1 into the Input Line). From Table 1.2 in the Help file, we
can see that SAXL can be obtained through the ETABLE, using the item 'LS,1'
o
o
o
o
o
o
o
From the General Postprocessor menu select Element Table > Define Table
Click on 'Add...'
Enter 'SAXL' in the 'Lab' box. This specifies the name of the item you are defining. Next, in
the 'Item,Comp' boxes, select 'By sequence number' and 'LS,'. Then enter 1 after LS, in the
selection box
Click on 'OK' and close the 'Element Table Data' window.
Plot the Stresses by selecting Element Table > Plot Elem Table
The following window will appear. Ensure that 'SAXL' is selected and click 'OK'
Because you changed the contour intervals for the Displacement plot to "User Specified" you need to switch this back to "Auto calculated" to obtain new values for VMIN/VMAX.
Utility Menu > PlotCtrls > Style > Contours > Uniform Contours
...
70
Again, you may wish to select more appropriate intervals for the contour plot
o
List the Stresses
From the 'Element Table' menu, select 'List Elem Table'
From the 'List Element Table Data' window which appears ensure 'SAXL' is
highlighted
Click 'OK'
MINIMUM VALUES
ELEM
VALUE
MAXIMUM VALUES
ELEM
VALUE
ELEM
SMAXI
1
-82.900
2
41.447
3
82.900
4
-82.900
5
-8.2900
6
87.038
7
8.2900
8
-91.183
9
91.189
10
45.591
11
-91.189
11
-91.189
9
91.189
71
© Copyright 2026 Paperzz