0% found this document useful (0 votes)
4K views308 pages

Computer Graphics PDF

Uploaded by

Dhruv Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
4K views308 pages

Computer Graphics PDF

Uploaded by

Dhruv Shah
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 308
As per the New Revised Syllabus (REV- 2019 ‘c’ Scheme) of Mumbai University w.e.f. academic year 2020-21 Computer Graphics (Code : CSC305) Semester III Computer Engineering / Computer Science and Engineering / Artificial Intelligence & Data Science / Machine Learning / Cyber Security / Internet of Things (IoT) / Data Engineering / Data Science / Internet of Things and Cyber Security Including Block Chain Technology / Computer Science Design Dr. Mahesh M. Goyani — Soy . B | Solved Latest University lu z= _ ee TechKnowledge @/ Model Queition Paper fr University Examination. SW” publications ag> COMPUTER GRAPHIC (Code : CSC305) { er Il (Mumba Computer Engineering / Computer Science and En; Sclence / Machine Learning / Cyber Security / Data Sctence / Internet of Things and Cyb Computer Sclence Design gineering / Artificial Intelligence & Data / Internet of Things (loT) / Data Engineering er Security Including Block Chain Technology / Dr. Mahesh M. Goyani PhD, BA, ME, BLE. Assistant Professor, Department of Computer Engineering, Government Engineering College, Modasa Gujarat, India MO148C Price? 425/- I Se TechKnowledge | Y publications COMPUTER GRAPHICS (csc305) br, Mahesh M. Goyant “ puter Engineering / Compurer Scie rity / Inte nine Learning / Cyber et of Things and Cyber Secu i University) ering / Artificial Intelligence & gs (lor) / Data Engineering n Technology nee and Engine ret of Thin} rity. Including Block Chain (Semester Il - Comp science / Mac’ nice /_ Intern sign (Mumbai Data § / Data / Computer Sclence Des be reproduced, copied, or stored ing including photocopy, recording, or lisher. author All rights reserved. No part of this publication my stributed or transmitted in any form or by any means, sthout the prior written permission of the Pl Copyright © by’ retrieval system di ther electronic or mechanical methods, wi be lent, resold, hired ay of trade or otherwise, in any form of binding or cover other n being imposed on the This book is sold subject tothe conition that shall not, by the Ww ier’s prior written consen out, or otherwise circulated without the publish ilar condition including this conditio than which it is published and without a simi subsequent purchaser and without limiting the rights under copyright reserved above. First Printed in India August 2015 (Mumbai University) First Edition 3 August 2020 Second Revised Edition: July 2021 Third Revised Edition + July 2022 This edition is for sale in India, Bangladesh, Bhutan, Maldi 0 I 1, Maldives, Nepal, Pakistan, Sri Lanka and d countries in South-East Asia, Sale and purchase of this book outside of these countries is vnauthorzed byte publisher. ISBN: 978-93-89889-99-4 ens TECHKNOWLEDGE PUBLICATIONS 37/2, Ashtavinayak Industrial Es state, B/S, First floor, Manirat ma ars Aeor, na Complex, Taware Colony ranyeshwar Corner, Pune - 411 009. Maharashtra State, India Ph: 91-20-24221234, 91-20-24225678. Email : [email protected], Website : of ebsite : www.techknowledgebooks.com ‘Narhe, Pune, Maharashtra State, India. Pune - 411041 Subject Code :CSC305 Book Code : MO148c We dedicate this Publication soulfully and wholeheartedly, in loving memory of our beloved founder director, Late Shri. Pradeepji Lalchandji Lunawat, who will always be an inspiration, a positive force and strong support behind us. “My work is my prayer to God” ~ Lt. Shiri. Pradeepji L. Lunawat Soulful Tribute and Gratitude for all Your Sacrifices, Hardwork and 40 years of Strong Vision... Dedicated to. My Beloved Daughters Kavya and Mausam ‘The musical lyrics of my life Computer Graphics is a very dynamic and rapidly growing area amongst others in Computer Science. Entertainment, education, animation, film industry, advertisements, presentations, virtual My dear students, reality, computer aided design and many other fields rly extensively on computer graphics, owing to (ts importance Computer Graphics has become an indivisible part not only in academic but in professional ventures as well The book "Computer Graphics” has been written according to the new syllabus of Mumbai University for students pursuing B.E, with a vision to provide students the necessary resources for the formation ofa strong base in Computer Graphics. This book discusses the concepts of Computer Graphics with self-explanatory diagrams and examples. Care has been taken to provide the reader with an understanding of the principles of Computer Graphics along with their implementation and applications. ‘Numerous examples have been covered to allow the readers an even better understanding of the concepts. The book has been written in a lucid manner and the technical jargon has been simplified so as to make it comprehensible by people from all disciplines, the questions from previous Mumbai University examinations have been included at the end of every chapter and their solutions are covered within the ‘ext. Ths facilitates the students to prepare a chapter or a concept from an examination point of view as well. Key features: ‘Simplified explanation in lucid manner Solved university question papers, Algorithms of all problems Detail coverage of each and every tople Set of self explanatory diagrams ‘Wide range of programs ACKNOWLEDGEMENT lectures with my “Computer Graphics” is the result of the numerous discussions. I had In le reciate all the students and peers while offering this course at different levels of study. 1 app constructive comments from colleges and doubts ralsed by students. nesting Cle, I would like to express my gratitude to my colleagues at Government Engineering College, Modasa. for their constant support. They have continuously monitored and motivated my journey throughout this book. My friends and colleagues have been a constant source of inspiration for me. 1 thank everyone who has contributed ta this book directly or indirectly. I present this book in the loving memory of Late Shri. Pradeepji Lunawat, ‘our source of inspiration and a strong foundation of “TechKnowledge Publications”. He will always be remembered in our heart and motivate us to achieve our milestone. 1am thankful to Shri. J. §. Katre, Shri. Shital Bhandari, Shri Arunoday Kumar and Shri. Chandroday Kumar for the encouragement and support that they have extended. | am also thankfill ‘@ Seema Lunawat for technology enhanced reading, E-books support and the staff members of TechKnowledge Publications for thelr efforts to make this book as good as it is, I have Jointly made every possible eforts to eliminate all the errors inthis book. However if you find any, please let me know, because that will help me to improve further. Last but not least, I would like to sincerely thank my. ‘family for supporting me throughout my venture of writing this book, without them it wouldn't have been possible. ~ Dr. Mahesh M, Goyani ee UE Mumbai University Revised syllabus (Rev-2019 'C’ Scheme) from Academic Year 2020-21 Course Code Course Name Credits esc30s Computer Graphics 3 Prerequisites : Knowledge of C Programming and Basic Mathematics, Course Objectives: To equip students with the fundamental knowledge and basic technical competence in the field of computei graphics. 2. To emphasize on implementation aspect of Computer Graphics Algorithms. To prepare the student for advance areas and professional avenues in the field of Computer Graphics. Course Outcomes : At the end of the course , the students should be able to Describe the basic concepts of Computer Graphics. 2, Demonstrate various algorithms for basic graphics primitives. 3. Apply geometric transformations on graphical objects. Use various Clipping algorithms on graphical objects Explore 3-D geometric transformations, curve representation techniques and projections methods. Explain visible surface detection techniques and Animation, Module Delalled Content 1. | Introduction and Overview of Graphics System oz hrs. Definition and Representative uses of computer graphics, Overview of coordinate system, Definition of scan conversion, rasterization and rendering. Raster scan & random scan displays, Architecture of raster graphics system with display processor, Architecture of random scan systems, (Refer Chapter 1) Output Primitives 10hrs. ‘Scan conversions of point, line, circle and ellipse: DDA algorithm and Bresenham algorithm for line drawing, midpoint algorithm for circle, midpoint algorithm for ellipse drawing (Mathematical derivation for above algorithms is expected) Aliasing, Antiallasing techniques like Pre and post filtering, super sampling, and pixel phasing), Filled Area Primitive : Scan line Polygon Fill algorithm, inside outside tests, Boundary Fill and Flood fill algorithm. (Refer Chapters 2 and 3) [a7 Detalled Content ‘Two Dime! Basie transformations: Homogeneous Coordinates ns: Reflection and Shear formations , aling, Rotation Matrix representation an ation nsfonal Geometric Tran ‘Translation, Jomposite transform: ae (Refer Chapter 4) Other transformatlo} coordinate Thrs. ind Clipping and Window to Viewport Two Dimensional ViewIng a Viewing transformation pipeline transformation algorithms : Cohen-Sutherland, Clipping operations : Point clipping, Line clipping L Liang : Barsky, Polygon Clipping Algorithms + sutherland-Hodgeman, Weller Atherton. (Refer Chapter 5) Shrs. Transformations, Curves and Fractal Three Dimensional Geometric Generation 3D Transformations : Translation, Rotation, Scaling and Refle Composite transformations : Rotation about an arbitrary axis Projections - Parallel, Perspective. (Matrix Representation) rractal Dimension, Koch Curve. Bezier Curve, B-Spline Curve, Fractal-Geometry : (Refer Chapters 6,7 and 8) 6 hrs. Visible Surface Detection : ton pee Detection : Classification of Visible Surface Detection algorithm, urface detection method, Depth Buffer method, Area Subdivision method Animation : Hi betes sito to Animation, Traditional Animation Techniques, ation, Key framing: Character and Facial Animation, Deformation, Motion capture YF Computer Graphics (MU) \ Table of Contents Chapter 1: Introduction and Overview of Graphics System Raster scan & random scan displays, Architecture of raster graphics 6 scan systems. 4-4 t04-28 ‘Syllabus : Definition and Representative uses of computer graphics, Overvie rasterization and rendering, 'ew of coordinate system, Definition of scan conversion, ster with display processor, Architecture of random| 44 12 13 14 15 16 Introduction. wn Graphics Primitives sn - BZA LINES on 12 1.2.2 Line Segments... “1a 123° Vectors... Applications of Computer Graphics, ‘Overview of the Coordinate System... 1.4.4 Introduction... 142 Cartesian Coordinate System. 1.4.3 Polar Coordinate System. 144 Spherical Coordinate System... 14.5 Cylindrical Coordinate System ... Basic Terminology..... 4.8.4 Sean Conversion «nun 1.8.2 Rasterization. 15.3 Rendering. 154 Piel... 1.5.5 Resolution... 1.5.6 Aspect Ratio 1.5.7 Frame Butter... Display Devices, 1.6.1 Cathode Ray Tube., 1.6.2 Raster Scan Display. 1.6.3 Random Scan Display.. 1.6.4 Raster Scan vs. Random Scan . 1.8.5 Color CRT Monitors. 1.8.5.1 Beam Penetration Method... 1.6.5.2 Shadow Mask Method... 17 18 &F Computer Grap Table of Content, jes (MU) 7 Se eT 1.6.7 Flat Panel Display... a he 1.6.7.1 LOD ~ 16.7.2 LED. x 1.6.7.3 Plasma Panels... m 1.6.7.4 Electroluminescent Display... a 416.8 Comparison of CRT, LCD, Plasma and OLED Display «~~~ 8 Architecture of Raster Sean Systems s 4.7.1 Video Controle... 128 Architecture of Random Scan Systems .. Modi Chapter 2: Output Primitives 2-1 to 247 Syllabus : [Scan conversions of point, ine, circle and ellipse : DDA algorithm and Bresenham algorithm for line drawing, midpoint algorithm for circle, midpoint algorithm for ellipse drawing (Mathematical derivation for above algorithms is expected) Aliasing, Antialiasing techniques like Pre and post ftering, super sampling, and pixel phasing). 24 22 23 ‘Scan Conversior 24.4 What is Scan Conversion? .. 24.2 Line and Line Segment... 2.4.3 Qualities of Good Line Drawing Algorithms. Line Drawing Algorithms. 22.1. DDALIne Drawing Algorithm... 23 2.2.1.1 Working Mechanism. 2.2.4.2 Algorithm... 22.1.3 Pros and Cons. 2.2.1.4 Examples...... “ 2.2.2 Bresenham Line Drawing Algorithm. a 2.2.2.1 Working Mechanism. at .2at 2.2.22 Algorithm... 2.2.23 Pros and Cons.. 2.2.2.4 Examples 2a 228 snes BOB 228 229 22.3 DDAvs. Bresenham Line Drawing Algorithm. Circle Drawing Algorithm, 23.1 Midpoint Circle Drawing Algorithm... 2.3.1.1 Working Mechanism.. 24 STiol WF Computer Grophics (MUL 2 Table of Contents 2.3.1.2 Algorithm ... ‘ son 234 2.3.1. Pros and Cons nee sn 282 2a.te Example. 222 235 235 2.4 Midpoint Ellipse Drawing Algorithm... 2.4.1 Working Mechanisr 242 Algorithm . su 240 243 Pros and Cons... Bd 244 Example... 284 282 243 os 43 25 Aliasing 2.6 Antialiasing 28.1 Pre Filtering... 2.62 Post Fiering 244 263 Super Sampling... 24 284 Pixel Phasing... 248 Chapter 3: Filled Area Primitives 341 to 346 Chapter 3:_Filled Area Primitives Syllabus : Filled Area Primitive : Scan line Polygon Fill algorithm, Inside outside tests, Boundary Fill and Flood fil algorithm. 34 Polygon.... 3.1.1. Introduction to Polygon... 3.1.2 Types of Polygon... 3.4.2.1. Convex Polygon... 3.4.2.2 Concave Polygon... 3.1.2.3 Complex Polygon. 3.2 Inside Outside Tests. 324 Even-Odd Test... 8.2.2 Winding Number RUIe sansnn 3.3 Polygon Filing... 3.3.1. Introduction, 33.2 Pixel Connectivity 34 Boundary Fill. 3.4.1 Working Mechanism... 35 34.2 Algorithm... 36 34.3 Prosand Cons... 36 344° Example..... OT 35 Flood Fil. 38 gee Table of Cor P ten Computer Graphics (MU) — conte 3.5.1. Working Mechanism... so . a) 352 Algorithm . . 35.3. Pros and Cons... " a 38 Optimization... Ms Ce 3.7.4 Working Principle... 4 arn 37.2. Algorithm a tee 349 37.3 Pros and Cons. 3.7.4 Example... Bg 38 Seed Fil vs Sean Line Algorithm ...unnion-nsesnsn on Bg ese Chapter 4:_ Two Dimensional Geometric Transformations 4-4 0485 SRapier A _Two Dimensional Geometric Transformations tts syllabus : 44 42 43 44 45 48 Basic transformations : Translation, Scaling, Rotation, Matrix representation and Homogeneous Coordinates, Composis| transformation (Other transformations : Reflection and Shear Introduction Matrix Operations. 424 Matrix Representation... 4.22 Matrix Properties. nnn 423 Determinant of Matrix 4.2.4 Multiplying Two Matrices... Translation... Rotation... 4.4.1 Rotation about Origin... 4a2 Rotation with Respect to Reference Point....... Scaling . 4.5.1 Scaling with Respect to Origi 45.2 Scaling with Respect to Reference Point... 45.3 Uniform vs. Non-Unitorm Sealing... Matric Representation and Homogeneous Coordinates 48.1 Translation... 46.2 Scaling... 46.3 Rotation....... 4.7 Compost Transformation... WE computer rnin MU) _ 5 “Table of Contents an 47.4 Successive Transformations... 42 4.7.2. Examples.. 23 48 Refedton.. so MOT 48:1 Reflection about X - Axis (Y = 0 Line)... 428 482 Reflection about Y - Axis (X = 0 Line) 2B 483 Reflection about X = Y Avis... 4-28 48.4 Reflection about X=—Y Axis 4-30 4.8.5 Reflection about Origin... 430 4.86 Reflection about any Line y= mx +c... 431 48.7 _ Reflection about a Line Parallel to X-Auis.... 488 Reflection about a Line Parallel to Y-Avis. 49 Shearing, 49.1 X-Direction Shearing... 4.92 Shearing about a Line Parallel to X- 49.3 Y- Direction Shearing . 4.9.4 Shearing about a Line Parallel to Y-axis. 410 Solved Examples... Chapter ‘Two-Dimensional Viewing and Clipping 5-1 to 5-39 [Syllabus + Viewing transformation pipeline and Window to Viewport coordinate transformation (Clipping operations: Point clipping, Line clipping algorithms : Cohen-Sutherland, Liang : Barsky, Polygon Clipping Algorithms : Suthertand-Hodgeman, Weiler-Atherton. BA 2D Viewing anne BA 5.1.1 Viewing Transformation Pipeline 5.1.2. Window to Viewport Coordinate Transformation $2 2D Clipping. 5.3 Point Clipping.... 5.4 Line Clipping... 5.4.1 Cohen - Sutherland Line Clipping Algorithm 8.4.4.1 Working Mechanism. 54.4.2 Algorithm. 5.4.1.3 Pros and Cons.. 55 Table of Conteny, Computer Graphics (MU) x 5.4.1.4 Examples seen “4 542 Liang - Barsky Line Ciping Algorithm i 5.4.2.1. Working Mechanism... 4 5.4.2.2 Algorithm... 5.4.2.3 Pros and CONS... 54.2.4 Example... Polygon Giipping .. 55.1 Sutherland-Hodgeman Polygon Clipping Algorithm... 55.1.1 Working Mechanism... 85.1.2 Algorithm... 5.5.1.3 Pros and CONS... 55.1.4 Examples... 5.5.2 Weiler- Atherton Polygon Clipping Algorithm, 55.2.1 Working Mechanism. se 5 55.2.2 Pros and Cons. 5523 Examples... BT Chapter 6: 3D Transformation 6-4 to 6332 Syllabus : Introduction, Translation, Rotation, Scaling, Reflection, Composite transformations, Rotation about an arbitrary axis et 62 63 64 3 Transformation... . 6.1.1. Introduction... 64.2 3D Geometry. Transiation SelM wenn 6.3.1 Scaling with Respect to Origin... 632 Scaling with Respect to Reference Point Rotation 64.1 Rotation About Principal Avis... 842 Rotation About Line Parallel to Principle Axis 64.3 Rotation About an Arbitrary Axis... Refiecton..... Shear. W Computer Graphics (MU) 1, 6.7 Composite Transformations. = Table of Contents 619 6.8 Solved Examples .. sn 620 ee ———eeemeeeeeeee Chapter 7: Projection TA 107-27 Syllabus : Projections-Parallel, Perspective. (Matrix Representation) 7.4 Introduetion.. 72 Parallel Projection ...un 7.2.4 Oblique Parallel Projection 7.24.4 Cavalier Projection 7.2.4.2 Cabinet Projection 7.22 Orthographic Parallel Projection. 7.2.2.1 Multiview Parallel Projection. 7.2.2.2 Axonometric Parallel Projection... 7.3 Perspective Projection... 7.3.1 Vanishing Point. — 7.3.2 Single Point Perspective Projection. 7.3.3 Two Point Perspective Projection. 7.34 Three-Point Perspective Projection..... 7.4 Parallel vs. Perspective Projection... 7.5 Orthographic vs. Isometric Projection 7.6 Solved Examples... Chapter8: Curves and Fractals Syllabus : Bezier Curve, B-Spline Curve, Fractal-Geometry, Fractal Dimension, Koch Curve 81 Curves. 8.1.1 Introduction 8.4.2 Interpolation and Approximation 84.3 Continuity... 8.1.3.1 Geometric Continuity..... 8.1.3.2 Parametric Continuly.. 8.1.4 Bezier Curve. 81.5 B-Spline Curve 81.6 Bezier Vs. B-Spline CUMVE nnn Table of Conten, Bg XE Computer Graphics (MU) cannes moe eee cary BZ FFACHAIS ener aan ventas 8.21 FractalGeomety. ° a 8.22 Fractal Classification . 2 8.29 Fractal Dimension. 3 824 Koch Curve 4 8.2.5 Applications. 9-4 toog [Syllabus : ; : Visible Surface Detection : Classification of Visible Surface Detection algorithm, Back [Buffer method, Area Subdivision method surface detection method, Depth a 844 Introduction nn 9.2 Classification of Visible Surface Detection Algorithm, 9.3 Back Surface Detection Method... 94 Depth Buffer Method. 9.5 Area Subdivision Method... Chapter 10: Animation 10-1 to 10-9 Syllabus Introduction to Animation, Traditional Animation Techni iques, Principles of Animation, Key framing : Character and Facial [Animation, Deformation, Motion capture 10.1 Introduction 104 102 Traditional Animation Techniques, 103 104 oo OA ples of Animation .. 10-2 Keyframing : Character and Facial Animation, 105 Deformation, 10.5.1 Rigid Body Transformation 10.5.2 Deformation... 10.2.1 Parameterized Deformation, 10.8.2.2 Lattice Deformation......... 10.5.2.3 Composite Deformation... 10.6 Motion Capture, ‘Model Question Paper (End sem.) Introduction and Overview of Graphics System 3 Syllabus Definition and Representative uses of computer graphics, Overview of coordinate systom, Defnton of scan conversion, rasterization and rendering. Raster scan & random scan displays, Architecture of raster graphies system with display processor, Architecture of random scan systems. 41.1 _ Introduction Computers have been a core part of efficient and economical image generation and manipulation. Advancement in computer technology has made the graphics processing faster and economical. Today, the scope of term computer graphics is not limited to what kind of scenes can be displayed or what kind of images we can generate with the help of a computer. In broad mean, computer graphics has covered almost every field, like education, animation, entertainment, film industry, fine arts, gaming, engineering, training, advertisement, medicine, statistical representation and many more. Computer graphics is a process of generating, manipulating, storing and displaying images. A person is more interested to study monthly or annual statistics in the form of graphs, tables or charts, instead of plain boring textual data. Computer graphics is the key component for presentation and user interface, Old slow and time-consuming ‘command line interfaces have been replaced by quick, fascinating Graphical User Interface (GUI). GUI provides quick and easy to use interface to the application users. Due to inefficient and expensive hardware before a couple of decades, application areas of computer graphics were limited. But with evolution in a digital system and personal computers, there is a flood of inexpensive graphics-based applications and devices. - With the help of GUI, multiple users can easily control simultaneous applications like text editors, code editors, entertainment tools ete. Computer graphics was initially started with displaying data on the hard copy display devices like plotters, printers and then Cathode Ray Tube (CRT). Today, the applications of computer graphics have been extended to display devices like Light Emitting Diodes (LED), Liquid Crystal Display (LCD), electroluminescent display, flat CRTs ete, ‘To generate a realistic scene, computer graphics performs various operations on objects such as translation, rotation, sealing, reflection, shearing, hidden surface removal, texture mapping, shading. Operations of computer graphics can be classified as follows : 1. Geometry : How to draw and represent the scene. 12 troduction and overview Of Graphics Introduction and Overs phics &| Computer Graphics (MU) 2, Animation : How to add dynamie content in the srone: 8. Rendering : How to add realistic light in the scene. 4, Imaging + Image acquisition and image editing. 1.2 Graphics Primitives an conversion. On the monitor, graphics primitives are generated using sc g the boundary of the primitive shape = Sean conversion is the process of turning ‘on’ or ‘off’ the pixels alon tation based on the jn; scan conversion algorithm performs the comput - For each pixel on the screen, ed ‘on’ parameters of the primitives and determines which pixel is to be turns ~ Few basic primitives are discussed in following subsections. 1.24 Lines = The line is a collection of points along a straight path. Typically, the line is described by its two endpoinis (& ¥,) and (2 ya). Intermediate points on the line are calculated by line generation algorithm. Polka, Ya) ; Fig. 1.2.4 : Representation of line ~ Given the endpoints P,(x,, ¥4) and P(x y5), any poi ; » Yo) any point PC ; intercept formula as follow, *% ¥) on the line ean be computed using the slit ~ Itis evident from Fig, 1.2.1 that the slope of the line is, m= Yeo ax" x— x, YF computer Graphics (MU) Introduction and Overview of Gr phics System ~ Lines with different slopes are shown in Fig. 1.2.2 Fig. 1.2.2 : Lines with different slope 1.2.2 Line Segments ~ Aline segment is the part of the line. Curves are often approximated using small line segments, Almost any shape can be approximated by line segments. ~ Like line, a line segment is also bounded by some start and endpoints. 1.2.3 Vectors In geometry, a vector is defined by two properties : direction and the magnitude. ‘We can represent a vector as a directed line, which grows from tail to head. at Fig. 1.2.3 : Vector representation ‘Two vectors are said to be same if, they have the same direction and magnitude. A vector in 2D is defined as v = ai + bj, where (i, j) represents the direction and (a, 5) represents the ‘magnitude of a vector in x and y direction, respectively. Given the two points A(x, y,) and B(x, yo) the vector in the direction from A to B is defined as, v = AB=B-A=(x)-x,y9-y) ~ And the gradient of vector AB is given as, Hot] = YGq-xp? + Q-y)? Ex. 1.2.1 ; Compute the direction and magnitude of the vector AB given the points A(2, 4) and B(7, 8). Soln. : The direction of the vector is computed as, v = AB=B-A=(x)-2y9-y,) #(7-2,8-4)=66,4) The magnitude of the vector is computed as, Well = \a=x)?* Gp- ype Vee aa Vii = 64 computer ing in the direction 6i + 43 , the vector is Thus, the vec m* ern the points and vector is shown in the Fi Fig. P. 4.2.1 : Geometric interpretation of vector 1.3 Applications of Computer Graphics Computer graphics has its root almost everywhere. In this section, we will discuss a few applications which are used in day to day life. 1. Computer-Aided Designing : One of the fundamental applications of computer graphics is designing ani modeling of objects, which is known as Computer-Aided Design (CAD). CAD methods are common ia designing models of machines, buildings, crafts, computers, automobiles, textiles, and many other products CAD packages allow designers to make wireframe or solid models of components. Wireframe display gives flexibility to designers to quickly see the effects of changes in shapes and adjust it. can display different views of objects. Standard sl the electronic cireuit design packages. display is useful for testing the designer to see into the interior of Wireframe design of the car and mi cle oF system, Ales lkonindow vow of the an eeviOUr of ‘the vehicle and to wat wire Ce is inner components during motio? objects are shown in Fig. 1.3.1 WF computer Graphics (MU) t Micon and Overviow of Graphics System 2 Virtual reality : With the help of computer graphics, itis possible to simulate various virtual environments which look seamlessly similar to the real world, Such environments help to train the person without providing them with physical resources. Doctors can be trained to operate a patient without operating on the ‘actual physical body. The pilot ean be trained to fly the aircraft without physically seating in the craft. One such vehicle navigation simulator is shown in Fig. 1.3.2. It is also possible to have simulated “walk” in and around the home using virtual reality Fig. 1.3.2 : Virtual vehicle navigation system 3. Presentation graphics : Another major application of computer graphics is presentation graphies. It is used ‘to produce diagrams, tables and charts for reports or presentations. Presentation graphics are commonly used to summarize research or survey data. 3D graphs are sometimes used to provide a multi-angle analysis of statistical data, They provide a more intuitive and more attractive presentation of data relationships. © Vanilla @ chocotato © sranbeny © Mint chocolate chip Fig. 1.3.3 : Graphical representation of the survey 4. Computer art : Computer graphics play @ major role in fine art and commercial art. Various computer methods, symbolic packages, software packages, CAD packages, ete. are used by the designer to generate computer art. Using such packages, the artist ean easily design shapes and can add motion. Morphing is the common graphics processing method used in animation. It is a process of transforming one object into another. Morphing is being used in movies to transform one shape to others, e.g. human to tiger, car or any random shape ete. duction and overview of Graphics Syste, ju Intro W computer Graphies (MU) Fig. 1.3.4: Morphing ; / / film industries for making animation ang hows ete. Sometimes the character itse 1 scene and synthesized objects, 5. Entertainment : Computer graphics are commonly used in ‘cartoon movies, for providing special effects to the scene, television s] is displayed as graphics object, and sometimes it is combined with the real Fig. 1.3.5 : Use of computer graphics in animation and movie 6, Education and Training : Another promising application area of computer graphics is education and training. Nowadays in the market, many educational toolkits are available for child education, They can leem through videos and animations, Thousands of simulation software are available to understand the behaviour of certain processes or environment or response of the system. Trai ining a person for vehicle driving using such simulators saves his time and efforts. YH computer Graphics (MU) 17 Introduction and Overview of Graphics System ee 11. Visualization : Data produced from many research applications is too ig to analyze on paper, Representing data in form of graphs, charts or some other visual form may help to understand the resulta in quick time, Colour coding can also provide a clue to understanding the data. For example, plain satellite image may not bbe as useful as ifit is segmented using different colors i.e.green indicating forest region, blue indicating water region, black indicating mountains and roads, grey indicating soil etc. HiPALorPAUSECAN Onshe Fig. 1.3.7 : Satellite images with augmented data Graphical User Interface : The old computer systems were mostly command-based. The userhad to write commands to perform any task. But with the introduction of computer graphics, things have changed. People get more interested in the graphical user interface. Nobody would like to remember or write commands. GUI provides an easy to use interface, with more accuracy and quick access time. GUI packages allow to design and interact with multiple windows like menu-based selection, mouse and keyboard-driven commands, zooming of objects ete. simultaneously. Fig, 4.3.8: Graphics User Interface 1.4 Overview of the Coordinate System 1.4.1. Introduction ‘The coordinate system determines how and where to display objects. Multiple coordinate systems can work in parallel, Objects in real world are represented using the world coordinates whereas an object displayed on a display device is specified in device coordinates. Viewing coordinate system specifies the position of the viewer. vi Graphics System Introduction and Over! aw of ‘Computer Graphics (MU) 1 Intro cad with a Cartesian coordinate system Special-purpos, Gonorally, graphics packagos are des packages may allow use of many other coordinate systems. esinn reference frames are use has n pon or chair, with their actual dimensions, called modellin nates ie. [mer Yme Once the object is designed, eld coordinates i.c. (ye Yo! 41 to construct and display @ scene. We cay g coordinates, or loca) several difforent Cart ‘ve can place it into gq = Ingeneral, cerente objects, sucl coordinates or master coord! position in the scene using wor t dovices, so it must be mapped to the sod coordinate (Xpe Yno) appropriate proper dimension to render jt ~ ‘The scone may be displayed on different ‘usually between 0 and 1, This World coordinates aro then represented in normaliz rakes the system independent of the various display devices. sealed to fit on any size of the displ inate is known as device coordinat = These normalized coordinate can be easily lay by multiplying it with a proper scaling factor. This new scaled coord Le (xger ¥de- Fig. 1.4.1 shows ‘sequence of coordinate transformations. One Ye) > Keer Yoo) Fner Yne) > der Yao) ES se ®@) Modellin ete World coordinates. Normalized coordinates Device coordinates Fig. 1.4.1 : Coordinate transformation ~ Ifnormalized coordinates are mapped int devi ipped into a square ares ice, ly and nel inate a of the outy i ‘ ii aa iB soho put device, then only appropriate scale aspect ratio are maintained. On non-square display device, the shape of object deforms. 1.4.2 Cartesian Coordinate System ~The cartesian coordinate syste mn ‘ son L Reese ea ae spatial location in a plane or space to wernt + we need two-dimensional coordinate syste aks ein nail "ms, which represents point vsi point using To represent a point in the space, we need a tht ‘ing (x,y, 2) triplet. Axo in the Cartesian evordines inal = Various shapes like circle, ellipse, line ete, are mathematical formula. The paereene nde The atte - are represented in i 4 a eordinate & Cartesian coordinate’ system using * system. system is als 0 known as a rectangular coordina! ies (MU) . ¥F_Computer Graphics (MU) +9 Introduction and Overview of Graphics System ~The cartesian coordinate system specifies the physical dimensions of objects, By conventions, X, Y and Z-axis represent the length, height and depth, respectively. Fig. 1.4.2 describes 2D and 3D Cartesian coordinate systems, Pybe¥9) % LAP OV) 1! ‘. Pobte¥e) (a) 2D coordinate system (b) 3D coordinate system Fig. 1. 2: Cartesian coordinate systems 1.4.3 Polar Coordinate System ‘The polar coordinate system is also known as a circular coordinate system. It uses the distance from origin and angle with the horizontal axis to define the coordinates of the point. Representation of point P(x, y) in polar system is shown in Fig. 1.4.8 Fig. 1.4.3 : Polar representation of point (x, y) Distance of point from the origin is called a radius. The anti-clockwise direction is considered as a positive angle. The angle is measured either in degree(0° to 360°) or in radians (0 to 2n). Fig. 1.4.3 shows the polar representation of point P(x, y) in the 2D polar coordinate system. From Fig. 1.4.3, point P makes an angle @ with X-axis and the distance of point P from the origin is r. From the trigonometric rule, coordinates of P is given as, cos = aha sin @ Introduction andl Overview of Graphics 9; WF_Computer Graphics (MU) So, x = reont y= rain useful in describing motion in objects and the human body, Objects and body gry = This coordinate system is coordinates. mado up of joints and motions are best doseribed by polar 4.4.4 Sphorical Coordinate System Elovation Fig. 1.4.4: Spherical coordinate system The 8D polar coordinate system is also known as a spherical coordinate system. - The coordinate of the point is parameterized by two angles and distance from the origin. Angle with the ‘The X-axis is called Azimuth and angle with Y-axis is called Elevation. ~ Fig. 1.4.4 shows the spherical coordinate system. The angle in the counter-clockwise direction is considered positive. - Spherical coordinates are given as, x " rsin@cos 4, 0<0 Intensity Fig, 4.7.3 : Basle video-controllor refresh operations = High-quality display’ system uses two frame buffors, so that one buffer can be used for refreshing while other is being filled, Then both buffors switch tho rolo, This mechanism is usoful to achieve real-time animation because it does not waste time in relonding the buffor. = Sometimes the video controller contains a lookup table, Lookup table provides a fast mechanism for changing pixel intensity. ~ Pixel value itself in the frame buffer is used to access tho intensity value from the lookup table. We do not need to control CRT beam intensity if the lookup table method is used. eo ee 7 WF _computer Graphics (MU) 127 Introduction and Overview of Graphics System wo Daens Fig. 1.7.2 : Architecture of a raster system with a reserved memory area for frame butte In some system, the origin is set at the bottom left location of the screen. X coordinate increases from left to right and Y coordinate increase from bottom to top. In some system, the origin is set at top left comer, Y coordinate increases on moving from top to bottom. The scan line is accessed by specifying the Y coordinate. — Fig. 1.7.8 shows the operation of the video controller. Two registers are used to store the pixel location (x,y). The initial value of x and y are set to 0 and Yznax Tespectively. — Intensity value from the frame buffer is retrieved from the current (x, y) location. After painting each pixel, x register is incremented by 1 and the process is repeated until x value hits to Xmuax- After processing all pixel on the current scan line, the content of x register is set to zero and y is decremented by 1 and video controller process the new scan line in the same way. On reaching to (pax) 0), the controller resets the value of register pair to (0, ymax) and repeat the procedure. The typical refresh rate is 60 frames per second. In this discussion, we assume that the origin is at the top left corner of the screen. |—+ intensity Fig. 1.7.3 : Basic video-controller refresh operations High-quality display system uses two frame buffers, so that one buffer can be used for refreshing while other is being filled. Then both buffers switch the role. This mechanism is useful to achieve real-time animation because it does not waste time in reloading the buffer. - Sometimes the video controller contains a lookup table. Lookup table provides a fast mechanism for changing pixel intensity. ~ Pixel value itself in the frame buffer is used to access the intensity value from the lookup table. We do not need to control CRT beam intensity if the lookup table method is used. 7 1 Introduction and Overview of Graphics Sig, Computer Graphics (MU) Architecture of Random Scan Systems Ara t of display processor and memory unit for random sean system is sone i Mg lay ” tation presvam roedaa in system memory. Graphies package translates the graphic nin, cori ion program into a display file. Display file is also stored in systom memory venom ~ Display processor accesses the content of the display file and renders it on the monitor ; . _ ~ Display processor retrieves one by one command from the display file and draws it on screen. Disp Processor in a random-tenn system is also called graphics controller. wn] [Bem a cous] [immo] [eee Monee Shen Be Wo Doveee Fig, 4.8.1 : Architecture of a simple random sean system ~ Random-scan devices render the scene using short * lines. Electron beam tracks the line position direct, rather than going through each pixel on the screen, ‘The entire scene is defied using segments of the line in the application program. Line segments are defined by ‘ pair of endpoints. Voltage is adjusted to deflect the electron beam across the line segment, 4 Whats computer graphics? a2 aa aa Enlist the classes of operations of computer graphics State and explain the applications of computer graphics, Define the terms: Computer Graphies, Scan conversion, 9-6 Why the border ofthe object dleplayed on the monitors 8 Write short note on vector, pixel, resolution, aspect ratio, frame buffer reen is zaggy 7 2-7 Find the direction and magnitude ofthe vector joining points AG, 8) and 8(7, 4), 8 Explain how pees ar related tothe dapay memory 2.9 Find the ize ofthe frame buiter forthe system eu 10 Explain the concept of odd and even field in an int G11 State the advantages end disadvantage Q.12 Explain the way of computing pixel posi 13 Explain the explicit formula of ne drawin terlaced display, f random scan display, nS using the slope-intercept formula, 9 gag Output Primitives ao ‘Scan conversions of point, line, circle and ellipse : DDA algorithm and Bresenham algorithm for line drawing, ‘midpoint algorithm for circle, midpoint algorithm for ellipse drawing (Mathematical derivation for above algorithms is expected) Aliasing, Antialiasing techniques like Pre and post fitering, super sampling, and pixel phasing), 2.4 Scan Conversion 2.4.4 What is Scan Conversion? Scan conversion is the process of representing continuous graphics as a collection of discrete pixels. Each pixel on the monitor screen is either turned on or off according to the picture definition stored in a frame buffer. ~ Scan conversion is widely used in CRT, Flat-panel, TV set and other types of display devices to display. — Implementation of such algorithm varies from one computer system to others. Some algorithms are implemented in software, some are implemented in firmware, and some are the combination of hardware, software and firmware. Algorithms implemented in hardware scan converts the objects quicker than software. - Application program takes these parameters as input and generates all the pixels representing the shape. ‘This process is called scan conversion. ~All the points on a line can be generated using DDA or Bresenham’s algorithm for given endpoints. ~ Most of the monitors and television sets support raster scan display. In raster scan devices, picture definition is stored as a discrete pixel value. The entire scene is defined by a set of intensity values for each pixel on the screen. - Computed pixel values may be a fraction, so it needs to round off to show it on a monitor screen. ~ As shown in Fig. 2.1.1, computed pixel values (10.8, 10.8), (12.6, 11.7) and (13.8, 10.4) are rounded to nearest integer values (11, 11), (13, 12) and (13, 10). "4 "3 2 2647 “ IC ae fiaane Bal aoe olitentel oe] % 10 Ww 12 13 4 Computed real value of pals Round of value of pixels’ Fig. 2.4.4 : Conversion from actual value to rounded value ————— ow Output Pri 2 a Computer Graphics (MU) 2.4.2 Line and Line Segment sg decribed by its 100 end po path, Typically, the line 1 ration algorithm. Poi i i straight - line is a collection of points along a straig” any) ‘and (xy ¥_)- Intermediate points on the line interpretation of line joining end points Py and Pp are depicted in Fig. 212 ~ see Polka, Ya) Fig. 2.1.2 : Representation of line — Given the end points P,(xy, ¥1) and Pp(2p, ¥2), any point P(x, y) on the line can be computed using the slope intercept formula as follow. - Ibis evident from Fig. 2.1.2 that the slope of the line is, _ dy Yar BS Gx amy ~ Let ‘c’ represents the Y-intercept of the line. Given the x-coordinate, the value of the corresponding y-coordinate of any point is computed as follow : y= mite ~ Ahorizontal line has slope 0. The line bisecting the first quadrant has slope 1. As F i 7 . cee : " increases, the slope increases. The slope of the vertical line is co, ‘ore soa flioernxe - Lines with different slopes are depicted in Fig. 2.1.8. = Aline segment is the part ofthe line. ORen shape can be approximated by line Me, ee AT? approximated using emall line bE ot ant ~ Like line, the line segment is alao Ee ee a ED WF computer Graphics (MU) 23 ‘Output Primitives: 2.1.3 Qualities of Good Line Drawing Algorithms. = When we draw a line on paper, it looks smooth and continuous. But due to the grid structure of monitor, when the line is rasterized, it looks zig-zag except horizontal (m = 0), vertical (m =») and diagonal (m = 1) line. ~ Distance between pixels also changes with orientation, and hence the brightness. ‘An ideal line should have the following properties : ~ It should interpolate both the endpoints. = The brightness of the line should be independent of the orientation of the line. - It should appear straight and smooth, = It should be drawn quickly. - Allproperties are satisfied when we draw lines on paper. But when we rasterize it on the monitor, most of the properties do not hold, ~ On the monitor screen, vertical and horizontal lines are displayed with maximum intensity; the brightness of inclined line changes with orientation. O O| Q O ©) je |e ee ©) OOOOO Cee Line with afferent intensities, Line with different orientations Fig. 2.1.4 : Line with different intensities and orientations. ~All properties are satisfied when we draw them on paper. But when we rasterize it on the monitor, most of the properties do not hold. = On the monitor screen, vertical and horizontal lines are displayed with maximum intensity; the brightness of inclined line changes with orientation 2.2 _Line Drawing Algorithms Line generation or scan conversion of the line is the process of turning ‘on' or ‘off the pixel along the line path, In this section, we will discuss the following line drawing algorithms, 1. Digital differential analyzer 2. Bresenham's Line Drawing Algorithm 2.2.1 DDA Line Drawing Algorithm af ie he BbaaVanlages of DDA algonibn? pe RS | 7 Output Pritt 2.2.4.1. Working Mechanism er (DDA) is a simple, + horizontal or vertical displace culated using the slope. (ie. m < 1), increment g algorithm. ital line scan converting val and the coFFespond, sment is set to unit inte — Digital Differential Analyz increment = Inthe DDA algorithm, either ispl { for other direction is cal ay ar . ‘i in the X-direction is set to 1 ay Ifthe line makes an angle less than 45° with X-axis corresponding Y is computed. — And if line makes an angle greater th and corresponding X is computed. increment in both the directions is s erement in the Y-direction is set tg, an 45° with X-axis (ie. m > 1), int - For line with slopem = 1, et to 1. — Fig. 2.2.1 shows the lines with different orientations. Yo Ye a Mi eo Y my % {@) Line with slope |m| <4 {b) Line with slope |m| = 4 (c) Line with slope |m]>1 Fig, 2.2.4: Lines with different orientations — Almost all recent monitors support integer coordinate system. Only integer movement is possible in xy direction. It is not possible to draw a pixel at position (2.3, 5.6), the system either rounds up or round dova coordinate values and then display the point. = We will derive the equation to draw a line in the first quadrant. - Another assumption is that we will process the line from left to rig is intui i p right. It is intuitive to derive a line i other quadrant just by changing the sign of increment values. ra ae ’s consider that 4x and Ay are the increments in x and y direction, respectively. Value of x ao! 7 Let's co ae y 7 tively. New value = Old value + Increment Xeon = mt ax Ye+1 = Yer dy We will discuss three cases. Case -1; Slope is less than 4 (|m| < 1) When the slope is less than 1, Ax is set to the unit j computed. ont in Fig. 2.2.5 terval, ie, Ax = : NS 4x= 1 and corresponding y-coordinst! * 2 shows the actual line and the rounded of locations ofa pixel th ‘on the monitor, grid. ee Nae wis W_Computer Graphics (MU) 25 Output Primitives 0%, 1, Round (yy # mp (442. #2) O- Oye tyem \ an (x Round (1) (#2, Round (yy #2m)) Fig. 2.2.2: Line with m| <4 From equation of slope, So coordinate value for next pixel is given as, Mei = Ht AKeK tH] Yee1 = Yetayey+m Value of m is real number, so yi. , may be real number. Hence, every time after adding m to y,, answer is, rounded to nearest integer. Ifthe line is processed from right to left, the value of x and y decreases in every iteration. So, Ax is set to—1 and Ay is set to-m. In that case, coordinate values for next pixel is given as, z Meer = thea aod Veet = Yet Aye ym Case - Il: Slope is greater than 1 (|m| > 1) When slope is greater than 1, Ay is sot to unit interval, ie., Ay = 1 and corresponding x-coordinate is computed. (Roun + hn) in (+ (Um). y) XI OW) | (Round (+ (tm). i) Line with [m| > 4 OUIbUt Prin Se 2-6 N¥_computer Grapes (WU) _ From equation of slope, ay m = Ax “Ax 1 ox = Coordinate value for next pixel is given a8, 1 Neer = Het aM vert = Tet AVe et? i iteration. Hence, Ie the line is processed from right to left, the value of x and ¥ decreases in every iterati bring to (-=;) and Ay is set to-1. In that case, coordinate values for next pixel is given a8, 1 Men = Met ARE Yea = Wet AV=IK? Case - Ill : Slope Is 4 (|m| = 1) When slope of line is 1, ic. line makes an angle of 45° with X-axis, we increment both coordinate value by! So, Ax = Ay = 1. (+2402) Gea) (+ 1K 1) Fig. 2.24 : Line with [m]=4 Coordinate value for next pixel is given as, Age = tne 41 Yes = Yetdy=y, +1 If the line is processed from right to left, in thy ‘hx and Ay are set to-1. at case, the value of x and y decreases in every iteratiot * computer Graphics (MU) 27, Output Primitives In that case coordinate values for next pixel is given aa, Nee Ft dee 1 Yas1 = Yetdyeynd ‘Table 2.2.1 shows the sign and value of x and y increments to draw a line in any quadrant. Table 2.2.4 : Generalization of DDA line drawing algorithm ss __| Ifprocessed from left to righi Magnitude of Slope |} — ee re ME [m| <1 1 m 1 [m| >1 Vm 1 4 [m| <1 1 -m -1 m [m| >1 Vm -1 vm 1 Im| <1 1 m -1 -m 3 [m|>1 -Vm 1 Um =1 |m| <1 1 -m -1 m 4 |m|>1 Vm =l -Vm 1 2.2.1.2 Algorithm Steps of DDA Line Drawing Algorithm : Step 1: Read two endpoints (xy, y,) and (xz, yo) Step 2: Compute horizontal and vertical differences as, dx = x-% dy = Ya~Vy Step 3: Set number of steps to N = max (| dx], |dy|) Step 4: Repeat step 5 to step 8 N times. Step 5: If |dx| > |dy| and x, |dy| and x, 2x2, set increments in X and Y-direction to (-1) and (-m), respectively. Step 7: If |dx| < |dy| and y, 1, eo set Ax = /m = 0.67 and Ay = 1. So, Xeon = mt Axe +067 Yeo = Wet Ave yt] Table P. 2.2.1 shows the calculation for required pixels, Table P. 2.2.1 : Calculation for required pixels Peis 0| ©,0) | 0+067=067 O+1=1 1 1| Gv | 0o67+067=184] 14+1=2 (1,2) | 184+067=2.01] 2+1=3 1 2 2 3| @3) |201+067=268| 3+1=4 3 4| @,4) |268+067=335| 4+1=5 3 5| @,5) |385+067=4.02| 5+1=6 4 6| 4,6) - = - In Table P. 2.2.1, column 2, i.e. (xy, ¥,) are the points to be displayed. They are shown in Fig. P. 2.2.1. lI o723456 o1234656 Line on paper between (0,0) to (4,6) _Line on monitor between ine on pap (0.0) to (4,6) (0.0) 10 (4.5) Fig. P. 2.2.1 : DDA line between points (0, 0) and (4, 6) Ex. 2.2.2: Draw line from point (2, 2) to (10, 7) using DDA line drawing algorithm, Soln. : Let's take, (xy, ¥y) = (2,2)and (xp, yq) = (10, 7) Output Prin, Computer Graphics (MU) Y Yams, 1H% 8 0,625 Slope ofline = m= yy, *]0=2 ax = Land 4y =m Line is in first quadrant, itis growing from left to right and slope |m] < 1, $9 6° 8 So, Xa et AReK HL Year = Met AY ey + 0.625 Table P. 2 shows the calculation for required pixels. Table P. 2.2.2 Calculation for required pixels vis mie 0828 o| a2 2 + 0,625 = 2.625 i] @s | s+1=4 | 2625+0.625=3.25 2] 3) 44125 | 3.25 + 0.625 =3.875 3| 6&4) 5+1=6 8.875 + 0.625 = 4.5 6,5) 6+1=7 4.5 + 0.625 = 5.125 7,8) T+1=8 | 5.125 +0.625 =5.75 5 6| 6) B+1=9 | 5,75 +0.625 =6.375 7 slololalals lole (9,6) | 9+1=10 | 6.375 +0.625 = 7.000 8| 0,7) - In Table P. 2.2.2, column 2, i. (x, y,) are the points to be displayed. They are shown in Fig. P. 2.2.2. 456786 i0” The line onthe menitor between (2,2) 0 (10,7) Fig. P.22.2: DDA line betwoen points (2, 2)and (10, 7) aed dL IE | 46678 810 The line on paper between (2,2) to (10,7) Draw ating rom ACD, 2/10 B(6, 8) sing DOA in drawing algorith m rithm, Soin. : Let's take, (x,y) = (10, 2) and (xp, y,) aS Se WF_Computer Graphics (MU) 241 Output Primitives Slope of line = m=22—¥1_ 8-2 =x “6107 The line is in the first quadrant, it is growing from right to left and slope m < 1. It is intuitive from the line coordinates that when line proceeds from point A to point B, its x-coordinate decreases and y-coordinate increases, so set 1 dy=lendax = 3 =-067 Xa = xy + Ax = x, — 0.67 Yard = Yetdyeyg ed Table P. 2.2.8 shows the calculation for required pixels, Table P. 2.2.3 : Calculation for required pixels [esa] : 0} (0,2) | 10-067 =933 | 24123 1| 3) | 933-067 =867| 34124 (9,4) | 867-067 =8.00| 441-5 (8,5) _| 800-067 =7.33| 5+1=6 2 3 4|_ 7,6 | 733-067 =667| 6+1=7 5 (1,D_| 667-067 =6.00| _7+1=8 6] 6,8) = = In Table P. 2.2.8 , column 2, i.e. (xj, yj) are the points to be displayed. They are shown in Fig. P. 2.2.3. The line on paper between The line on the Monitor between (10,2) to (6,8) (10,2) to (6,8) Fig. P. 2.2.3 : DDA line between points (10, 2) and (6, 8) Ex.2.24: Drawaline from A (20, 10) to B (30, 18) using DDA line drawing algorithm. Soln.: - Let's take (x},y;) = (20, 10) and (xp, yp) = (80, 18) 242 yor¥1 18-10 Slope ofline = M=yy=x, “30-20 = land Ay=ms seni going om et to ight ante [a <0 80 28 ay=m=0g, Rye 2 Xt OREM AH Line is in first quadré = yp tdye net 08 Ykel 24 : Calculation for required epee oases oe 0 | (20,10) 2041221 10.0 + 0.8 = 10.8 iL 1 | @1,1) 2141222 10.8 + 0.8 = 11.6 12 2 | (22,12) 2241223 11.6 + 0.8 = 12.4 12 3 | (23, 12) 23+1=24 12.4 + 0.8 = 18.2 13 4 | (24, 13) 2441225 13.2+0.8 = 14.0 14 5 | (25,14) 25+1=26 14.0 + 0.8 = 14.8 15 6 | (26,15) | 26+1=27 14.8 + 0.8 = 15.6 16 7 | 27,16) 2741228 15.6 + 0.8 = 16.4 16 8 | (28,16) 28+1=29 16.4 + 0.8 = 17.2 17 9 | (29,17) | 29+1=30 17.2 + 0.8 = 18.0 18 10 | (80, 18) - _ = In Table P. 2.2.4, column 2, ie. (x,, ¥,) are the points to be displayed. They are shown in Fig. P. 2.2.4. 1e|_ LT 7 [ 16 15] 14] 2 12] 1" 10) 20 21 22 23 26 25 26 27 26 26 30 The line on paper between (20,10) to (30,18) The line on the Moni Fig. P. 2.2.4: DDA line b a aon 'tween polnts (20, 10) and (30, 18) Ex 2.2.5: Drawatine from A (0, 0) B (5, ~) using the DDA ine rawing algorithm, Sol Lets take, Gy ¥y) = (0,0) and (ep y4) 2)=

You might also like