COMPUTER GRAPHICS NOTES.pdf
Document Details
Uploaded by Deleted User
Tags
Full Transcript
COMPUTER GRAPHICS Arignar Anna Government Arts & Science College Karaikal, Puducherry (U.T), Affiliated to Pondicherry University Department of Computer Science COMPUTER GRAPHI...
COMPUTER GRAPHICS Arignar Anna Government Arts & Science College Karaikal, Puducherry (U.T), Affiliated to Pondicherry University Department of Computer Science COMPUTER GRAPHICS Paper Code: 249 MODULE - I Overview of Computer Graphics System: Video Display Devices – Raster Scan Systems – Random – Scan Systems - Graphics Monitors and Workstations – Input Devices – Hardcopy Devices – Graphics Software. MODULE - II Output Primitives: Line Drawing Algorithms – Loading the Frame Buffer – Line Function – Circle – Generating Algorithms - Attributes of Output Primitives: Line Attributes – Curve Attributes – Color and Gray scale levels– Area fill Attributes – Character Attributes – Bundled Attributes – Inquiry Functions. MODULE - III 2D Geometric Transformations: Basic Transformation – Matrix Representations – Composite Transformations – Window to View port Co-Ordinate Transformations - Clipping: Point Clipping – Line Clipping – Cohen-Sutherland Line Clipping – Liang Barsky Line Clipping – Polygon Clipping – Sutherland – Hodgeman Polygon Clipping – Curve Clipping – Text Clipping. MODULE - IV Graphical User Interfaces and Interactive Input Methods: The User Dialogue – Input of Graphical Data – Input Functions – Interactive Picture Construction Techniques – Three Dimensional Concepts: 3D-Display Methods – Three Dimensional Graphics Packages MODULE - V 3D Geometric and Modeling Transformations: Translation – Scaling – Rotation – Other Transformations. Visible Surface Detection Methods: Classification of Visible Surface Detection Algorithm –Back face Detection – Depth-Buffer Method – A Buffer Method – Scan-Line Method –Applications of Computer Graphics. Text Book: Donald Hearn M. Pauline Baker, Computer Graphics C Version, 2nd edition, Pearson Education, 2014. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS MODULE - I Overview of Computer Graphics System: Video Display Devices – Raster Scan Systems – Random – Scan Systems - Graphics Monitors and Workstations – Input Devices – Hardcopy Devices – Graphics Software. Overview of Computer Graphics System Computer graphics is commonly seen as a computer science branch that deals with the computerized image fusion theory and technology. As simple as a triangle outline, a computer-generated image may represent a scene. The computer has become a powerful tool for producing images quickly and economically. When a computer is used to create images, the same process is followed as creating images manually. The process’s primary computational steps give a boost to several important computer graphics areas. Also on computers, the term computer graphics covers almost everything. Here in the computer graphics program’s classroom, we think of computer graphics as drawing images on machines, often known as rendering. The images can be photos, sketches, animations, or pictures of items imagined. Or they may be pictures, we cannot see directly, like internal body parts. We have put a great deal of our time to develop how computer images can replicate real-world scenes. We want objects on computers not only to look more real, but also their colors to be more realistic and how different materials appear. We can call it “real synthesis of the image.” The term computer graphics has been used to define “almost everything on the computer, including text or sound.” Generally, the term computer graphics refer to the following things: Computer representation and manipulation of image data. Various technologies for creating and manipulating images. Computer graphics study is a sub-field of computer science that studies methods for digitally incorporating and manipulating visual content. The next area of computer graphics that deals with the placement of a triangle is called transformation. Here we can use matrices to get the mapping of a triangle in image space. We can also set up the transformation matrix to control the location and orientation of the displayed image. We can also resize the triangle. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Definition of Computer Graphics-Computer graphics can be a series of images which is most often called a video or single image. Computer graphics is the technology that concerns with designs and pictures on computers. That’s why, computer graphics are visual representations of data shown on a monitor made on a computer. “Computer graphics is the use of a computer to define, store, manipulate, interrogate, and represent the pictorial output.” An image in computer graphics is made up of a number of pixels. Types of Computer Graphics There are two kinds of computer graphics are– Interactive Computer Graphics Non-Interactive Computer Graphics Interactive Computer Graphics In interactive computer graphics, users have some controls over the image, i.e., the user can make any changes to the image produced. Interactive Computer Graphics involves computer-user two-way communication. For Example: Ping-pong game. Drawing on touch screens. Display weather forecast or other moving charts/graphs on the screen. Animating pictures or graphics in movies. Graphics animation in video games. Working of Interactive Computer Graphics The modern display of graphics is very simple to build. It is composed of three components: Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Display controller or video controller Digital memory or frame buffer Television monitor 1. Display controller or video controller- It’s a Memory Buffer and TV Monitor interface. Its task is to pass Frame Buffer’s contents to the monitor. The display controller reads each continuous byte of Memory frame buffer data and converts 0’s and 1’s into appropriate video signals. In today’s term, the display controller is recognized as a display card, and one of our choices can be a VGA(Video Graphics Array) card with a resolution of 640×480. Display Controller is also capable of displaying the image in colors. 2. Digital memory or frame buffer-This is a place where images and pictures are stored as an array (matrix of 0 & 1, 0 represents darkness, and 1 represents image or picture). It is also called a frame buffer. In today’s term frame buffer is called V-RAM (video RAM), and it helps to store the image in bit form. It helps to increase the speed of graphics. 3. Television monitor- Monitor helps us to view the display, and they make use of CRT(Cathode ray tube) technology. Advantages 1. Superior Quality. 2. More accurate outcomes or products. 3. Increased Productivity. 4. Lower cost of development. 5. Increases the ability to understand information and interpret patterns significantly. Non- Interactive Computer Graphics Non-interactive computer graphics are also known as passive computer graphics. It is a type of computer graphics in which the user has no control over the image. The photo is completely controlled by the instructions of the program, not by the user. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS For Example: Screen savers. Map representation of the data. Graphic elements are used in the text, document, and PDF presentation. Static images are used in mobile applications and websites. Business graphics are used as brochures, business cards, menu of the hotel. Representation of graphics We can represent the graphics by following two ways: 1. Raster (Bitmap) Graphics 2. Vector Graphics 1. Raster Graphics: In raster graphics, the image is presented as a rectangular grid of colored squares. Raster images are also called bitmap images. Bitmap images are stored as the collection of small individual dots called pixels. Bitmap images require high resolution and anti-aliasing for a smooth appearance. For example– Paint, Photoshop, etc. 2. Vector Graphics: In vector graphics, the image is represented in the form of continuous geometric objects: line, curve, etc. Vector images are not based on pixel pattern. They use mathematical formulas to draw line and curves. The lines and curves can be combined to create an image. For Example– PowerPoint, Corel Draw, etc. Fig: Raster (Composition of Paths) Vector (Composition of Pixels) Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Difference between Raster and Vector Graphics: Raster Graphics Vector Graphics Raster images are the collection of the The Vector images are composed of pixel. paths. Scan conversion is required. Scan Conversion is not required. Vector Graphics are more costly Raster Graphics are less costly. compared to raster graphics. Raster image takes less space to store. Vector image takes more space. Raster graphics can draw mathematical Vector graphics can only draw curves, polygons, and boundaries. continuous and smooth lines. File Extension:.BMP,.TIF,.JPG etc. File Extension:.SVG,.PDF,.AI etc. Computer graphics is an art of drawing pictures on computer screens with the help of programming. It involves computations, creation, and manipulation of data. In other words, we can say that computer graphics is a rendering tool for the generation and manipulation of images. Video Display Devices Cathode Ray Tube CRT stands for Cathode ray tube. It is a technology which is used in traditional computer monitor and television. Cathode ray tube is a particular type of vacuum tube that displays images when an electron beam collides on the radiant surface. The primary output device in a graphical system is the video monitor. Component of CRT: Electron Gun: The electron gun is made up of several elements, mainly a heating filament (heater) and a cathode. The electron gun is a source of electrons focused on a narrow beam facing the CRT. Focusing & Accelerating Anodes: These anodes are used to produce a narrow and sharply focused beam of electrons. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Horizontal & Vertical Deflection Plates: These plates are used to guide the path of the electron the beam. The plates produce an electromagnetic field that bends the electron beam through the area as it travels. Phosphorus-coated Screen: The phosphorus coated screen is used to produce bright spots when the high-velocity electron beam hits it. The main element of a video monitor is the Cathode Ray Tube CRT, shown in the following illustration. The operation of CRT is very simple − The electron gun emits a beam of electrons cathode rays. The electron beam passes through focusing and deflection systems that direct it towards specified positions on the phosphor-coated screen. When the beam hits the screen, the phosphor emits a small spot of light at each position contacted by the electron beam. It redraws the picture by directing the electron beam back over the same screen points quickly. There are two ways Random scan and Raster scan by which we can display an object on the screen. Raster Scan In a raster scan system, the electron beam is swept across the screen, one row at a time from top to bottom. As the electron beam moves across each row, the beam intensity is turned on and off to create a pattern of illuminated spots. Picture definition is stored in memory area called the Refresh Buffer or Frame Buffer. This memory area holds the set of intensity values for all the screen points. Stored intensity values are then retrieved from the refresh buffer and “painted” on the screen one row scan line at a time as shown in the following illustration. Each screen point is referred to as a pixel picture element or pel. At the end of each scan line, the electron beam returns to the left side of the screen to begin displaying the next scan line. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Random Scan /Vector Scan In this technique, the electron beam is directed only to the part of the screen where the picture is to be drawn rather than scanning from left to right and top to bottom as in raster scan. It is also called vector display, stroke-writing display, or calligraphic display. Picture definition is stored as a set of line-drawing commands in an area of memory referred to as the refresh display file. To display a specified picture, the system cycles through the set of commands in the display file, drawing each component line in turn. After all the line-drawing commands are processed, the system cycles back to the first line command in the list. Random-scan displays are designed to draw all the component lines of a picture 30 to 60 times each second. Application of Computer Graphics Computer Graphics has numerous applications, some of which are listed below − Computer graphics user interfaces GUIs − A graphic, mouse-oriented paradigm which allows the user to interact with a computer. Business presentation graphics − "A picture is worth a thousand words". Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Cartography − Drawing maps. Weather Maps − Real-time mapping, symbolic representations. Satellite Imaging − Geodesic images. Photo Enhancement − Sharpening blurred photos. Medical imaging − MRIs, CAT scans, etc. - Non-invasive internal examination. Engineering drawings − mechanical, electrical, civil, etc. - Replacing the blueprints of the past. Typography − The use of character images in publishing - replacing the hard type of the past. Architecture − Construction plans, exterior sketches - replacing the blueprints and hand drawings of the past. Art − Computers provide a new medium for artists. Training − Flight simulators, computer aided instruction, etc. Entertainment − Movies and games. Simulation and modeling − Replacing physical modeling and enactments Color CRT Monitor: It is similar to a CRT monitor. The basic idea behind the color CRT monitor is to combine three basic colors- Red, Green, and Blue. By using these three colors, we can produce millions of different colors. The two basic color display producing techniques are: 1. Beam–Penetration Method: It is used with a random scan monitor for displaying pictures. There are two phosphorus layers- Red and Green are coated inside the screen. The color shown depends on how far the electron beam penetrates the phosphorus surface. A powerful electron beam penetrates the CRT, it passes through the red layer and excites the green layer within. A beam with slow electrons excites only the red layer. A beam with the medium speed of electrons, a mixture of red and green light is emitted to display two more colors- orange and yellow. Advantages: 1. Better Resolution 2. Half cost 3. Inexpensive Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Disadvantages: 1. Only four possible colors 2. Time Consuming 2.Shadow–Mask Method: It is used with a raster scan monitor for displaying pictures. It has more range of color than the beam penetration method. It is used in television sets and monitors. Structure: 1. It has three phosphorus color dots at each position of the pixel. First Dot: Red color Second Dot: Green color Third Dot: Blue color 1. It has three different guns. Each for one color. 2. It has a metal screen or plate just before the phosphorus screen, named “Shadow-Mask.” 3. It also has a shadow grid just behind the phosphorus coated screen with tiny holes in a triangular shape. Working: A Shadow Mask is a metal plate with tiny holes present inside a color monitor. A Shadow Mask directs the beam by consuming the electrons so that the beam hits only the desired point and displays a resulting picture. It has three different guns. These guns direct their beams to shadow mask, which allows them to pass. It is a task of a shadow mask to direct the beam on its particular dot on the screen and produce a picture on the screen. A Shadow Mask can display a wider range of pictures than beam penetration. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Advantages: 1. Display a wider range picture. 2. Display realistic images. 3. In-line arrangement of RGB color. Disadvantages: Difficult to cover all three beams on the same hole. Poor Resolution. Liquid crystal display (LCD): The LCD depends upon the light modulating properties of liquid crystals. LCD is used in watches and portable computers. LCD requires an AC power supply instead of DC, so it is difficult to use it in circuits. It generally works on flat panel display technology. LCD consumes less power than LED. The LCD screen uses the liquid crystal to turn pixels on or off. Liquid Crystals are a mixture of solid and liquid. When the current flows inside it, its position changes into the desired color. For Example: TFT(Thin Film Transistor) Advantages: 1. Produce a bright image 2. Energy efficient 3. Completely flat screen Disadvantages: 1. Fixed aspect ratio & Resolution 2. Lower Contrast 3. More Expensive Light Emitting Diode (LED): LED is a device which emits when current passes through it. It is a semiconductor device. The size of the LED is small, so we can easily make any display unit by arranging a large number of LEDs. LED consumes more power compared to LCD. LED is used on TV, smartphones, motor vehicles, traffic light, etc. LEDs are powerful in structure, so they are capable of withstanding mechanical pressure. LED also works at high temperatures. Advantages: 1. The Intensity of light can be controlled. 2. Low operational Voltage. 3. Capable of handling the high temperature. Disadvantages: More Power Consuming than LCD. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Direct View Storage Tube (DVST): It is used to store the picture information as a charge distribution behind the phosphor-coated screen.There are two guns used in DVST: 1.Primary Gun: It is used to store the picture information. 2.Flood / Secondary Gun: It is used to display a picture on the screen. Advantages: 1. Less Time Consuming 2. No Refreshing Required 3. High-Resolution 4. Less Cost Disadvantages: 1. The specific part of the image cannot be erased. 2. They do not display color. Plasma Display: It is a type of flat panel display which uses tiny plasma cells. It is also known as the Gas- Discharge display. Components of plasma display: 1. Anode: It is used to deliver a positive voltage. It also has the line wires. 2. Cathode: It is used to provide negative voltage to gas cells. It also has fine wires. 3. Gas Plates: These plates work as capacitors. When we pass the voltage, the cell lights regularly. 4. Fluorescent cells: It contains small pockets of gas liquids when the voltage is passed to this neon gas. It emits light. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Advantages: 1. Wall Mounted 2. Slim 3. Wider angle Disadvantages: 1. Phosphorus loses luminosity over time. 2. It consumes more electricity than LCD. 3. Large Size 3D Display: It is also called stereoscope display technology. This technology is capable of bringing depth perception to the viewer. It is used for 3D gaming and 3D TVs. For Example: Fog Display, Holographic Display, Retina Display Etc. Advantages: Impressive Picture Quality High Definition Motion Communicates Disadvantage: Expensive Binocular Fusion Input Devices Following are some of the important input devices which are used in a computer − Keyboard Mouse Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Joy Stick Light pen Track Ball Scanner Graphic Tablet Microphone Magnetic Ink Card Reader(MICR) Optical Character Reader(OCR) Bar Code Reader Optical Mark Reader(OMR) Keyboard Keyboard is the most common and very popular input device which helps to input data to the computer. The layout of the keyboard is like that of traditional typewriter, although there are some additional keys provided for performing additional functions. Keyboards are of two sizes 84 keys or 101/102 keys, but now keyboards with 104 keys or 108 keys are also available for Windows and Internet. The keys on the keyboard are as follows − S.No Keys & Description Typing Keys 1 These keys include the letter keys (A-Z) and digit keys (09) which generally give the same layout as that of typewriters. Numeric Keypad 2 It is used to enter the numeric data or cursor movement. Generally, it consists of a set of 17 keys that are laid out in the same configuration used by most adding machines and calculators. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Function Keys 3 The twelve function keys are present on the keyboard which are arranged in a row at the top of the keyboard. Each function key has a unique meaning and is used for some specific purpose. Control keys 4 These keys provide cursor and screen control. It includes four directional arrow keys. Control keys also include Home, End, Insert, Delete, Page Up, Page Down, Control(Ctrl), Alternate(Alt), Escape(Esc). Special Purpose Keys 5 Keyboard also contains some special purpose keys such as Enter, Shift, Caps Lock, Num Lock, Space bar, Tab, and Print Screen. Mouse Mouse is the most popular pointing device. It is a very famous cursor-control device having a small palm size box with a round ball at its base, which senses the movement of the mouse and sends corresponding signals to the CPU when the mouse buttons are pressed. Generally, it has two buttons called the left and the right button and a wheel is present between the buttons. A mouse can be used to control the position of the cursor on the screen, but it cannot be used to enter text into the computer. Advantages Easy to use Not very expensive Moves the cursor faster than the arrow keys of the keyboard. Joystick Joystick is also a pointing device, which is used to move the cursor position on a monitor screen. It is a stick having a spherical ball at its both lower and upper ends. The lower spherical ball moves in a socket. The joystick can be moved in all four directions. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS The function of the joystick is similar to that of a mouse. It is mainly used in Computer Aided Designing (CAD) and playing computer games. Light Pen Light pen is a pointing device similar to a pen. It is used to select a displayed menu item or draw pictures on the monitor screen. It consists of a photocell and an optical system placed in a small tube. When the tip of a light pen is moved over the monitor screen and the pen button is pressed, its photocell sensing element detects the screen location and sends the corresponding signal to the CPU. Track Ball Track ball is an input device that is mostly used in notebook or laptop computer, instead of a mouse. This is a ball which is half inserted and by moving fingers on the ball, the pointer can be moved. Since the whole device is not moved, a track ball requires less space than a mouse. A track ball comes in various shapes like a ball, a button, or a square. Scanner Scanner is an input device, which works more like a photocopy machine. It is used when some information is available on paper and it is to be transferred to the hard disk of the computer for further manipulation. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Scanner captures images from the source which are then converted into a digital form that can be stored on the disk. These images can be edited before they are printed. Digitizer Digitizer is an input device which converts analog information into digital form. Digitizer can convert a signal from the television or camera into a series of numbers that could be stored in a computer. They can be used by the computer to create a picture of whatever the camera had been pointed at. Digitizer is also known as Tablet or Graphics Tablet as it converts graphics and pictorial data into binary inputs. A graphic tablet as digitizer is used for fine works of drawing and image manipulation applications. Microphone Microphone is an input device to input sound that is then stored in a digital form. The microphone is used for various applications such as adding sound to a multimedia presentation or for mixing music. Magnetic Ink Card Reader (MICR) MICR input device is generally used in banks as there are large number of cheques to be processed every day. The bank's code number and cheque number are printed on the cheques with a special type of ink that contains particles of magnetic material that are machine readable. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS This reading process is called Magnetic Ink Character Recognition (MICR). The main advantages of MICR is that it is fast and less error prone. Optical Character Reader (OCR) OCR is an input device used to read a printed text. OCR scans the text optically, character by character, converts them into a machine readable code, and stores the text on the system memory. Bar Code Readers Bar Code Reader is a device used for reading bar coded data (data in the form of light and dark lines). Bar coded data is generally used in labelling goods, numbering the books, etc. It may be a handheld scanner or may be embedded in a stationary scanner. Bar Code Reader scans a bar code image, converts it into an alphanumeric value, which is then fed to the computer that the bar code reader is connected to. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Optical Mark Reader (OMR) OMR is a special type of optical scanner used to recognize the type of mark made by pen or pencil. It is used where one out of a few alternatives is to be selected and marked. It is specially used for checking the answer sheets of examinations having multiple choice questions. Output Devices An output device is a component of hardware or the main physical part of a computer that can be touched and seen. An output device is an electromechanical device. “The Computer gives instructions and data from input devices and processes it and returns the result called as output.” For Example: Printer, Plotter, Monitor, Projector etc. Printers: A printer is a peripheral device which is used to represent the graphics or text on paper. The quality is measured by its resolution. The resolution of any printer is measured in dot per inch (dpi). The printer usually works with the computer and connected via a cable. In present, many digital device support printer features so that we can use Bluetooth, Wi-fi, and cloud technology to print. Types of Printers Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Some types of printers are: Impact Printers Non-impact Printers Impact Printers In impact printers, there is a physical contact established between the print head, ribbon, ink-cartridge, and paper. The printers hit print head on an ink-filled ribbon than the letter prints on the paper. Impact printers are works like a typewriter. Impact printers print the characters by striking them on the ribbon, which is then pressed on the paper. Characteristics of Impact Printers are the following − Very low consumable costs Very noisy Useful for bulk printing due to low cost There is physical contact with the paper to produce an image These printers are of two types − Character printers Line printers Character Printers Character printers are the printers which print one character at a time. These are further divided into two types: Dot Matrix Printer(DMP) Daisy Wheel Dot Matrix Printer In the market, one of the most popular printers is Dot Matrix Printer. These printers are popular because of their ease of printing and economical price. Each character printed is in the form of pattern of dots and head consists of a Matrix of Pins of size (5*7, 7*9, 9*7 or 9*9) which come out to form a character which is why it is called Dot Matrix Printer. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Advantages Inexpensive Widely Used Other language characters can be printed Disadvantages Slow Speed Poor Quality Daisy Wheel Head is lying on a wheel and pins corresponding to characters are like petals of Daisy (flower) which is why it is called Daisy Wheel Printer. These printers are generally used for word-processing in offices that require a few letters to be sent here and there with very nice quality. Advantages More reliable than DMP Better quality Fonts of character can be easily changed Disadvantages Slower than DMP Noisy More expensive than DMP Line Printers Line printers are the printers which print one line at a time. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS These are of two types − Drum Printer Chain Printer Drum Printer This printer is like a drum in shape hence it is called drum printer. The surface of the drum is divided into a number of tracks. Total tracks are equal to the size of the paper, i.e. for a paper width of 132 characters, drum will have 132 tracks. A character set is embossed on the track. Different character sets available in the market are 48 character set, 64 and 96 characters set. One rotation of drum prints one line. Drum printers are fast in speed and can print 300 to 2000 lines per minute. Advantages Very high speed Disadvantages Very expensive Characters fonts cannot be changed Chain Printer In this printer, a chain of character sets is used, hence it is called Chain Printer. A standard character set may have 48, 64, or 96 characters. Advantages Character fonts can easily be changed. Different languages can be used with the same printer. Disadvantages Noisy Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Non-impact Printers Non-impact printers print the characters without using the ribbon. These printers print a complete page at a time, thus they are also called as Page Printers. These printers are of two types − Laser Printers Inkjet Printers Characteristics of Non-impact Printers Faster than impact printers They are not noisy High quality Supports many fonts and different character size Laser Printers These are non-impact page printers. They use laser lights to produce the dots needed to form the characters to be printed on a page. Advantages Very high speed Very high quality output Good graphics quality Supports many fonts and different character size Disadvantages Expensive Cannot be used to produce multiple copies of a document in a single printing Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Inkjet Printers Inkjet printers are non-impact character printers based on a relatively new technology. They print characters by spraying small drops of ink onto paper. Inkjet printers produce high quality output with presentable features. They make less noise because no hammering is done and these have many styles of printing modes available. Color printing is also possible. Some models of Inkjet printers can produce multiple copies of printing also. Advantages High quality printing More reliable Disadvantages Expensive as the cost per page is high Slow as compared to laser printer Monitors Monitors, commonly called as Visual Display Unit (VDU), are the main output device of a computer. It forms images from tiny dots, called pixels that are arranged in a rectangular form. The sharpness of the image depends upon the number of pixels. There are two kinds of viewing screen used for monitors. Cathode-Ray Tube (CRT) Flat-Panel Display Cathode-Ray Tube (CRT) Monitor The CRT display is made up of small picture elements called pixels. The smaller the pixels, the better the image clarity or resolution. It takes more than one illuminated pixel to form a whole character, such as the letter ‘e’ in the word help. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS A finite number of characters can be displayed on a screen at once. The screen can be divided into a series of character boxes - fixed location on the screen where a standard character can be placed. Most screens are capable of displaying 80 characters of data horizontally and 25 lines vertically. There are some disadvantages of CRT − Large in Size High power consumption Flat-Panel Display Monitor The flat-panel display refers to a class of video devices that have reduced volume, weight and power requirement in comparison to the CRT. You can hang them on walls or wear them on your wrists. Current uses of flat-panel displays include calculators, video games, monitors, laptop computer, and graphics display. The flat-panel display is divided into two categories − Emissive Displays − Emissive displays are devices that convert electrical energy into light. For example, plasma panel and LED (Light-Emitting Diodes). Non-Emissive Displays − Non-emissive displays use optical effects to convert sunlight or light from some other source into graphics patterns. For example, LCD (Liquid-Crystal Device). Plotters: A plotter is a special type of output device. It is used to print large graphs, large designs on a large paper. For Example: Construction maps, engineering drawings, architectural plans, and business charts, etc. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS It was invented by “Remington rand” in 1953. It is similar to a printer, but it is used to print vector graphics. Types of Plotter 1. Flatbed Plotter: In a flatbed plotter, the paper is kept in a stationary position on a table or a tray. A flatbed plotter has more than one pen and a holder. The pen rotates on the paper upside-down and right-left by the using of a motor. Every pen has a different color ink, which is used to draw the multicolor design. We can quickly draw the following designs by using a flatbed printer. For: Cars, Ships, Airplanes, Dress design, road and highway blueprints, etc. Advantages of Flatbed Plotter 1. Larger size paper can be used 2. Drawing Quality is similar to an expert Disadvantages of Flatbed Plotter 1. Slower than printers 2. More Expensive than printers 3. Do not produce high-Quality text printouts 2. Drum Plotter: It is also called “Roller plotter.” There is a drum in this plotter. We can apply the paper on the drum. When the plotter works, these drums moves back and forth, and the image is drawn. Drum plotter has more than one pen and penholders. The pens easily moves right to left and left to right. The movement of pens and drums are controlled by graph plotting program.It is used in industry to produce large drawings (up to A0). Advantages of Drum Plotter 1. Draw Larger Size image 2. We can print unlimited length of the image Disadvantages of Drum Plotter 1. Very costly Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Graphics Monitors and Workstations Graphics Monitor: i).The name itself giving some idea that, Monitor which is capable of displaying “Graphics”. Generally most of the Monitors support Text modes. ii).So Monitors which are capable of showing and supporting Graphics mode along with the Text modes. iii).Graphic monitors who can display pictures on its screen, of course it acts like an output device. The monitors which support the following Graphic applications are said to be Graphic Monitors. The Graphics Applications include, A).Animation Software’s B).CAD Software’s C).Drawing programs D).Paint Application programs E).Presentation Graphics Software’s (Excel likewise, creating pie and bar charts) F).Desktop publishing (MS Office, Share points, Document managements) So by now, you might have got an Idea of what is Graphic Monitor Actually is?? Workstation: i).Workstation is also a computer which varies generally with other General Computers ii).Because these Workstations need good operating power of computer. They must be able to support high power i.e. it must sustain good graphic capabilities. iii).These kind of computers comes with the following specifications. Unlike normal general computers they consists of, A).Minimum of 64 Megabytes of RAM B).Very good Resolution Graphics screen C).High and Large Screen D).GUI Graphical User Interface (which helps programs easier to use of the Computer’s Graphics) E).Very good Mass storage Device like Disk Drive F).Built-in Network Support and many factors iv) We may also notice that, some of the workstations do not have any disk drives in it. So these kind of disk drives are called as Diskless workstation. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS v) Workstations took place of and they lie between Personal computer (General Computers) and minicomputers as far as Computing power is concerned. vi) These can be used as both types such as stand system (which only consists of one) and Local area network. So basically in this LAN kind, workstations are typically connected together one and other. Operating Systems for Workstations: The most generally used common operating systems are, UNIX: UNIX is a multitasking operating system. Unix Operating System are to be written in High level programming language, which we can simply say C language. This Unix Operating System is with very flexible and so most commonly used in Workstations. Windows NT: Windows NT is also referred as Windows New Technology. It is also a most commonly used Operating system for workstations. This Windows NT highly supports multitasking works and Windows NT has its other versions are such as Windows NT Server and Windows NT Workstation. Graphics software and standard There are mainly two types of graphics software: 1. General programming package 2. Special-purpose application package General programming package A general programming package provides an extensive set of graphics function that can be used in high level programming language such as C or FORTRAN. It includes basic drawing element shape like line, curves, polygon, color of element transformation etc. Example: - GL (Graphics Library). Special-purpose application package Special-purpose application package are customize for particular application which implement required facility and provides interface so that user need not to vory about how it will work (programming). User can simply use it by interfacing with application. Example: - CAD, medical and business systems. Coordinate representations Except few all other general packages are designed to be used with Cartesian coordinate specifications. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS If coordinate values for a picture are specified is some other reference frame they must be converted to Cartesian coordinate before giving input to graphics package. Special-purpose package may allow use of other coordinates which suits application. In general several different Cartesian reference frames are used to construct and display scene. We can construct shape of object with separate coordinate system called modeling coordinates or sometimes local coordinates or master coordinates. Once individual object shapes have been specified we can place the objects into appropriate positions called world coordinates. Finally the World-coordinates description of the scene is transferred to one or more output device reference frame for display. These display coordinates system are referred to as “Device Coordinates” or “Screen Coordinates”. Generally a graphic system first converts the world-coordinates position to normalized device coordinates. In the range from 0 to 1 before final conversion to specific device coordinates. An initial modeling coordinates position ( Xmc,Ymc) in this illustration is transferred to a device Xdc,Ydc). Graphic Function A general purpose graphics package provides user with Varity of function for creating and manipulating pictures. The basic building blocks for pictures are referred to as output primitives. They includes character, string, and geometry entities such as point, straight lines, curved lines, filled areas and shapes defined with arrays of color points. Input functions are used for control & process the various input device such as mouse, tablet, etc. Control operations are used to controlling and housekeeping tasks such as clearing display screen etc. All such inbuilt function which we can use for our purpose are known as graphics function Software Standard Primary goal of standardize graphics software is portability so that it can be used in any hardware systems & avoid rewriting of software program for different system Some of these standards are discuss below Graphical Kernel System (GKS) This system was adopted as a first graphics software standard by the international standard organization (ISO) and various national standard organizations including ANSI. GKS was originally designed as the two dimensional graphics package and then later extension was developed for three dimensions. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS PHIGS (Programmer’s Hierarchical Interactive Graphic Standard) PHIGS is extension of GKS. Increased capability for object modeling, color specifications, surface rendering, and picture manipulation are provided in PHIGS. Extension of PHIGS called “PHIGS+” was developed to provide three dimensional surface shading capabilities not available in PHIGS. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS MODULE - II Output Primitives: Line Drawing Algorithms – Loading the Frame Buffer – Line Function – Circle – Generating Algorithms - Attributes of Output Primitives: Line Attributes – Curve Attributes – Color and Gray scale levels– Area fill Attributes – Character Attributes – Bundled Attributes – Inquiry Functions. Output Primitives Points and Lines Point plotting is done by converting a single coordinate position furnished by an application program into appropriate operations for the output device in use. Line drawing is done by calculating intermediate positions along the line path between two specified endpoint positions. The output device is then directed to fill in those positions between the end points with some color. For some device such as a pen plotter or random scan display, a straight line can be drawn smoothly from one end point to other. Digital devices display a straight line segment by plotting discrete points between the two endpoints. Discrete coordinate positions along the line path are calculated from the equation of the line. For a raster video display, the line intensity is loaded in frame buffer at the corresponding pixel positions. Reading from the frame buffer, the video controller then plots the screen pixels. Screen locations are referenced with integer values, so plotted positions may only approximate actual line positions between two specified endpoints. For example line position of (12.36, 23.87) would be converted to pixel position (12, 24). This rounding of coordinate values to integers causes lines to be displayed with a stair step appearance (“the jaggies”), as represented in fig 2.1. Fig. 2.1: - Stair step effect produced when line is generated as a series of pixel positions. The stair step shape is noticeable in low resolution system, and we can improve their appearance somewhat by displaying them on high resolution system. More effective techniques for smoothing raster lines are based on adjusting pixel intensities along the line paths. For raster graphics device-level algorithms discuss here, object positions are specified directly in integer device coordinates. Pixel position will referenced according to scan-line number and column number which is illustrated by following figure. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS 6 5 4 3 2 0 1 2 3 4 5 6 Fig. 2.2: - Pixel positions referenced by scan-line number and column number. To load the specified color into the frame buffer at a particular position, we will assume we have available low-level procedure of the form 𝑠𝑒𝑡𝑝𝑖𝑥𝑒𝑙(𝑥, 𝑦) Similarly for retrieve the current frame buffer intensity we assume to have procedure 𝑔𝑒𝑡𝑝𝑖𝑥(𝑥, 𝑦). Line Drawing Algorithms The Line drawing algorithm is a graphical algorithm which is used to represent the line segment on discrete graphical media, i.e., printer and pixel-based media. A line contains two points. The point is an important element of a line. Properties of a Line Drawing Algorithm There are the following properties of a good Line Drawing Algorithm. An algorithm should be precise: Each step of the algorithm must be adequately defined. Finiteness: An algorithm must contain finiteness. It means the algorithm stops after the execution of all steps. Easy to understand: An algorithm must help learners to understand the solution in a more natural way. Correctness: An algorithm must be in the correct manner. Effectiveness: The steps of an algorithm must be valid and efficient. Uniqueness: All steps of an algorithm should be clearly and uniquely defined, and the result should be based on the given input. Input: A good algorithm must accept at least one or more input. Output: An algorithm must generate at least one output. Equation of the straight line We can define a straight line with the help of the following equation. y= mx + a Where, (x, y) = axis of the line. m = Slope of the line. a = Interception point Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Let us assume we have two points of the line (p1, q1) and (p2, q2). Now, we will put values of the two points in straight line equation, and we get y = mx + a q2 = mp2 …(1) q1 = mp1 + a …(2) We have from equation (1) and (2) q2 – q1 = mp2 – mp1 q2 – q1 = m (p2 –p1) The value of m = (q2 – q1)/ (p2 –p1) m = ▲q / ▲p Algorithms of Line Drawing There are following algorithms used for drawing a line: DDA (Digital Differential Analyzer) Line Drawing Algorithm Bresenham’s Line Drawing Algorithm Mid-Point Line Drawing Algorith DDA (Digital Differential Analyzer) Line Drawing Algorithm The Digital Differential Analyzer helps us to interpolate the variables on an interval from one point to another point. We can use the digital Differential Analyzer algorithm to perform rasterization on polygons, lines, and triangles. Digital Differential Analyzer algorithm is also known as an incremental method of scan conversion. In this algorithm, we can perform the calculation in a step by step manner. We use the previous step result in the next step. As we know the general equation of the straight line is: y = mx + c Here, m is the slope of (x1, y1) and (x2, y2). m = (y2 – y1)/ (x2 – x1) Now, we consider one point (xk, yk) and (xk+1, yk+1) as the next point. Then the slope m = (yk+1 – yk)/ (xk+1 – xk) Now, we have to find the slope between the starting point and ending point. There can be following three cases to discuss: Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Case 1: If m < 1 Then x coordinate tends to the Unit interval. xk+1 = xk + 1 yk+1 = yk + m Case 2: If m > 1 Then y coordinate tends to the Unit interval. yk+1 = yk + 1 xk+1 = xk + 1/m Case 3: If m = 1 Then x and y coordinate tend to the Unit interval. xk+1 = xk + 1 yk+1 = yk + 1 We can calculate all intermediate points with the help of above three discussed cases. Algorithm of Digital Differential Analyzer (DDA) Line Drawing Step 1: Start. Step 2: We consider Starting point as (x1, y1), and endingpoint (x2, y2). Step 3: Now, we have to calculate ▲x and ▲y. ▲x = x2-x1 ▲y = y2-y1 m = ▲y/▲x Step 4: Now, we calculate three cases. If m < 1 Then x change in Unit Interval y moves with deviation (xk+1, yk+1) = (xk+1, yk+1) If m > 1 Then x moves with deviation y change in Unit Interval (xk+1, yk+1) = (xk+1/m, yk+1/m) If m = 1 Then x moves in Unit Interval y moves in Unit Interval (xk+1, yk+1) = (xk+1, yk+1) Step 5: We will repeat step 4 until we find the ending point of the line. Step 6: Stop. Example: A line has a starting point (1,7) and ending point (11,17). Apply the Digital Differential Analyzer algorithm to plot a line. Solution: We have two coordinates, Starting Point = (x1, y1) = (1,7) Ending Point = (x2, y2) = (11,17) Step 1: First, we calculate ▲x, ▲y and m. ▲x = x2 – x1 = 11-1 = 10 ▲y = y2 – y1 = 17-7 = 10 m = ▲y/▲x = 10/10 = 1 Step 2: Now, we calculate the number of steps. ▲x = ▲y = 10 Then, the number of steps = 10 Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Step 3: We get m = 1, Third case is satisfied. Now move to next step. xk yk xk+1 yk+1 (xk+1, yk+1) 1 7 2 8 (2, 8) 3 9 (3, 9) 4 10 (4, 10) 5 11 (5, 11) 6 12 (6, 12) 7 13 (7, 13) 8 14 (8, 14) 9 15 (9, 15) 10 16 (10, 16) 11 17 (11, 17) Step 4: We will repeat step 3 until we get the endpoints of the line. Step 5: Stop. The coordinates of drawn line are- P1 = (2, 8) P2 = (3, 9) P3 = (4, 10) P4 = (5, 11) P5 = (6, 12) P6 = (7, 13) P7 = (8, 14) P8 = (9, 15) P9 = (10, 16) P10 = (11, 17) Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Advantages of Digital Differential Analyzer It is a simple algorithm to implement. It is a faster algorithm than the direct line equation. We cannot use the multiplication method in Digital Differential Analyzer. Digital Differential Analyzer algorithm tells us about the overflow of the point when the point changes its location. Disadvantages of Digital Differential Analyzer The floating-point arithmetic implementation of the Digital Differential Analyzer is time-consuming. The method of round-off is also time-consuming. Sometimes the point position is not accurate. Bresenham’s Line Drawing Algorithm This algorithm was introduced by “Jack Elton Bresenham” in 1962. This algorithm helps us to perform scan conversion of a line. It is a powerful, useful, and accurate method. We use incremental integer calculations to draw a line. The integer calculations include addition, subtraction, and multiplication. In Bresenham’s Line Drawing algorithm, we have to calculate the slope (m) between the starting point and the ending point. As shown in the above figure let, we have initial coordinates of a line = (xk, yk). The next coordinates of a line = (xk+1, yk+1). The intersection point between yk and yk+1 = y. Let we assume that the distance between y and yk = d1. The distance between y and yk+1 = d2. Now, we have to decide which point is nearest to the intersection point. If m < 1 then x = xk+1 { Unit Interval} y = yk+1 { Unit Interval} As we know the equation of a line- y = mx +b Now we put the value of x into the line equation, then y = m(xk+1) +b …………. (1) The value of d1 = y – yk Now we put the value of d1 in equation (1). Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS y = m (xk+1) +b – yk Now, we again put the value of y in the previous equation then we got, d2 = yk+1 – y = yk + 1 – m (xk+1) – b Now, we calculate the difference between d1 – d2 If d1 < d2 Then yk+1 = yk {we will choose the lower pixel as shown in figure} If d1 => d2 Then yk+1 = yk+1 {we will choose the upper pixel as shown in figure} Now, we calculate the values of d1 – d2 (d1 – d2)= m (xk+1) +b – yk – yk – 1 + m (xk+1) + b We simplified the above equation and replaced the m with ▲y/▲x. (d1 – d2) = 2 m (xk+1) -2yk + 2b-1 We multiplied ▲x at both side then we got, ▲x (d1 – d2) = ▲x (2m (xk+1) -2yk + 2b-1) We consider ▲x (d1 – d2) as a decision parameter (Pk), so pk = ▲x (d1 – d2) After calculation we got, Pk = 2▲yxk + 2▲y – 2▲xyk +▲x (2b-1) Then, the next coordinate of pk pk+1 = 2▲yxk+1 + 2▲y – 2▲xyk+1 +▲x (2b-1) Now, the difference between pk+1 – pk then, pk+1 – pk = 2▲y (xk+1-xk) – 2▲x (yk+1-yk) pk+1 = pk + 2▲y (xk+1-xk) – 2▲x (yk+1-yk) {Decision parameter coordinate} Now, we put the value of xk+1 in above equation then we got, pk+1 = pk + 2▲y – 2▲x (yk+1 – yk) {New decision parameter when m 1, the new decision parameter for next coordinate will be pk+1 = pk + 2▲y – 2▲x (xk+1 – xk) {New decision parameter when m >1} If pk >= 0 {For coordinate y} Then, yk+1 = yk+1 {We will choose the nearest yk+1 pixel} The next coordinate will be (xk+1, yk+1) If pk < 0 Then, yk+1 = yk {We will choose the nearest yk pixel} The next coordinate will be (xk+1, yk) Similarly, If pk >= 0 {For coordinate x} Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Then, xk+1 = xk+1 {We will choose the nearest xk+1 pixel} The next coordinate will be (xk+1, yk+1) If pk < 0 Then, xk+1 = xk {We will choose the nearest xk pixel} The next coordinate will be (xk, yk+1) Algorithm of Bresenham’s Line Drawing Algorithm Step 1: Start. Step 2: Now, we consider Starting point as (x1, y1) and ending point (x2, y2). Step 3: Now, we have to calculate ▲x and ▲y. ▲x = x2-x1 ▲y = y2-y1 m = ▲y/▲x Step 4: Now, we will calculate the decision parameter pk with following formula. pk = 2▲y-▲x Step 5: The initial coordinates of the line are (xk, yk), and the next coordinates are (xk+1, yk+1). Now, we are going to calculate two cases for decision parameter pk Case 1: If pk < 0 Then pk+1 =pk +2▲y xk+1 = xk +1 yk+1 = yk Case 2: If pk >= 0 Then pk+1 =pk +2▲y-2▲x xk+1 =xk +1 yk+1 =yk +1 Step 6: We will repeat step 5 until we found the ending point of the line and the total number of iterations =▲x-1. Step 7: Stop. Example: A line has a starting point (9,18) and ending point (14,22). Apply the Bresenham’s Line Drawing algorithm to plot a line. Solution: We have two coordinates, Starting Point = (x1, y1) = (9,18) Ending Point = (x2, y2) = (14,22) Step 1: First, we calculate ▲x, ▲y. ▲x = x2 – x1 = 14-9 = 5 ▲y = y2 – y1 = 22-18 = 4 Step 2: Now, we are going to calculate the decision parameter (pk) pk = 2▲y-▲x =2x4–5=3 The value of pk = 3 Step 3: Now, we will check both the cases. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS If pk >= 0 Then Case 2 is satisfied. Thus pk+1 = pk +2▲y-2▲x =3+ (2 x 4) – (2 x 5) = 1 xk+1 =xk +1 = 9 + 1 = 10 yk+1 =yk +1 = 18 +1 = 19 Step 4: Now move to next step. We will calculate the coordinates until we reach the end point of the line. ▲x -1 = 5 – 1 = 4 pk pk+1 xk+1 yk+1 9 18 3 1 10 19 1 -1 11 20 -1 7 12 20 7 5 13 21 5 3 14 22 Step 5: Stop. The Coordinates of drawn lines are- P1 = (9, 18) P2 = (10, 19) P3 = (11, 20) P4 = (12, 20) P5 = (13, 21) P6 = (14, 22) Advantages of Bresenham’s Line Drawing Algorithm It is simple to implement because it only contains integers. It is quick and incremental Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS It is fast to apply but not faster than the Digital Differential Analyzer (DDA) algorithm. The pointing accuracy is higher than the DDA algorithm. Disadvantages of Bresenham’s Line Drawing Algorithm The Bresenham’s Line drawing algorithm only helps to draw the basic line. The resulted draw line is not smooth. Circle generating algorithm Drawing a circle on the screen is a little complex than drawing a line. There are two popular algorithms for generating a circle − Bresenham’s Algorithm and Midpoint Circle Algorithm. These algorithms are based on the idea of determining the subsequent points required to draw the circle. Let us discuss the algorithms in detail − The equation of circle is X2+Y2=r2,X2+Y2=r2, where r is radius. Bresenham’s Algorithm We cannot display a continuous arc on the raster display. Instead, we have to choose the nearest pixel position to complete the arc. From the following illustration, you can see that we have put the pixel at X,YX,Y location and now need to decide where to put the next pixel − at N X+1,YX+1,Y or at S X+1,Y−1X+1,Y−1. This can be decided by the decision parameter d. If d 0, then SX+1,Y−1X+1,Y−1 is to be chosen as the next pixel. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Algorithm Step 1 − Get the coordinates of the center of the circle and radius, and store them in x, y, and R respectively. Set P=0 and Q=R. Step 2 − Set decision parameter D = 3 – 2R. Step 3 − Repeat through step-8 while P ≤ Q. Step 4 − Call Draw Circle X,Y,P,QX,Y,P,Q. Step 5 − Increment the value of P. Step 6 − If D < 0 then D = D + 4P + 6. Step 7 − Else Set R = R - 1, D = D + 4P−QP−Q + 10. Step 8 − Call Draw Circle X,Y,P,QX,Y,P,Q. Draw Circle Method(X, Y, P, Q). Call Putpixel (X + P, Y + Q). Call Putpixel (X - P, Y + Q). Call Putpixel (X + P, Y - Q). Call Putpixel (X - P, Y - Q). Call Putpixel (X + Q, Y + P). Call Putpixel (X - Q, Y + P). Call Putpixel (X + Q, Y - P). Call Putpixel (X - Q, Y - P). Mid Point Algorithm Step 1 − Input radius r and circle center (xc,yc)(xc,yc) and obtain the first point on the circumference of the circle centered on the origin as (x0, y0) = (0, r) Step 2 − Calculate the initial value of decision parameter as P0P0 = 5/4 – r See the following description for simplification of this equation. f(x, y) = x2 + y2 - r2 = 0 f(xi - 1/2 + e, yi + 1) = (xi - 1/2 + e)2 + (yi + 1)2 - r2 = (xi- 1/2)2 + (yi + 1)2 - r2 + 2(xi - 1/2)e + e2 = f(xi - 1/2, yi + 1) + 2(xi - 1/2)e + e2 = 0 Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Let di = f(xi - 1/2, yi + 1) = -2(xi - 1/2)e - e2 Thus, If e < 0 then di > 0 so choose point S = (xi - 1, yi + 1). di+1 = f(xi - 1 - 1/2, yi + 1 + 1) = ((xi - 1/2) - 1)2 + ((yi + 1) + 1)2 - r2 = di - 2(xi - 1) + 2(yi + 1) + 1 = di + 2(yi + 1 - xi + 1) + 1 If e >= 0 then di = Y. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Attributes of output primitives Attributes The features or characteristics of an output primitive are known as Attribute. In other words, any parameter that affects the way a primitive is to be displayed is known as Attribute. Some attributes, such as colour and size, are basic characteristics of primitive. Some attributes control the basic display properties of primitives. For example, lines can be dotted or dashed, thin or thick. Areas can be filled with one colour or with multiple colours pattern. Text can appear from left to right, slanted or vertical. Line Attributes: Basic attributes of a straight line are its type, its width, and its colour. In some graphics packages, line can also be displayed using selected pen or brush options. 1. Line Type: The line type attribute includes solid lines, dashed lines, and dotted lines. We modify the line drawing algorithm to generate such lines by setting the length and space. A dashed line could be displayed by generating spaces that is equal to length of solid part. A dotted line can be displayed by generating very short dashes with spacing equal to or greater than the dash size. Similar methods are used to produce other line-type variations. Raster line-algorithms displays line type attribute by plotting pixels. For various dashed, dotted patterns, the line-drawing algorithms outputs part of pixels followed by spaces. Plotting dashes with a fixed number of pixels results in unequal-length dashes for different line angles. For example, the length of dash diagonally is more than horizontal dash for same number of pixels. For precision drawings, dash length should remain approximately same for any line angle. For this, we can adjust the pixel number according to line slope. 2. Line Width: A line with more width can be displayed as parallel lines on a video monitor. In raster lines, a standard width line is generated with single pixels at each point. Width lines are displayed by plotting additional pixels along next parallel line paths. For lines with slope less than 1, we can display thick lines by plotting a vertical length of pixels at each x position along the line. Similarly, for lines with slope greater than 1, we can plot thick lines with horizontal widths for each point. The problem with implementing width options using horizontal and vertical pixel widths is that the width of line is depended on the slope. A 45-degree line will be displayed thinner as compared to vertical or horizontal line plotted with same number of pixel widths. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Another problem is that it produces lines whose ends are either horizontal or vertical. We can adjust the shape of the line ends by adding Line Caps. One kind of line cap is the Butt Cap. It is obtained by adjusting the end positions of lines so that the thick line is displayed with square ends that are perpendicular to the line. Another line cap is the Round Cap obtained by adding a filled semicircle to each butt cap. The semicircle has diameter equal to thickness of line. The third type of line cap is the Projecting Square Cap. Here, the butt cap is extended to half of line width. (a) (b) (c) Thick Lines drawn with (a) Butt Cap (b) Round Cap and (c) Projecting Square Cap Generating thick connected line segments require other considerations. The methods that we have considered for displaying thick lines will not produce smoothly connected line segments. It leaves gaps at the boundaries between lines of different slope. There are three possible methods for smoothly joining two line segments. A Miter Join is obtained by extending the outer boundaries of each of the two lines until they meet. A Round Join is produced by covering the connection between the two segments with a circular boundary whose diameter is equal to the line width. A Bevel Join is generated by displaying the line with butt caps and filling in the triangular gap where the segments meet. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Line without Joins Bevel Join Miter Join Round Join 3. Pen and Brush Options: In some graphic packages, lines can be displayed with pen or brush selection. Options in this category include shape, size and pattern. These shapes are stored in a Pixel Mask that identifies the pixel positions that are to be set along the line path. Lines generated with pen or brush shaped can be displayed in various widths by changing the size of the mask. Lines can also be displayed with selected patterns. 4. Line Colour: A system displays a line in the current colour by setting the colour value in the frame buffer at pixel locations. The number of colour choices depends on the number of bits available per pixel in the frame buffer. A line drawn in the background colour is invisible. COLOR AND GRAYSCALE LEVELS Various color and intensity-level options can be made available to a user, depending on the capabilities and design objectives of a particular system. General purpose raster-scan systems, for example, usually provide a wide range of colors, while random-scan monitors typically offer only a few color choices, if any. Color options are numerically coded with values ranging from 0 through the positive integers. For CRT monitors, these color codes are then converted to intensity level settings for the electron beams. With color plotters, the codes could control ink-jet deposits or pen selections. In a color raster system, the number of color choices available depends on the amount of storage provided per pixel in the frame buffer. Also, color-information can be stored in the frame buffer in two ways: We can store color codes directly in the frame buffer, or we can put the color codes in a separate table and use pixel values as an index into this table. With the direct storage scheme, whenever a particular color code Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS is specified in an application program, the corresponding binary value is placed in the frame buffer for each-component pixel in the output primitives to be displayed in that color. A minimum number of colors can be provided in the scheme with 3 bits of storage per pixel, as shown in Table. Each of the three bit positions is used to control the intensity level (either on or off) of the corresponding electron gun in an RGB monitor. The leftmost bit controls the red gun, the middle bit controls the green gun, and the rightmost bit controls the blue gun. Adding more bits per pixel to the frame buffer increases the number of color choices. With 6 bits per pixel, 2 bits can be used for each gun. This allows four different intensity settings for each of the three color guns, and a total of 64 color values are available for each screen pixel. With a resolution of 1024 by 1024, a full-color (24bit per pixel) RGB system needs 3 megabytes of storage for the frame buffer. Color tables are an alternate means for providing extended color capabilities to a user without requiring large frame buffers. Lower-cost personal computer systems, in particular, often use color tables to reduce frame-buffer storage requirements. COLOR TABLES Figure 2.1 illustrates a possible scheme for storing color values in a color lookup table (or video lookup table), where frame-buffer values are now used as indices into the color table. In this example, each pixel can reference any one of the 256 table positions, and each entry in the table uses 24 bits to specify an RGB color. For the color code 2081, a combination green-blue color is displayed for pixel location (x, y). Systems employing this particular lookup table would allow a user to select any 256 colors for simultaneous display from a palette of nearly 17 million colors. Compared to a full color system, this scheme reduces the number of simultaneous colors that can be displayed, but it also reduces the frame buffer storage requirements to 1 megabyte. Some graphics systems provide 9 bits per pixel in the frame buffer, permitting a user to select 512 colors that could be used in each display. (Table 2.1, The eight color codes for a three-bit per pixel frame buffer) Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS (Fig: 2:1, Color Lookup Table) There are several advantages in storing color codes in a lookup table. Use of a color table can provide a "reasonable" number of simultaneous colors without requiring large frame buffers. For most applications, 256 or 512 different colors are sufficient for a single picture. Also, table entries can be changed at any time, allowing a user to be able to experiment easily with different color combinations in a design, scene, or graph without changing the attribute settings for the graphics data structure. Similarly, visualization applications can store values for some physical quantity, such as energy, in There are several advantages in storing color codes in a lookup table. Use of a color table can provide a "reasonable" number of simultaneous colors without requiring large frame buffers. For most applications, 256 or 512 different colors are sufficient for a single picture. Also, table entries can be changed at any time, allowing a user to be able to experiment easily with different color combinations in a design, scene, or graph without changing the attribute settings for the graphics data structure. Similarly, visualization applications can store values for some physical quantity, such as energy, in the frame buffer and use a lookup table to try out various color encodings without changing the pixel values. And in visualization and image-processing applications, color tables are a convenient means or setting color thresholds so that all pixel values above or below a specified threshold can be set to the same color. For these reasons, some systems provide both capabilities for color-code storage, so that a user can elect either to use color tables or to store color codes directly in the frame buffer. GRAYSCALE With monitors that have no color capability, color functions can be used in an application program to set the shades of gray, or grayscale, for displayed primitives. Numeric values over the range from 0 to 1 can be used to specify grayscale levels, which are then converted to appropriate binary codes for storage in the raster. This allows the intensity settings to be easily adapted to systems with differing grayscale capabilities. Table lists the specifications for intensity codes for a four-level grayscale system. In this example, any intensity input value near 0.33 would be stored as the binary value 01 in the frame buffer, and pixels with this value would be displayed as dark gray. If additional bits per pixel are available in the frame buffer, the value of 0.33 would be mapped to the nearest level. With 3 bits per pixel, we can accommodate 8 gray Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS levels; while 8 bits per pixel would give us 256 shades of gray. An alternative scheme for storing the intensity information is to convert each intensity code directly to the voltage value that produces this grayscale level on the output device in use. INTENSITY CODES FOR A FOUR-LEVEL GRAYSCALE SYSTEM Intensity Stored Intensity Displayed Codes Values Gray Scale In the frame Buffer (Binary Code) 0.0 0 (00) Black 0.33 1 (01) Dark gray 0.67 2 (1 0) Light gray 1.O 3 (11) White Area-Fill Attributes: Options for filling a region include a choice between a solid colour and a patterned fill. These options can be applied to polygon regions or regions with curved boundaries. Areas can be displayed with various fill styles: hollow, solid, pattern and hatch. Hollow areas are displayed using only the boundary outline, with interior colour the same as the background colour. A Solid fill is displayed in a single colour including the borders. Fill style can also be with a specific pattern or design. The Hatch fill is used to fill area with hatching pattern. Hollow Solid Pattern Polygon fill styles Diagonal hatch Diagonal Cross-hatch Polygon fill using hatch patterns Other fill options include specifications for the edge type, edge width and edge colour. These attributes are same as the line attributes. That is, we can display polygon edges as dotted, dashed, thick or of different colours, etc. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Soft Fill We may want to fill area again due to 2 reasons: It is blurred (unclear) when painted first time, or It is repainting of a color area that was originally filled with semitransparent brush, where current color is then mixture of the brush color and the background color “b e h i n d ” the area. So that the fill color is combined with the background colors are referred to as Soft-fill. Character Attributes: The appearance of displayed characters is controlled by attributes such as font, size, colour and orientation. Attributes can be set both for entire character strings and for individual characters, known as Marker symbols. 1. Text Attributes: There are many text options available, such as font, colour, size, spacing, and orientation. Text Style: The characters in a selected font can also be displayed in various underlining styles (solid, dotted, dashed, double), in bold, in italics, shadow style, etc. Font options can be made available as predefined sets of grid patterns or as character sets designed with lines and curves. Text Colour: Colour settings for displayed text are stored in the system attribute list and transferred to the frame buffer by character loading functions. When a character string is displayed, the current colour is used to set pixel values in the frame buffer corresponding to the character shapes and position. Text Size: We can adjust text size by changing the overall dimensions, i.e., width and height, of characters or by changing only the width. Character size is specified in Points, where 1 point is 0.013837 inch or approximately 1/72 inch. Point measurements specify the size of the Character Body. Different fonts with the same point specifications can have different character sizes depending upon the design of the font. Topline Kern q Capline H Ba seline Bottomline f Descenders Character Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS Character Body The distance between Topline and Bottomline is same for all characters in a particular size and font, but the width may be different. A smaller body width is assigned to narrow characters such as i, j, l, e t c. compared to broad characters such as W or M. The Character Height is the distance between the Baseline and Capline of characters. Kerned characters, such as f and j, extend beyond the character-width limits. And letters with descenders, such as g, j, p, q, extend below the baseline. The size can be changed in such a way so that the width and spacing of characters is adjusted to maintain the same text proportions. For example, doubling the height also doubles the character width and the spacing between characters. Also, only the width of the character s can be changes without affecting its height. Similarly, spacing between characters can be increased without changing height or width of individual characters. The effect of different character-height setting, character-width setting, and character spacing on a text is shown below. HEIGHT1 WIDTH1 SPACING1 HEIGHT2 WIDTH2 SPA CI NG2 HEIGHT3 WIDTH3 SPACING3 Effect of changing Height, Width and Spacing Text Orientation: The text can be displayed at various angles, known as orientation. A procedure for orienting text rotates characters so that the sides of character bodies, from baseline to topline at aligned at some angle. Character strings can be arranged vertically or horizontally. Orientation A text orientated by 45 degrees in anticlockwise and clockwise direction Text Path: In some applications the character strings are arranged vertically or horizontally. This is known as Text Path. Text path can be right, left, up or down. Dr. D. UDAYA / Assistant Professor AAGASC / Department of Computer Science / KKL COMPUTER GRAPHICS g n i r t s gnirts String A text displayed with the four text-path options s t r i n g Text Alignment: Another attribute for character strings is alignment. This attribute specifies how text is to be positioned with respect to the start coordinates. Vertical alignment can be top, cap, half, base and bottom. Similarly, horizontal alignment can be left, centre and right. top cap TEXT ALIGNMENT half bottom right left Alignment values for a string Text Attributes In text we are having so many style and design like italic fonts, bold fonts etc. For setting the font style in PHIGS package we have one function which is: setTextFont (tf) Where tf is used to specify text font It will set specified font as a current character. For setting color of character in PHIGS we have function: setTextColorIndex (tc) Where text color parameter tc specifies an allowable color code. For setting the size of the text we use function. setCharacterheight (ch) For scaling the character we use function. Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS setCharacterExpansionFacter (cw) Where character width parameter cw is set to a positive real number that scale the character body width. Spacing between character is controlled by function setCharacterSpacing (cs) Where character spacing parameter cs can be assigned any real value. The orientation for a displayed character string is set according to the direction of the character up vector: setCharacterUpVector (upvect) Parameter upvect in this function is assigned two values that specify the 𝑥 and 𝑦 vector components Text is then displayed so that the orientation of characters from baseline to cap line is in the direction of the up vector. For setting the path of the character we use function: setTextPath (tp) Where the text path parameter tp can be assigned the value: right, left, up, or down. It will set the direction in which we are writing. For setting the alignment of the text we use function. setTextAlignment (h, v) Where parameter h and v control horizontal and vertical alignment respectively. For specifying precision for text display is given with function. setTextPrecision (tpr) Where text precision parameter tpr is assigned one of the values: string, char, or stroke. The highest-quality text is produced when the parameter is set to the value stroke. Marker Attributes A marker symbol display single character in different color and in different sizes. For marker attributes implementation by procedure that load the chosen character into the raster at defined position with the specified color and size. We select marker type using function. setMarkerType (mt) Where marker type parameter mt is set to an integer code. Typical codes for marker type are the integers 1 through 5, specifying, respectively, a dot (.), a vertical cross (+), an asterisk (*), a circle (o), and a diagonal cross (x). Displayed marker types are centered on the marker coordinates. We set the marker size with function. SetMarkerSizeScaleFactor (ms) Where parameter marker size ms assigned a positive number according to need for scaling. For setting marker color we use function. setPolymarkerColorIndex (mc) Where parameter mc specify the color of the marker symbol Bundled Attributes A particular set of attribute values tor a primitive on each output device is then chosen by specifying the appropriate table index. Attributes specified in this manner called bundled attributes Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS MODULE - III 2D Geometric Transformations: Basic Transformation – Matrix Representations – Composite Transformations – Window to View port Co-Ordinate Transformations - Clipping: Point Clipping – Line Clipping – Cohen-Sutherland Line Clipping – Liang Barsky Line Clipping – Polygon Clipping – Sutherland – Hodgeman Polygon Clipping – Curve Clipping – Text Clipping. 2D Transformations 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. Homogenous Coordinates To perform a sequence of transformation such as translation followed by rotation and scaling, we need to follow a sequential process − Translate the coordinates, Rotate the translated coordinates, and then Scale the rotated coordinates to complete the composite transformation. To shorten this process, we have to use 3×3 transformation matrix instead of 2×2 transformation matrix. To convert a 2×2 matrix to 3×3 matrix, we have to add an extra dummy coordinate W. In this way, we can represent the point by 3 numbers instead of 2 numbers, which is called Homogenous Coordinate system. In this system, we can represent all the transformation equations in matrix multiplication. Any Cartesian point PX,YX,Y can be converted to homogenous coordinates by P’ (Xh, Yh, h). 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,YX,Y to get the new coordinate X′,Y′X′,Y′. Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS From the above figure, you can write that − X’ = X + tx Y’ = Y + ty The pair (tx, ty) is called the translation vector or shift vector. The above equations can also be represented using the column vectors. P=[X][Y]P=[X][Y] p' = [X′][Y′][X′][Y′]T = [tx][ty][tx][ty] We can write it as − P’ = P + T Rotation In rotation, we rotate the object at particular angle θ thetatheta from its origin. From the following figure, we can see that the point PX,YX,Y is located at angle φ from the horizontal X coordinate with distance r from the origin. Let us suppose you want to rotate it at the angle θ. After rotating it to a new location, you will get a new point P’ X′,Y′X′,Y′. Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS Using standard trigonometric the original coordinate of point PX,YX,Y can be represented as − X=rcosϕ......(1)X=rcosϕ......(1) Y=rsinϕ......(2)Y=rsinϕ......(2) Same way we can represent the point P’ X′,Y′X′,Y′ as − x′=rcos(ϕ+θ)=rcosϕcosθ−rsinϕsinθ.......(3)x′=rcos(ϕ+θ)=rcosϕcosθ−rsinϕsinθ.......(3) y′=rsin(ϕ+θ)=rcosϕsinθ+rsinϕcosθ.......(4)y′=rsin(ϕ+θ)=rcosϕsinθ+rsinϕcosθ.......(4) Substituting equation 11 & 22 in 33 & 44 respectively, we will get x′=xcosθ−ysinθx′=xcosθ−ysinθ y′=xsinθ+ycosθy′=xsinθ+ycosθ Representing the above equation in matrix form, [X′Y′]=[XY][cosθ−sinθsinθcosθ]OR[X′Y′]=[XY][cosθsinθ−sinθcosθ]OR P’ = P. R Where R is the rotation matrix R=[cosθ−sinθsinθcosθ]R=[cosθsinθ−sinθcosθ] The rotation angle can be positive and negative. For positive rotation angle, we can use the above rotation matrix. However, for negative angle rotation, the matrix will change as shown below − R=[cos(−θ)−sin(−θ)sin(−θ)cos(−θ)]R=[cos(−θ)sin(−θ)−sin(−θ)cos(−θ)] =[cosθsinθ−sinθcosθ](∵cos(−θ)=cosθandsin(−θ)=−sinθ)=[cosθ−sinθsinθcosθ](∵cos(−θ)=cosθ andsin(−θ)=−sinθ) 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. Let us assume that the original coordinates are X,YX,Y, the scaling factors are (SX, SY), and the produced coordinates are X′,Y′X′,Y′. This can be mathematically represented as shown below − Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS X' = X. SX and Y' = Y. SY The scaling factor SX, SY scales the object in X and Y direction respectively. The above equations can also be represented in matrix form as below − (X′Y′)=(XY)[Sx00Sy](X′Y′)=(XY)[Sx00Sy] OR P’ = P. S Where S is the scaling matrix. The scaling process is shown in the following figure. If we provide values less than 1 to the scaling factor S, then we can reduce the size of the object. If we provide values greater than 1, then we can increase the size of the object. Reflection Reflection is the mirror image of original object. In other words, we can say that it is a rotation operation with 180°. In reflection transformation, the size of the object does not change. The following figures show reflections with respect to X and Y axes, and about the origin respectively. Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS Shear 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. However; in both the cases only one coordinate changes its coordinates and other preserves its values. Shearing is also termed as Skewing. X-Shear The X-Shear preserves the Y coordinate and changes are made to X coordinates, which causes the vertical lines to tilt right or left as shown in below figure. Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS The transformation matrix for X-Shear can be represented as − Xsh=⎡⎣⎢100shx10001⎤⎦⎥Xsh=[1shx0010001] Y' = Y + Shy. X X’ = X Y-Shear The Y-Shear preserves the X coordinates and changes the Y coordinates which causes the horizontal lines to transform into lines which slopes up or down as shown in the following figure. The Y-Shear can be represented in matrix from as − Ysh⎡⎣⎢1shy0010001⎤⎦⎥Ysh[100shy10001] X’ = X + Shx. Y Y’ = Y Matrix representation of transformations. For translation, P‘= P+T x‘ = x + tx y‘ y ty This can also be written as , x‘ = 1 0 tx. x y‘ 0 1 ty y 1 001 1 Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS For rotation, x‘ = Cosθ -Sinθ. x y‘ Sinθ Cosθ y This can be written as, x‘ = Cos@ -Sin @ 0. x y‘ Sin @ Cos @ 0 y 1 0 0 1 1 For scaling, P‘= S.P This can be written as, x‘ = Sx 0 0. x y‘ 0 Sy 0 y 1 0 0 1 1 Composite Transformation If a transformation of the plane T1 is followed by a second plane transformation T2, then the result itself may be represented by a single transformation T which is the composition of T1 and T2 taken in that order. This is written as T = T1∙T2. Composite transformation can be achieved by concatenation of transformation matrices to obtain a combined transformation matrix. A combined matrix − [T][X] = [X] [T1] [T2] [T3] [T4] …. [Tn] Where [Ti] is any combination of Translation Scaling Shearing Rotation Reflection The change in the order of transformation would lead to different results, as in general matrix multiplication is not cumulative, that is [A]. [B] ≠ [B]. [A] and the order of multiplication. The basic purpose of composing transformations is to gain efficiency by applying a single composed transformation to a point, rather than applying a series of transformation, one after another. For example, to rotate an object about an arbitrary point (Xp, Yp), we have to carry out three steps − Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS Translate point (Xp, Yp) to the origin. Rotate it about the origin. Finally, translate the center of rotation back where it belonged. We have learnt matrix representations of transformation. We can set up a matrix for any sequence of transformations as a composite transform matrix by calculating the matrix product of the individual transform. For e.g. suppose we want to perform rotation of an object about an arbitrary point. This can be performed by applying a sequence of three simple transforms a translation, followed by a rotation followed by another translation. For e.g. suppose we are asked to rotate the triangle through 900. This can be done by first translate the object to the origin. Rotate it by 900 and again translate it by tx = 2, ty=0. Translate the object to tx=2, ty= 0 Here we have done one translation, one rotation , one translation again. Complex transformation can be described as concatenation of simple ones. Suppose we wish to derive a transformation which will rotate a point through a clockwise angle @ about the point (Rx, Ry). The rotation transformation be applied to rotate points only about the origin. So we must translate points so that (Rx, Ry) becomes the origin. x‘ = x. 1 0 -Rx y‘ y 0 1 -Ry 1 1 0 0 1 then rotation can be applied x‘‘ = x‘ Cos@ -Sin@ 0 y‘‘ y‘ Sin@ Cos@ 0 1 1 0 0 1 Finally, we translate point so that the origin is returned to (Rx,Ry) x‘‘‘ = x‘‘ 1 0 Rx y‘‘‘ y‘‘ 0 1 Ry 1 1 0 0 1 Window to view port co-ordinate transformation “The process of selecting and viewing an image with different views, called windowing.” All the objects in the real world have a size. We can measure the size and location of an object by the unit. Dr. D. UDAYA / Assistant Professor AAGASC/Department of Computer Science / KKL COMPUTER GRAPHICS For Example-We use the meter unit to measure both size and the location of the object. When we represent the image of an object on the screen, then we use the screen coordinate system. The screen coordinate system is used to define the location of the object. When we select the screen coordinate system, then the image can be displayed on the screen. “The Capability to show some part of an object in a window is known as windowing.” “The rectangular area describes in the world coordinate system is called the window.” Viewport: “The viewport can be defined as an area on the screen which is used to display the object.” The window is an area space for the object. Viewport surrounds the object. We need the coordinate transformation to display the object on the screen. We can define many viewports on a different area of the screen and also see the same object from a different angle in the viewport. Window to Viewport transformation: “Window to viewport transformation is a process of converting two-dimensional or world into a device coordinate.” The object inside the clipping window is mapped to the viewport. The viewport is displayed inside the interface window on the screen. We can use the clipping window to select the part of an object, and the viewport is used to display the selected part of the object on the screen or output device. Steps for Window to Viewport Transformation: We can follow the following steps for