0% found this document useful (0 votes)
45 views24 pages

Bresenham's Algorithm Enables The Selection of Optimum Raster Locations To Represent A Straight Line

Bresenham's algorithm enables the selection of optimum raster locations to represent a straight line on a discrete digital display. It is a line drawing algorithm that determines the points that lie on a discrete representation of a continuous line between two given points. The algorithm uses integer arithmetic to determine the next pixel in the raster image, along the line between two given points. It works by calculating the distance of the current pixel from the ideal line defined by the two end points and checking if this distance exceeds a threshold value. Geometric modeling refers to computer representations of objects using software. There are three main types: wireframe modeling uses edges to represent objects, surface modeling uses surfaces defined by vertices and edges, and solid modeling represents objects as
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
45 views24 pages

Bresenham's Algorithm Enables The Selection of Optimum Raster Locations To Represent A Straight Line

Bresenham's algorithm enables the selection of optimum raster locations to represent a straight line on a discrete digital display. It is a line drawing algorithm that determines the points that lie on a discrete representation of a continuous line between two given points. The algorithm uses integer arithmetic to determine the next pixel in the raster image, along the line between two given points. It works by calculating the distance of the current pixel from the ideal line defined by the two end points and checking if this distance exceeds a threshold value. Geometric modeling refers to computer representations of objects using software. There are three main types: wireframe modeling uses edges to represent objects, surface modeling uses surfaces defined by vertices and edges, and solid modeling represents objects as
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 24

BRESENHAMS LINE ALGORITHM

Bresenhams algorithm enables the selection of optimum raster locations to represent a


straight line

Fig. a Location of Pixels Using


Bresenham Algorithm

Fig. b Pixels for Line of


Slope, m = 0.4

Pseudo code for Bresenhams line-drawing algorithm


Given a line from x1, y1 to x2, y2...
dx is the difference between the x components of end points
dy is the difference between the y components of end points
ix is the absolute value of dx
iy is the absolute value of dy
inc is the larger of dx, dy
plotx is x1
ploty is y1 (the beginning of line)
x starts at 0
y starts at 0
plot a pixel at plotx, ploty
increment x using ix
increment y using iy
plot is false
if x is greater than inc
plot is true
decrement x using inc
increment plotx if dx is positive
decrement plotx id dx is negative
if y is greater than inc
plot is true
decrement y using inc
increment ploty if dy is positive
decrement ploty if dy is negative
if plot is true, plot a pixel at plotx, ploty
increment i.

Program in Turbo-C to draw a line


