SlideShare a Scribd company logo
How to avoid floating point and multiplication operation in
Bresenham’s algorithm
The idea of Bresenham’s algorithm is to avoid floating point multiplication and
addition to compute mx + c, and then computing round value of (mx + c) in
every step. In Bresenham’s algorithm, we move across the x-axis in unit
intervals.
1. We always increase x by 1, and we choose about next y, whether we
need to go to y+1 or remain on y. In other words, from any position (Xk,
Yk) we need to choose between (Xk + 1, Yk) and (Xk + 1, Yk + 1).
2. We would like to pick the y value (among Yk + 1 and Yk) corresponding to
a point that is closer to the original line.
We need to a decision parameter to decide whether to pick Yk + 1 or Yk as
next point. The idea is to keep track of slope error from previous increment to
y. If the slope error becomes greater than 0.5, we know that the line has
moved upwards one pixel, and that we must increment our y coordinate and
readjust the error to represent the distance from the top of the new pixel –
which is done by subtracting one from error.
// Modifying the naive way to use a parameter
// to decide next y.
void withDecisionParameter(x1, x2, y1, y2)
{
m = (y2 - y1)/(x2 - x1)
slope_error = [Some Initial Value]
for (x = x1, y = y1; x = 0.5)
{
y++;
slope_error -= 1.0;
}
}
}
How to avoid floating point arithmetic
The above algorithm still includes floating point arithmetic. To avoid floating
point arithmetic, consider the value below value m.
m = (y2 – y1)/(x2 – x1)
We multiply both sides by (x2 – x1)
We also change slope_error to slope_error * (x2 – x1). To avoid comparison
with 0.5, we further change it to slope_error * (x2 – x1) * 2.
Also, it is generally preferred to compare with 0 than 1.
// Modifying the above algorithm to avoid floating
// point arithmetic and use comparison with 0.
void bresenham(x1, x2, y1, y2)
{
m_new = 2 * (y2 - y1)
slope_error_new = [Some Initial Value]
for (x = x1, y = y1; x = 0)
{
y++;
slope_error_new -= 2 * (x2 - x1);
}
}
}
The initial value of slope_error_new is 2*(y2 – y1) – (x2 – x1). Refer this for
proof of this value
Bresenham algorithm is faster than other algorithm :
Bresenham's line drawing algorithm is fast because it reduces determining where
to draw points on a line from the naive y= m*x + b formula to an addition plus a
branch (and the branch can be eliminated through well know branchless integer
techniques). The run-slice version of Brensenham's line drawing algorithm can be
even faster as it determines "runs" of pixels with the same component directly
rather than iterating. Bresenhams algorithm is faster than DDA algorithm in line
drawing because it performs only addition and subtraction in its calculation and
uses only integer arithmetic so it runs significantly faster.
What is shearing in computer graphics
Shearing: A transformation that slants the shape of an object is called
the shear transformation. There are two shear transformations X-Shear and
Y-Shear. One shifts X coordinates values and other shifts Y coordinate
values.
Scan Conversion Definition
It is a process of representing graphics objects a collection of pixels. The
graphics objects are continuous. The pixels used are discrete. Each pixel can
have either on or off state.
The circuitry of the video display device of the computer is capable of
converting binary values (0, 1) into a pixel on and pixel off information. 0 is
represented by pixel off. 1 is represented using pixel on. Using this ability
graphics computer represent picture having discrete dots.
Any model of graphics can be reproduced with a dense matrix of dots or
points. Most human beings think graphics objects as points, lines, circles,
ellipses. For generating graphical object, many algorithms have been
developed.
Advantage of developing algorithms for scan
conversion
1. Algorithms can generate graphics objects at a faster rate.
2. Using algorithms memory can be used efficiently.
3. Algorithms can develop a higher level of graphical objects.
Examples of objects which can be scan converted
1. Point
2. Line
3. Sector
4. Arc
5. Ellipse
6. Rectangle
7. Polygon
8. Characters
9. Filled Regions
The process of converting is also called as rasterization. The algorithms
implementation varies from one computer system to another computer
system. Some algorithms are implemented using the software. Some are
performed usinghardware or firmware. Some are performed using various
combinations of hardware, firmware, and software.
What is transformation? Type of transformation
What is transformation? In many cases a complex picture can
always be treated as a combination of straight line, circles, ellipse etc.,
and if we are able to generate these basic figures, we can also generate
combinations of them. Once we have drawn these pictures, the need
arises to transform these pictures.
We are not essentially modifying the pictures, but a picture in the center of
the screen needs to be shifted to the top left hand corner, say, or a picture
needs to be increased to twice it's size or a picture is to be turned through
900 . In all these cases, it is possible to view the new picture as really a
new one and use algorithms to draw them, but a better method is, given
their present form, try to get their new counter parts by operating on the
existing data. This concept is called transformation.
The three basic transformations are
(i) Translation
(ii) rotation and
(iii) Scaling.
Translation refers to the shifting of a point to some other place, whose
distance with regard to the present point is known. Rotation as the
name suggests is to rotate a point about an axis. The axis can be any of
the coordinates or simply any other specified line also. Scaling is the
concept of increasing (or decreasing) the size of a picture. (in one or in
either directions. When it is done in both directions, the increase or
decrease in both directions need not be same) To change the size of the
picture, we increase or decrease the distance between the end points of the
picture and also change the intermediate points are per requirements.
Translation:
Consider a point P(x1 , y1 ) to be translated to another point Q(x2 , y2 ). If we
know the point value (x2, y2) we can directly shift to Q by displaying the
pixel (x2, y2). On the other hand, suppose we only know that we want to
shift by a distance of Tx along x axis and Ty along Y axis. Then obviously
the coordinates can be derived by x2 =x1 +Tx and Y2 = y1 + Ty .
Suppose we want to shift a triangle with coordinates at A(20,10),
B(30,100) and C(40,70). The shifting to be done by 20 units along x
axis and 10 units along y axis. Then the new triangle will be at A1 (20+20,
10+10) B1 (30+20, 10+10) C1 (40+20, 70+10) In the matrix form [x2 y2 1] =
[x1 y1 1]
Rotation
Suppose we want to rotate a point (x1 y1) clockwise through an angle?
about the origin of the coordinate system. Then mathematically we can
show that
x2 = x1cos ? + y1sin? and
y2 = x1sin? - y1cos?
These equations become applicable only if the rotation is about the origin.
In the matrix for [x2 y2 1] = [x1 y1 1]
Scaling : Suppose we want the point (x1 y1) to be scaled by a factor sx and
by a factor sy along y direction.
Then the new coordinates become : x2 = x1 * sx and y2 = y1 * sy
(Note that scaling a point physically means shifting a point away. It does
not magnify
the point. But when a picture is scaled, each of the points are scaled
differently and hence the dimensions of the picture changes.)
composite transformation in computer graphics
A number of transformations or sequence of transformations can be combined into
single one called as composition. The resulting matrix is called as composite matrix.
The process of combining is called as concatenation.
Suppose we want to perform rotation about an arbitrary point, then we can perform
it by the sequence of three transformations
1. Translation
2. Rotation
3. Reverse Translation
The ordering sequence of these numbers of transformations must not be changed.
If a matrix is represented in column form, then the composite transformation is
performed by multiplying matrix in order from right to left side. The output
obtained from the previous matrix is multiplied with the new coming matrix.
Current Transformation Matrix (CTM)
There is a 4x4 homogeneous coordinate matrix, the current transformation
matrix (CTM), that is part of the state and is applied to all vertices that pass
down the pipeline.
Scalling matrix :
Matrix notation use in computer graphics
A matrix is an entity composed of components arranged in rows and
columns. Mathematically, a matrix is represented as:
Addition/Subtraction
Matrix addition/subtraction is allowed between matrices that have the same
dimension. To add matrices simply add the corresponding component to each
other.
Multiplication
Unlike matrix addition, matrix multiplication does not require matrices to be
of the same dimensions. However, the number of rows in matrix M must be
equal to the number of colums in matrix N. For example:
composite transformation in computer graphics composite transformation incomputer graphics composite transformation in computer graphics

