SAZ4C COMPUTER GRAPHICS Unit : 1-5 1
UNIT :1 SYLLABUS Introduction to computer Graphics Video display devices Raster scan Systems Random Scan Systems Interactive input devices Hard copy devices Graphics software Output primitives line drawing algorithms initializing lines line function circle Generating algorithms. 2
Introduction to Computer Graphics Creation, Manipulation, and Storage of geometric objects (modeling) and their images (rendering) Display those images on screens or hardcopy devices Image processing Others: GUI, Haptics, Displays (VR)... 3
Computer Graphics The study of computer graphics is a sub-field of computer science which studies methods for digitally synthesizing and manipulating visual content. dimensional Although computer the graphics, term it often also refers to encompasses three- two- dimensional graphics and image processing. 4
Applications of Computer Graphics 5
Video Display Devices Cathode Ray Tube Raster Scan Display Random Scan Display Color CRT Monitor Flat Panel Display Plasma Panel Display Liquid Crystal Display 3D Viewing Device 6
Interactive Input Devices Keyboard Mouse Trackball& Space ball Joysticks Data Glove Digitizer Image Scanner Touch Panel Light Pen Voice System 7
Hard Copy Devices Laser Printer Inkjet Plotter Dot Matrix Printer Electrostatic Printer Pen Plotter Rollfeed Pen Plotter 8
Graphics Software Coordinate Representation Graphics Functions Software Standards PHIGS Workstations 9
Output Primitives Points and Lines Line Drawing Algorithms DDA Algorithm Bresenham s Line Algorithm Parallel Line Algorithm Loading the Frame Buffer Line Function 10
Line Drawing Algorithms A line drawing algorithm is a graphical algorithm for approximating a line segment on discrete graphical media. On discrete media, such as pixel-based displays and printers, line drawing requires such an approximation (in nontrivial cases). Basic algorithms rasterize lines in one color. 11
Line Function Two Dimensional Line Function: Polyline(n,wcPoints) 12
Circle Generating Algorithms Standard Algorithm Polar Algorithm Symmetry Algorithm Mid-Point Algorithm 13
Eclipse Generating Algorithms 14
UNIT 2: SYLLABUS Attributes of Output Primitives Line Attributes Color and Grayscale Style Area Filling Algorithms Character Attributes Inquiry Functions Two Dimensional Transformation Basic Transformation Composite Transformation Matrix Representation Other Transformations 15
Attributes of Output Primitives 1. The line-type attribute include solid lines, dashed lines, and dotted lines. 2. We modify a line drawing algorithm to generate such lines by setting the length and spacing of displayed solid sections along the line path. 3. Attributes: 1. Line Attributes 2. Color Attribute 3. Color and Gray Scale Level 4. Area Filled Attribute 5. Text and Characters 16
Line Attributes The line and curve attributes include the current position, brush style, brush color, pen style, pen color, transformation, and so on. Basic attributes of a straight line segment are its type, its width, and its color. In some graphics packages, lines can also be displayed using selected pen or brush options. Line-type attribute: solid lines, dashed lines, and dotted lines. 17
Color and Grayscale Style 1. Grayscale images are distinct from one-bit bi-tonal black-andwhite images, which in the context of computer imaging are images with only two colors, black and white (also called bilevel or binary images). Grayscale images have many shades of gray in between. 2. A grayscale or greyscale image is one in which the value of each pixel is a single sample representing only an amount of light, that is, it carries only intensity information. 3. The color scale is a specialized label object that displays a color map and its numerical scale for color mapped or contour data plots. The color scale displays by default when creating color-filled or gray-scale contour graphs. 18
Area Filling Algorithms It determines the area connected to a given cell in a multidimensional array. Following are some famous implementations of flood fill algorithm: Bucket Fill Solving a Maze Minesweeper Fill Styles Pattern Fill Soft Fill 19
Character Attributes Text Attributes settextfont(tf) settextcolourindex(tc) setcharacterheight(ch) setcharacterexpansionfactor(cw) setcharacterspacing(cs) setcharactervector(upvect) settextpath(tp) settextalignment(h,v) settextprecision(tpr) 20
Character Attributes Marker Attributes setmarkertype(mt) setmarkersizescalefactor(ms) setpolymarkercolourindex(mc) 21
Inquiry Functions These functions allow current values to be copied into specified parameters, which can then be saved for later reuse or used to check the current state of the system if an error occurs Example: inquirepolylineindex(lastli) inquireinteriorcolourindex(lastfc) Sample Coding: inquirelinetyoe(oldlt) setlinrtyoe(newlt).. setlinetype(oldlt) 22
Two Dimensional Transformation Transformation means changing some graphics into something else by applying rules. We can have various types of transformations such as translation, scaling up or down, rotation, shearing, etc. When a transformation takes place on a 2D plane, it is called 2D transformation. Transformations play an important role in computer graphics to reposition the graphics on the screen and change their size or orientation. 23
Basic Transformation Translation: A translation moves an object to a different position on the screen. You can translate a point in 2D by adding translation coordinate (tx, ty) to the original coordinate (X, Y) to get the new coordinate (X, Y ). Rotation In rotation, we rotate the object at particular angle θ (theta) from its origin. From the following figure, we can see that the point P(X, Y) is located at angle φ from the horizontal X coordinate with distance r from the origin. Scaling To change the size of an object, scaling transformation is used. In the scaling process, you either expand or compress the dimensions of the object. Scaling can be achieved by multiplying the original coordinates of the object with the scaling factor to get the desired result. 24
Composite Transformation A composite transformation (or composition of transformations) is two or more transformations performed one after the other. Sometimes, a composition of transformations is equivalent to a single transformation. 25
Matrix Representation The fact that the matrix of a composite transformation can be formed by multiplying the individual transformation matrices means that any sequence of affine transformations can be stored in a single Matrix object. 26
Other Transformations 1. 2. 3. 4. 5. 6. Translation Rotation Scaling General Pivot Point Rotation General Fixed Point Scaling General Scaling Directions 27
Unit III Syllabus Two - dimensional viewing Window- to view port co-ordinate transformation Clipping algorithms Interactive input methods Physical input devices Logical classification of input devices Interactive picture construction methods. 28
Two - Dimensional Viewing 29
Window To view port co-ordinate transformation A world coordinate area selected for display is called a window An area on a display device to which a window is mapped is called a viewport Mapping of a part of a world coordinate scene to device coordinates is referred to as a viewing transformation 30
Clipping Algorithms Any procedure that identifies those portions of a picture that are either inside or outside of a specified region of space is referred to as a clipping algorithm or clipping 31
Line Clipping Algorithms 1. Cohen-Sutherland Line Clipping 2. Liang-Barsky Line Clipping 3. Nicholl-Lee-Nicholl Line Clipping 4. Line Clipping Using Nonrectangular Clip Windows 5. Splitting Concave Polygons 32
Polygon Clipping The output of a polygon clipper should be a sequence of vertices that defines the clipped polygon boundaries Sutherland-Hodgeman Polygon Clipping Weiler Atherton Polygon Clipping 33
Other Algorithms 1. Curve Clipping 2. Text Clipping 3. Exterior Clipping 34
Structures & Hierarchical Modeling Structure Concepts Editing Structures Basic Modeling Concepts Model Representation Symbol Hierarchies Modeling Packages Hierarchical Modeling with Structures 35
Interactive input methods Input Modes Request mode Sample mode Event Mode Initial Values for Input Device Parameters Size of pick window minimum pick distance Type and size of cursor display type of structure highlighting during pick operations range for valuator input resolution for valuator input 36
Virtual Reality Environment Interactive input is accomplished in this environment with a data glove, which is capable of grasping and moving objects displayed in a virtual scene Another method for generating virtual scenes is to display stereoscopic projections on a raster monitor, with the two stereoscopic views displayed on alternate refresh cycles 37
Physical Input Devices 38
39
Interactive Picture Construction Techniques Basic Positioning Methods Constraints Grids Gravity Field Rubber band Method Dragging Painting and Drawing 40
Interactive Picture Construction Methods Interactive picture- construction methods are commonly used in variety of applications, including design and painting packages. These methods provide user with the capability to position objects, to constrain fig. to predefined orientations or alignments, to sketch fig., and to drag objects around the screen. Grids, gravity fields, and rubber band methods are used to aid in positioning and other picture construction operations. 41
Unit IV- Syllabus Three - dimensional concepts Three dimensional display methods Parallel Projection Perspective Projection Depth Cueing Visible line and surface identification Three dimensional transformation. 42
Three - Dimensional Concepts It is the field of computer graphics that deals with generating and displaying three dimensional objects in a two-dimensional space (eg: display screen) In addition to color and brightness, a 3-D pixels adds a depth property that indicates where the point lies on the imaginary When many 3-D pixels are combined, each with its own depth value, the result is a 3-D surface called a texture. Objects are created on a 3-D stage where the current view is derived from the camera and light sources, similar to the real world. 43
Three-Dimensional Display Methods Parallel projection Project points on the object surface along parallel lines onto the display plane. Parallel lines are still parallel after projection. Used in engineering and architectural drawings. By selecting different viewing positions, we can project visible points on the object onto the display plane to obtain different two-dimensional views of the object. 44
Parallel Projection It has two major characteristics 1. Smaller as their distance from the observer increases. 2. Foreshortened: the size of an object s dimension along the line of sight are relatively shorter than dimensions across the line of sight. 45
Three - Dimensional Concepts Perspective projection Project points to the display plane along converging paths. This is the way that our eyes and a camera lens form images and so the displays are more realistic. 46
Depth Cueing To easily identify the front and back of display objects. Depth information can be included using various methods. A simple method to vary the intensity of objects according to their distance from the viewing position. Application is modeling the effect of the atmosphere on the pixel intensity of objects. More distant objects appear dimmer to us than nearer objects due to light scattering by dust particles, smoke etc. 47
Visible Line And Surface Identification Highlight the visible lines or display them in different color Display nonvisible lines as dashed lines Remove the nonvisible lines 48
Surface Rendering Set the surface intensity of objects according to Lighting conditions in the scene Assigned surface characteristics Lighting specifications include the intensity and positions of light sources and the general background illumination required for a scene. Surface properties include degree of transparency and how rough or smooth the surfaces are to be. 49
Exploded and Cutaway Views To maintain a hierarchical structures to include internal details. These views show the internal structure and relationships of the object parts 50
Cutaway view Remove part of the visible surfaces to show internal structure. 51
Three-dimensional And Stereoscopic Views 52
Three-dimensional Transformation 1. Generalize from 2D by including z coordinate 2. Straightforward for translation and scale, rotation more difficult 3. Homogeneous coordinates: 4 components 4. Transformation matrices: 4 4 elements 53
3D Translation An Object represented as a set of polygon surfaces, is translated by translate each vertex of each surface and redraw the polygon facets in the new position. T t x, t y, t z x, y, z x ', y ', z ' Inverse Translation: T (t, t, t ) T ( t, t, t ) 1 x y z x y z 54
3D Rotation In general, rotations are specified by a rotation axis and an angle. In two-dimensions there is only one choice of a rotation axis that leaves points in the plane. 55
UNIT V-Syllabus Three dimensional viewing Projection Viewing transformation Implementation of viewing operations Hidden surface and Hidden line removal Backface removals. 56
Three Dimensional Viewing We can view an object from any spatial position, eg. In front of an object, Behind the object, In the middle of a group of objects, Inside an object, etc. 3D descriptions of objects must be projected onto the flat viewing surface of the output device. The clipping boundaries enclose a volume of space. 57
3D Viewing The steps for computer generation of a view of a three dimensional scene are somewhat analogous to the processes involved in taking a photograph. 58
Camera Analogy 1. Viewing position 2. Camera orientation 3. Size of clipping window Orientation Window (aperture) of the camera Position 59
Viewing Pipeline The general processing steps for modeling and converting a world coordinate description of a scene to device coordinates: 60
Viewing Coordinates Viewing coordinates system described 3D objects with respect to a viewer. A Viewing (Projector) plane is set up perpendicular to zv and aligned with (xv,yv). 61
Projection Convert the viewing coordinate description of the scene to coordinate positions on the projection plane. Convert the viewing coordinate description of the scene to 3D coordinate positions on display the projection Viewing objects on a 2D requires plane. from 3D to 2D. a mapping Viewing 3D objects on a 2D display requires a mapping from 3D to 2D. 62
Projection Parallel Projection : Coordinate position are transformed to the view plane along parallel lines. Perspective Projection: Object positions are transformed to the view plane along lines that converge to the projection reference (center) point. 63
Parallel and Perspective Projection 64
3D Object Representations Methods ß Polygon and Quadric surfaces: For simple Euclidean objects ß Spline surfaces and construction: For curved surfaces ß Procedural methods: Eg. Fractals, Particle systems ß Physically based modeling methods ß Octree Encoding ß Isosurface displays, Volume rendering, etc. Classification: Boundary Representations (B-reps) eg. Polygon facets and spline patches Space-partitioning representations eg. Octree Representation Objects may also associate with other properties such as mass, volume, so as to determine their response to stress and temperature etc. 65
Visibility Assumption: All polygons are opaque What polygons are visible with respect to your view frustum? Outside: View Frustum Clipping Remove polygons outside of the view volume For example, Liang-Barsky 3D Clipping Inside: Hidden Surface Removal Backface culling Polygons facing away from the viewer Occlusion Polygons farther away are obscured by closer polygons Full or partially occluded portions Why should we remove these polygons? Avoid unnecessary expensive operations on these polygons later 66
Backface Culling Avoid drawing polygons facing away from the viewer Front-facing polygons occlude these polygons in a closed polyhedron Test if a polygon is front- or back-facing? back-facing front-facing 67
Detecting Back-face Polygons The polygon normal of a front-facing polygon points towards the viewer back-facing polygon points away from the viewer If (n v) > 0 back-face If (n v) 0 front-face v = view vector Eye-space test EASY! back-face if nz < 0 glcullface(gl_back) 68
Z-Buffer Depth buffer (Z-Buffer) A secondary image buffer that holds depth values Same pixel resolution as the color buffer Why is it called a Z-Buffer? After eye space, depth is simply the z-coordinate Sorting is done at the pixel level Rule: Only draw a polygon at a pixel if it is closer than a polygon that has already been drawn to this pixel 69
Z-buffer: A Secondary Buffer Color buffer Depth buffer 70