# include <stdio. h>
# include <graphics. h>
# include <stdlb. h>
void draw line (int x1, int y1, int x2, int y2),
void main (void)
{
draw line (100, 100, 50, 50) ;
}
void draw line (int x1, int y1, int x2 m int y2)
{
int dx, dy, inc, ix, iy, x, y, plot, plotx, ploty, i ;
int gd, gm ;
gd = DETECT ;
initgraph (&gd, &gm, ) ;
dx = x1 x2 ;
dy = y1 y2 ;
ix = abs (dx) ;
iy = abs (dy) ;
inc = max (ix, iy) ;
x=y=0;
plot x = x1 ;
plot y = y1 ;

for (i = 0 ; i <inc ; i ++)


{
x + = ix ;
y + iy ;
plot = 0
if (x > inc)
{
plot = 1 ;
x = inc ;
if (dx < 0)
plot x = 1 ;
else
plotx + = 1 ;
}
if (y > inc)
{
plot = 1 ;
y = inc ;
if (dy)
ploty = 1 ;
else
ploty + = 1 ;
}
if (plot)
putpixel (plotx, ploty, 1)
else
}
getch ( ) ;
closegraph ( ) ;

BRESENHAMS CIRCLE ALGORITHM

UNIT - 3
GEOMETRIC MODELLING
wire frame, surface and solid modeling

CLASSIFICATION OF GEOMETRIC MODELING


Computer representation of the geometry of a component using software is called
a geometric model. Geometric modeling is done in three principal ways. They are:
1. Wire frame modeling
2. Surface modeling
3. Solid modeling
These modeling methods have distinct features and applications.

WIRE FRAME MODELING


In wire frame modeling the object is represented by its edges

A comparison between 2-D and 3-D models is given below:


2 - D Models

3-D Wire Frame Models

1. Ends (vertices) of lines are represented 1. Ends of lines are represented by their
by their X and Y coordinates

X, Y and Z coordinates.

2. Curved edges are represented by 2. Curved surfaces are represented by


circles,

ellipses,

splines

etc.

suitably spaced generators. Hidden

Additional views and sectional views

line or hidden surface elimination is

are necessary to represent a complex

object with clarity.

components correctly.

3. 3-D image reconstruction is tedious.


4. Uses only one global coordinate
system

must

to

interpret

complex

3. 2-D views as well as various pictorial


views can be generated easily.
4. May require the use of several user
coordinate systems to create features
on different faces of the component.

SURFACE MODELING
In this approach, a component is represented by its surfaces which in turn are
represented by their vertices and edges.
For example, eight surfaces are put together to create a box, as
shown in
Apart from standard surface types
available for surface modeling
(box, pyramid, wedge, dome,
sphere, cone, torus, dish and
mesh) techniques are available
for interactive modeling and
editing of curved surface
geometry.

Surface modeling has been very popular in


aerospace product design and automotive
design.

SOLID MODELING
The representation of solid models uses the fundamental idea that a physical
object divides the 3-D Euclidean space into two regions, one exterior and one interior,
separated by the boundary of the solid. Solid models are:
bounded
Homogeneously three dimensional
Finite
There are six common representations in solid modeling.
i. Spatial Enumeration: In this simplest form of 3D volumetric raster model, a
section of 3D space is described by a matrix of evenly spaced cubic volume
elements called voxels.
ii. Cell Decomposition: This is a hierarchical adaptation of spatial enumeration.
3D space is sub-divided into cells. Cells could be of different sizes. These simple
cells are glued together to describe a solid object.

iii. Boundary Representation: The solid is represented by its boundary which


consists of a set of faces, a set of edges and a set of vertices as well as their
topological relations.
iv. Sweep Methods: In this technique a planar shape is moved along a curve.
Translational sweep can be used to create prismatic objects and rotational sweep
could be used for axisymmetric components.
v. Primitive Instancing: This modeling scheme provides a set of possible object
shapes which are described by a set of parameters. Instances of object shape can
be created by varying these parameters.
vi. Constructive Solid Geometry (CSG): Primitive instances are combined using
Boolean set operations to create complex objects.
In most of the modeling packages, the approach used for modeling uses any one of the
following three techniques:
i. Constructive solid geometry (CSG or C-Rep)
ii. Boundary representation (B-Rep)
iii. Hybrid method which is a combination of B-Rep and CSG.

Constructive Solid Geometry (CSG)


In a CSG model, physical objects
are created by combining basic
elementary

shapes

known

as

primitives like blocks, cylinders,


cones, pyramids and spheres.
The Boolean operations like union
(),

difference

()

and

intersection are used to carry out


this task. For example, let us
assume that we are using two
primitives, a block and a cylinder
which are located in space as
shown in Fig.

Boundary Representation
Boundary representation is built on
the concept that a physical object is
enclosed by a set of faces which
themselves are closed and orient able
surfaces. Fig. Shows a B-rep model of
an object. In this model, face is bounded
by edges and each edge is bounded by
vertices. The entities which constitute a
B-rep model are:
Geometric

entities

entities
Point Vertex
Curve, line Edge
Surface Face

Topological

Workings of CSG

CSG Example
ADD

REMOVE

INTERSEC
T

SALIENT FEATURES OF SOLID MODELING


FEATURE-BASED DESIGN
The most fundamental aspect in creating a solid model is the concept of feature-based
design.
In typical 2-D CAD applications, a designer draws a part by adding basic geometric
elements such as lines, arcs, circles and splines.
In solid modeling a 3-D design is created by starting a base feature and then adding other
features, one at a time, until the accurate and complete representation of the parts
geometry is achieved.
A feature is a basic building block that describes the design, like a keyway on a shaft.
Each feature indicates how to add material (like a rib) or remove a portion of material
(like a cut or a hole).

SURFACE MODELING
All physical objects are 3-dimensional.
In a number of cases, it is sufficient to describe the boundary of a solid object in order
to specify its shape without ambiguity. This fact is illustrated in Fig..
The boundary is a collection of faces forming a closed surface

Creating a Surface
A surface can be created in several ways:
i. Creating a plane surface by the linear sweep of
a line or series of lines.
ii. Revolving a straight line about an axis.
Cylindrical, conical surfaces etc. can be generated
by this technique.
iii. Revolving a curve about an axis.
iv. Combination of plane surfaces.
v. Analytic surfaces: Planes, cylinders, cones, ellipsoid, parabolic hyperboloid etc can be
defined by mathematical equations in terms of X, Y and Z co-ordinates.
vi. Sculptured surfaces: These are also called free form surfaces. These are created by
spline curves in one or both directions in a 3-D space. These surfaces are used in the
manufacture of car body panels, aircraft structures, mixed flow impellers, telephone
instruments, plastic containers and several consumer and engineering products.

Application of Surface modeling


Modeling of curves and surfaces is essential to describe
objects that are encountered in several areas of mechanical
engineering design. Curves and surfaces are the basic building
blocks in the following designs:
i. Body panels of passenger cars
ii. Aircraft bulk heads and other fuselage structures, slats,
flaps, wings etc.
iii. Marine structures
iv. Consumer products like plastic containers, telephones etc.
v. Engineering products like mixed flow impellers, foundry patterns etc A curve has one
degree of freedom while a surface has two degrees of freedom. This means that a point on
a curve can be moved in only one independent direction while on surfaces it has two
independent directions to move. This is shown in Fig.

REPRESENTATION OF CURVES AND SURFACES


A curve or a surface may be described or represented by a set of equations. These
equations can be categorized into two forms:
i. Generic form
The generic form in which any generic point (x, y, z) satisfies a relationship in implicit
form in x, y, and z i.e. f(x, y, z) = 0. A single such constraint generally describes a surface
while two constraints considered together can be thought of as a curve which is the intersection
of two surfaces. This may be expressed in an explicit form in the following manner:
x = g1(y, z)

y = g2(x, z)

z = g3(x, y)

ii. Parametric form


A parametric curve is one whose defining equations are in terms of a simple, common
independent variable known as parametric variable. In the parametric form, the representation
is done by a set of functions. A curve may be represented by
x = x (u)

y = y (u)

z = z (u)

where x, y, z are co-ordinates of the points on the curve which are functions of some
parameter u and the parametric variable is constrained in the interval.

For example, a point (x, y) is located at an angle from +X axis on a circle with
centre at (0, 0) and radius = 1 can be described in parametric form as:
x = Cos
y = Sin
where is the parameter. Surfaces are described similarly for which x, y and z
are functions two independent parameters u and v.
Parametric design is very popular in computer aided design for a variety of reasons,
which are listed below:
Separation of variables
Each variable is treated alike
More degrees of freedom/control
Parametric equations can be transformed directly
Infinite slopes can be handled without computational breakdown
Easy to express as vectors
Amenable to plotting and digitizing
Inherently bounded

DESIGN OF CURVED SHAPES

You might also like