More Related Content

What's hot

Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
PrathimaBaliga
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
Kasun Ranga Wijeweera
 
Unit 3
Unit 3Unit 3
Anish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_ReportAnish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_Reportanish h
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
Prabin Gautam
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
Maaz Rizwan
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
aravindangc
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
SHIVANI SONI
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
RAJKIYA ENGINEERING COLLEGE, BANDA
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithmsMohammad Sadiq
 
Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
Statistics Assignment Help
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
Ankit Garg
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
Tekendra Nath Yogi
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
sabbirantor
 
Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...
Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...
Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...
graphitech
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
LOKENDRA PRAJAPATI
 
Homogeneous Representation: rotating, shearing
Homogeneous Representation: rotating, shearingHomogeneous Representation: rotating, shearing
Homogeneous Representation: rotating, shearing
Manthan Kanani
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
MuhammadHamza401
 
transformation 3d
transformation 3dtransformation 3d
transformation 3d
HiteshJain007
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
Kamal Acharya
 

What's hot (20)

Chapter 3 Output Primitives
Chapter 3 Output PrimitivesChapter 3 Output Primitives
Chapter 3 Output Primitives
 
Digital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing AlgorithmDigital Differential Analyzer Line Drawing Algorithm
Digital Differential Analyzer Line Drawing Algorithm
 
