Docsity

Computer Graphics Notes – Transformations, Line Drawing, Clipping & 2D/3D Graphics, Study notes of Computer Graphics

Partial preview of the text

Download Computer Graphics Notes – Transformations, Line Drawing, Clipping & 2D/3D Graphics and more Study notes Computer Graphics in PDF only on Docsity!

Computer Graphics Computer Graphics is the branch of computer science that deals with creating , manipulating and displaying images using Computers . Tt is used in games, animation, CAD / CAM, simulations, scientific visualizotion, UL/UX, etc. sk, Transformations Transformations axe used to change the position, size or shape of objects in o graphics Scene . They axe of two dypes: (i) 2D Transformations (ii) 3D Transformations G)) 2D Transformations ¢ Translation: Moves an object from. one position to onother . Gch y) = (ett, y +ty) . Scaling : Changes the size of on object . feat J Gi) = (Sax, 5-4) Ha e Rotation: Rotates an object about the origin. x! = x cos® — y sin® — y! = x sin@ + y cosO e Reflection: Flips an object about an axis. i | xemople. About X-axis: (x!, y/) = (x, -y) Rati About Y-axis: (x', y’) = (-x, y) (ii) 3D Transformations Y ¢ Translation: (x’, 4’, Z)) (Gee, yt ty, z+t) ° Sealing : (x),y472') = (Gases, Sy ey, o-) * Rotation: About X-axis Z y’ = y cos@ — zsin® va z’ = ysin@ + z cos® Xx Similarly about Y-axis and Z-axis. ° Reflection : About coordinate planes . 2. Line Drawing Algorithms Line drovoing algorithms determine the set of pixels that best opproximade o straight line between two points . + DDA (Digital Differential Analyzer) Algorithm Cea, Ya) 1. Coleulate dx, dy and steps = mx (ldx|,, Id!) 2. xine = dx [steps , y-ine = dy / steps 3. Starting from (x41), plot pixels and increment . cal © Bresenham’s Line Drawing Algorithm (m4, 4) Uses. infeger arithmetic ond. decision parameter to choose the next pixel. It is faster ond more efficient than DA. 3. Line Drowing Algorithms (Contd...) * Midpoint Line Drawing Algorithm 1. Start from the first endpoint (x,,4.). 24% Y) 2. Choose the initial, decision parameter (do). fa 3. At each step, choose the pixel (E or NE) a ° fen that is closest to the true line. be 4, Update the decision parameter. £ reer Tees 5. Repeat until the second endpoint (2, yo) ES is reached. at e Applications Koy Ponts teat Pats 2 eens e Line. dro ets price Soe tas Systerns:, Cl Pees equations into pixel positions. gome development , and simulations. * DDA is simple , Bresenham is faster. + These algorithms consider only integer calculations . 4: Clipping Clipping is the process of removing the parts of an object that lie outside the viewing area (window). This reduces the amount of data to be processed ond displayed. Line Clipping Types_of Clipping Before. Clipping After Clipping a Ageienen) Oars OT aes i 1001 1000 1010 e Line Clippir fo He ee : = * Polygon. Clipping NS 0001 0000 010 ° Text Clipping Applications o1o1 100 otto Used. in windowing systems , CAD / CAM, 3D vendering , and. image processing . 5. 2D ond 3D Graphics 2D_ Graphics 3D_ Graphics « Deals with two-dimensional objects « Deals with three-dimensional objects (X and Y axes). (%, Y and Z oxes). ° Examples : Line , Circle , Rectangle A * Examples: Cube , Sphere , Cylinder 5 Polygon , Text. Pyramid , 3D Models. * Used in drawings , logos , charts , * Used in simulations , games , virtual, reality , UL design , animakion . engineering , medical imaging . TT 6 fF ! ES pee a Surnmasry Computer Graphics invelves creating and manipulating visual content. Transformations position and shape objects in 2D/3D space , line drawing algorithms determine pixel positions of lines, clipping removes unwanted parts of objects, and 2D/3D graphics help in visual representation of real-world objects in various applications . 9) Viewing Transformations Viewing transformations position and orient the world with vespect to the observer . Tips (0) Viewing (Camera) Transformation : cTransteans werlil eenglinaiee to view coordinakes . (ii) Window to Viewport Transformation : Maps a selected window (world coordinates) to the viewport (device. coordinates) . (iit) Viewport Transformation : Converts normalized device coordinates bo ockuol device coordinates (pixels) World. Coordinates View Coordinates y Yy Ves Pa R=] | Oe Frans! x| Xy (Pixels) Ya. (WH) Lat |e 1 | | Meret bennnna= 4 Transformation 10. 2D Transformations Used to manipulate 2D objects . Transformation Matrix About Translation 10 Moves an object (Te) Ty) o 41 Ty in x and y eo 6 4 divections . Scaling (Sx, Sy) | [Sx 9 ©] | Changes the size 0 Sy 0] | of on object © jo Al) Rotakion (8) cos@ -sin® O Rotates object sin8 cos8 0 counterclockwise i) 0 1] | by 6. Reflection about 1 0 07 Flips object X-oxis 0 sais 0 about X-axis oe Reflection about | [-1 © 0] | Flips object Y-axis o 4 0 about Y-oxis. oo ne] Compasite transformations can be obtained by multiplying the madrices in order. 4053D. Transformations Used to manipulate 3D objects in 3D space. Basic Transformations * Translation (Te, Ty, Te)! Moves object in 3D space. + Scaling (Sz, Sy, Sz): Changes size in 3D. © Rotation: About X,Y ond Z axes. About X-axis About Y-axis 4 ie) ie} te) cos® 0 sin® © 0 cos sind 0 0 SO © O sin® cos@ O -sin8 0 cos® O ie} io) 0 4 ° O Lo) 4 About Z~oxis Uniform Scaling cos@ -sin@ O O Ss ie) o 0 sin® cos? 0 0 ie} Ss o ° te) le) AG fe} ie} Ss oO to} (e) Oo a fo} to} oO at 3D transformations axe represented using 424 matrices in homogeneous coordinates . 412. Homogeneous Coordinates * To represent translations and other transformations using matrices, we use homogeneous coordinates © A aD point (x,y) ts represented os (x,y, 1) © A 3D point (x,y,z) is represented os (x,y,z, 4). After tronsformation , divide by w (if w#0) to get the Cartesian coordinates . Example (2D Translation) Translate point (x,y) by (Tx, Ty)- x! 1b Oi ae x x+Ty w= On teeaty gy] =f ytty a 0.0 4 eb 4 + Transformations change the position, size or orientation of objects . + Line drawing algorithms determine which pixels best approximate a line * Clipping vemoves parts of objects outside the viewing area. * 2D ond 3D graphics are used in many real-world applications like CAD, animation , simulation , games , VR, scientific visualization ond more . Applications of Computer Graphics * Computer Games © Virtual Reality © User Interface Design + CAD/CAM + Medical Imaging Education & Training © Animation & Movies * Scientific Visualization © Simulations