Unit 3
Unit 3Unit 3
Unit 3
 
Anish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_ReportAnish_Hemmady_assignmnt1_Report
Anish_Hemmady_assignmnt1_Report
 
Computer graphics 2
Computer graphics 2Computer graphics 2
Computer graphics 2
 
Lec02 03 rasterization
Lec02 03 rasterizationLec02 03 rasterization
Lec02 03 rasterization
 
Computer Graphics Unit 1
Computer Graphics Unit 1Computer Graphics Unit 1
Computer Graphics Unit 1
 
3D transformation in computer graphics
3D transformation in computer graphics3D transformation in computer graphics
3D transformation in computer graphics
 
Computer graphics notes watermark
Computer graphics notes watermarkComputer graphics notes watermark
Computer graphics notes watermark
 
Lines and curves algorithms
Lines and curves algorithmsLines and curves algorithms
Lines and curves algorithms
 
Statistics Assignment Help
Statistics Assignment HelpStatistics Assignment Help
Statistics Assignment Help
 
Line drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniquesLine drawing algorithm and antialiasing techniques
Line drawing algorithm and antialiasing techniques
 
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath YogiB. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
B. SC CSIT Computer Graphics Unit 2 By Tekendra Nath Yogi
 
3D Transformation in Computer Graphics
3D Transformation in Computer Graphics3D Transformation in Computer Graphics
3D Transformation in Computer Graphics
 
Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...
Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...
Implementation of Hybrid Terrain Representation in Nasa WorldWind: Regular Gr...
 
Computer graphics presentation
Computer graphics presentationComputer graphics presentation
Computer graphics presentation
 
Homogeneous Representation: rotating, shearing
Homogeneous Representation: rotating, shearingHomogeneous Representation: rotating, shearing
Homogeneous Representation: rotating, shearing
 
Dda line algorithm presentatiion
Dda line algorithm presentatiionDda line algorithm presentatiion
Dda line algorithm presentatiion
 
transformation 3d
transformation 3dtransformation 3d
transformation 3d
 
Output primitives in Computer Graphics
Output primitives in Computer GraphicsOutput primitives in Computer Graphics
Output primitives in Computer Graphics
 

Similar to Computer graphic

The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math Primer
Janie Clayton
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
SanthiNivas
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Diksha Trivedi
 
Shi.pdf
Shi.pdfShi.pdf
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptx
Khalil Alhatab
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
RAJKIYA ENGINEERING COLLEGE, BANDA
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
Bala Murali
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmKALAIRANJANI21
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmKALAIRANJANI21
 
3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates
KRIPA SHNAKAR TIWARI
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1
Philip Schwarz
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptx
Khalil Alhatab
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
AhmadAbba6
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptx
Khalil Alhatab
 
99995320.ppt
99995320.ppt99995320.ppt
99995320.ppt
MohdSaqib79
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transform
Patel Punit
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
Mattupallipardhu
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra
Xad Kuain
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphics
cairo university
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsThirunavukarasu Mani
 

Similar to Computer graphic (20)

The Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math PrimerThe Day You Finally Use Algebra: A 3D Math Primer
The Day You Finally Use Algebra: A 3D Math Primer
 
Computer Graphics Unit 2
Computer Graphics Unit 2Computer Graphics Unit 2
Computer Graphics Unit 2
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Shi.pdf
Shi.pdfShi.pdf
Shi.pdf
 
Part 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptxPart 3- Manipulation and Representation of Curves.pptx
Part 3- Manipulation and Representation of Curves.pptx
 
Computer graphics notes
Computer graphics notesComputer graphics notes
Computer graphics notes
 
Computer graphics
Computer graphicsComputer graphics
Computer graphics
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithm
 
Rasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithmRasterisation of a circle by the bresenham algorithm
Rasterisation of a circle by the bresenham algorithm
 
3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates3 d scaling and translation in homogeneous coordinates
3 d scaling and translation in homogeneous coordinates
 
Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1Computer Graphics in Java and Scala - Part 1
Computer Graphics in Java and Scala - Part 1
 
Part 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptxPart 2- Geometric Transformation.pptx
Part 2- Geometric Transformation.pptx
 
Rasterization.pptx
Rasterization.pptxRasterization.pptx
Rasterization.pptx
 
Part 2- Transformation.pptx
Part 2- Transformation.pptxPart 2- Transformation.pptx
Part 2- Transformation.pptx
 
99995320.ppt
99995320.ppt99995320.ppt
99995320.ppt
 
Two dimentional transform
Two dimentional transformTwo dimentional transform
Two dimentional transform
 
raster algorithm.pdf
raster algorithm.pdfraster algorithm.pdf
raster algorithm.pdf
 
Computer Graphics & linear Algebra
Computer Graphics & linear Algebra Computer Graphics & linear Algebra
Computer Graphics & linear Algebra
 
2 transformation computer graphics
2 transformation computer graphics2 transformation computer graphics
2 transformation computer graphics
 
Graphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygonsGraphics6 bresenham circlesandpolygons
Graphics6 bresenham circlesandpolygons
 

Recently uploaded

Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
gdsczhcet
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
Amil Baba Dawood bangali
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
AhmedHussein950959
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
AJAYKUMARPUND1
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
seandesed
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
karthi keyan
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
ssuser9bd3ba
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
DuvanRamosGarzon1
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
Jayaprasanna4
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Dr.Costas Sachpazis
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
PrashantGoswami42
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
Robbie Edward Sayers
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
ShahidSultan24
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 

Recently uploaded (20)

Gen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdfGen AI Study Jams _ For the GDSC Leads in India.pdf
Gen AI Study Jams _ For the GDSC Leads in India.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...
 
ASME IX(9) 2007 Full Version .pdf
ASME IX(9)  2007 Full Version       .pdfASME IX(9)  2007 Full Version       .pdf
ASME IX(9) 2007 Full Version .pdf
 
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
Pile Foundation by Venkatesh Taduvai (Sub Geotechnical Engineering II)-conver...
 
Architectural Portfolio Sean Lockwood
Architectural Portfolio Sean LockwoodArchitectural Portfolio Sean Lockwood
Architectural Portfolio Sean Lockwood
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
CME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional ElectiveCME397 Surface Engineering- Professional Elective
CME397 Surface Engineering- Professional Elective
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
LIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.pptLIGA(E)11111111111111111111111111111111111111111.ppt
LIGA(E)11111111111111111111111111111111111111111.ppt
 
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSETECHNICAL TRAINING MANUAL   GENERAL FAMILIARIZATION COURSE
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSE
 
ethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.pptethical hacking in wireless-hacking1.ppt
ethical hacking in wireless-hacking1.ppt
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...
 
Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.Quality defects in TMT Bars, Possible causes and Potential Solutions.
Quality defects in TMT Bars, Possible causes and Potential Solutions.
 
HYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generationHYDROPOWER - Hydroelectric power generation
HYDROPOWER - Hydroelectric power generation
 
addressing modes in computer architecture
addressing modes  in computer architectureaddressing modes  in computer architecture
addressing modes in computer architecture
 
Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 

Computer graphic

  • 1. How to avoid floating point and multiplication operation in Bresenham’s algorithm The idea of Bresenham’s algorithm is to avoid floating point multiplication and addition to compute mx + c, and then computing round value of (mx + c) in every step. In Bresenham’s algorithm, we move across the x-axis in unit intervals. 1. We always increase x by 1, and we choose about next y, whether we need to go to y+1 or remain on y. In other words, from any position (Xk, Yk) we need to choose between (Xk + 1, Yk) and (Xk + 1, Yk + 1). 2. We would like to pick the y value (among Yk + 1 and Yk) corresponding to a point that is closer to the original line. We need to a decision parameter to decide whether to pick Yk + 1 or Yk as next point. The idea is to keep track of slope error from previous increment to y. If the slope error becomes greater than 0.5, we know that the line has moved upwards one pixel, and that we must increment our y coordinate and readjust the error to represent the distance from the top of the new pixel – which is done by subtracting one from error.
  • 2. // Modifying the naive way to use a parameter // to decide next y. void withDecisionParameter(x1, x2, y1, y2) { m = (y2 - y1)/(x2 - x1) slope_error = [Some Initial Value] for (x = x1, y = y1; x = 0.5) { y++; slope_error -= 1.0; } } } How to avoid floating point arithmetic The above algorithm still includes floating point arithmetic. To avoid floating point arithmetic, consider the value below value m. m = (y2 – y1)/(x2 – x1) We multiply both sides by (x2 – x1) We also change slope_error to slope_error * (x2 – x1). To avoid comparison with 0.5, we further change it to slope_error * (x2 – x1) * 2. Also, it is generally preferred to compare with 0 than 1. // Modifying the above algorithm to avoid floating // point arithmetic and use comparison with 0. void bresenham(x1, x2, y1, y2) { m_new = 2 * (y2 - y1) slope_error_new = [Some Initial Value] for (x = x1, y = y1; x = 0) { y++; slope_error_new -= 2 * (x2 - x1); } } } The initial value of slope_error_new is 2*(y2 – y1) – (x2 – x1). Refer this for proof of this value
  • 3. Bresenham algorithm is faster than other algorithm : Bresenham's line drawing algorithm is fast because it reduces determining where to draw points on a line from the naive y= m*x + b formula to an addition plus a branch (and the branch can be eliminated through well know branchless integer techniques). The run-slice version of Brensenham's line drawing algorithm can be even faster as it determines "runs" of pixels with the same component directly rather than iterating. Bresenhams algorithm is faster than DDA algorithm in line drawing because it performs only addition and subtraction in its calculation and uses only integer arithmetic so it runs significantly faster. What is shearing in computer graphics Shearing: A transformation that slants the shape of an object is called the shear transformation. There are two shear transformations X-Shear and Y-Shear. One shifts X coordinates values and other shifts Y coordinate values.
  • 4. Scan Conversion Definition It is a process of representing graphics objects a collection of pixels. The graphics objects are continuous. The pixels used are discrete. Each pixel can have either on or off state. The circuitry of the video display device of the computer is capable of converting binary values (0, 1) into a pixel on and pixel off information. 0 is represented by pixel off. 1 is represented using pixel on. Using this ability graphics computer represent picture having discrete dots. Any model of graphics can be reproduced with a dense matrix of dots or points. Most human beings think graphics objects as points, lines, circles, ellipses. For generating graphical object, many algorithms have been developed. Advantage of developing algorithms for scan conversion 1. Algorithms can generate graphics objects at a faster rate. 2. Using algorithms memory can be used efficiently. 3. Algorithms can develop a higher level of graphical objects.
  • 5. Examples of objects which can be scan converted 1. Point 2. Line 3. Sector 4. Arc 5. Ellipse 6. Rectangle 7. Polygon 8. Characters 9. Filled Regions The process of converting is also called as rasterization. The algorithms implementation varies from one computer system to another computer system. Some algorithms are implemented using the software. Some are performed usinghardware or firmware. Some are performed using various combinations of hardware, firmware, and software. What is transformation? Type of transformation What is transformation? In many cases a complex picture can always be treated as a combination of straight line, circles, ellipse etc., and if we are able to generate these basic figures, we can also generate combinations of them. Once we have drawn these pictures, the need arises to transform these pictures. We are not essentially modifying the pictures, but a picture in the center of the screen needs to be shifted to the top left hand corner, say, or a picture needs to be increased to twice it's size or a picture is to be turned through 900 . In all these cases, it is possible to view the new picture as really a new one and use algorithms to draw them, but a better method is, given their present form, try to get their new counter parts by operating on the existing data. This concept is called transformation.
  • 6. The three basic transformations are (i) Translation (ii) rotation and (iii) Scaling. Translation refers to the shifting of a point to some other place, whose distance with regard to the present point is known. Rotation as the name suggests is to rotate a point about an axis. The axis can be any of the coordinates or simply any other specified line also. Scaling is the concept of increasing (or decreasing) the size of a picture. (in one or in either directions. When it is done in both directions, the increase or decrease in both directions need not be same) To change the size of the picture, we increase or decrease the distance between the end points of the picture and also change the intermediate points are per requirements. Translation: Consider a point P(x1 , y1 ) to be translated to another point Q(x2 , y2 ). If we know the point value (x2, y2) we can directly shift to Q by displaying the pixel (x2, y2). On the other hand, suppose we only know that we want to shift by a distance of Tx along x axis and Ty along Y axis. Then obviously the coordinates can be derived by x2 =x1 +Tx and Y2 = y1 + Ty . Suppose we want to shift a triangle with coordinates at A(20,10), B(30,100) and C(40,70). The shifting to be done by 20 units along x axis and 10 units along y axis. Then the new triangle will be at A1 (20+20, 10+10) B1 (30+20, 10+10) C1 (40+20, 70+10) In the matrix form [x2 y2 1] = [x1 y1 1]
  • 7. Rotation Suppose we want to rotate a point (x1 y1) clockwise through an angle? about the origin of the coordinate system. Then mathematically we can show that x2 = x1cos ? + y1sin? and y2 = x1sin? - y1cos? These equations become applicable only if the rotation is about the origin. In the matrix for [x2 y2 1] = [x1 y1 1] Scaling : Suppose we want the point (x1 y1) to be scaled by a factor sx and by a factor sy along y direction. Then the new coordinates become : x2 = x1 * sx and y2 = y1 * sy (Note that scaling a point physically means shifting a point away. It does not magnify the point. But when a picture is scaled, each of the points are scaled differently and hence the dimensions of the picture changes.)
  • 8. composite transformation in computer graphics A number of transformations or sequence of transformations can be combined into single one called as composition. The resulting matrix is called as composite matrix. The process of combining is called as concatenation. Suppose we want to perform rotation about an arbitrary point, then we can perform it by the sequence of three transformations 1. Translation 2. Rotation 3. Reverse Translation The ordering sequence of these numbers of transformations must not be changed. If a matrix is represented in column form, then the composite transformation is performed by multiplying matrix in order from right to left side. The output obtained from the previous matrix is multiplied with the new coming matrix.
  • 9. Current Transformation Matrix (CTM) There is a 4x4 homogeneous coordinate matrix, the current transformation matrix (CTM), that is part of the state and is applied to all vertices that pass down the pipeline. Scalling matrix :
  • 10. Matrix notation use in computer graphics A matrix is an entity composed of components arranged in rows and columns. Mathematically, a matrix is represented as: Addition/Subtraction Matrix addition/subtraction is allowed between matrices that have the same dimension. To add matrices simply add the corresponding component to each other.
  • 11. Multiplication Unlike matrix addition, matrix multiplication does not require matrices to be of the same dimensions. However, the number of rows in matrix M must be equal to the number of colums in matrix N. For example: composite transformation in computer graphics composite transformation incomputer graphics composite transformation in computer graphics