Vous êtes sur la page 1sur 75

COMPUTER GRAPHICS

4.1 computer Graphics

1. Overview of graphics system Video display devices, Raster-scan systems, Random-Scan systems, Graphics Monitors Workstations, Input devices, hard-copy devices, Graphics Software.

2. Output Primitives points and lines, lines drawing algorithms, loading the frame buffer, line functions, circle generating algorithm, filled area primitives, fill area functions, cell array, character generation

3. Attributes of output primitives Line attributes, color and grayscale levels, area- fill attributes, character attributes, antialiasing.

4. Two dimensional geometric transformations basic transformations, matrix representations and homogeneous coordinate composite transformations, other transformations, transformations between coordinate system, affined transformations, transformation functions and raster methods for transformations.

5. Two dimensional viewing the viewing pipeline, viewing coordinate reference frame, window-to-view port coordinate transformation, two dimensional viewing functions, clipping operations, point clipping, line clipping, polygon clipping, text clipping, exterior clipping

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

6. graphics user interfaces and interactive input methods The user dialogue input of graphical data, input functions, initial values for input device parameter, interactive picture-construction techniques, virtual-reality environment

7. three dimensional concepts and object representation three dimensional display methods, polygon surfaces, curved lines and surfaces, quadratic surfaces, Bezier curves and surfaces, B-Spline curves and surfaces, octrees, BSP trees, Fractal-geometry methods

8. three dimensional geometric and modeling transformation translation, rotation, scaling, other transformations, composite transformations, three dimensional transformation functions, modeling and coordinate transformations

9. three dimensional viewing viewing pipeline, viewing coordinates, projections, view volumes, clipping

10.visible surface detection methods classification of visible- surface detection algorithms, back face detection, depth-buffer method, scan line method, area subdivision method, curved surfaces, wire frame methods

text book:

1. computer graphics: c version- Donold Heam and M. Pauline Baker, Pearson educationsecond edition- 2003

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

reference books: 1. computer graphics: a programming approach- steven Harrigton, Tata McGraw Hillsecond edition 2. computer graphics: principles and practice- Foley, VanDam, Feiner & Hughes. Pearson education- second edition- 2003

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

Computer Graphics Computer Graphics is the use of computers to display and manipulate information in graphical or pictorial form, either on a visual-display unit or via a printer or plotter. Computer graphics are graphics created by computers and, more generally, the representation and manipulation of pictorial data by a computer. The term computer graphics includes almost everything on computers that is not text or sound. Today nearly all computers use some graphics and users expect to control their computer through icons and pictures rather than just by typing. The term Computer Graphics has several meanings:

the representation and manipulation of pictorial data by a computer the various technologies used to create and manipulate such pictorial data the images also produced Today computers and computer-generated images touch many aspects of our daily life. Computer imagery is found on television, in newspapers, in weather reports, education, medicine, business, art and during surgical procedures. A well-constructed graph can present complex statistics in a form that is easier to understand and interpret. Such graphs are used to illustrate papers, reports, theses, and other presentation material. A range of tools and facilities are available to enable users to visualize their data, and computer graphics are used in many disciplines. 2D Computer Graphics 2D computer graphics are the computer-based generation of digital images mostly from two-dimensional models, such as 2D geometric models, text, and digital images, and by techniques specific to them. The word may stand for the branch of computer science that comprises such techniques, or for the models themselves. 2D computer graphics started in the 1950s. 2D computer graphics are mainly used in applications that were originally developed upon traditional printing and drawing technologies, such as typography, cartography, technical drawing, advertising, etc.. In those applications, the two-dimensional image is not just a representation of a real-world object, but an independent artifact with added semantic value; two-dimensional models are therefore preferred, because they give more direct control of the image than 3D computer graphics, whose approach is more akin to photography than to typography. 3D Computer Graphics

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

3D computer graphics in contrast to 2D computer graphics are graphics that use a three-dimensional representation of geometric data that is stored in the computer for the purposes of performing calculations

and rendering 2D images. Such images may be for later display or for real-time viewing.3D computer graphics are often referred to as 3D models. However, there are differences. Computer Animation Computer animation is the art of creating moving images via the use of computers. It is a subfield of computer graphics and animation. Increasingly it is created by means of 3D computer graphics, though 2D computer graphics are still widely used for stylistic, low bandwidth, and faster real-time rendering needs. Sometimes the target of the animation is the computer itself, but sometimes the target is another medium, such as film. It is also referred to as CGI (Computer-generated imagery or computer-generated imaging), especially when used in films. To create the illusion of movement, an image is displayed on the computer screen then quickly replaced by a new image that is similar to the previous image, but shifted slightly. This technique is identical to the illusion of movement in television and motion pictures. Display Systems-Refresh CRTs ! A cathode ray tube (CRT) is a specialized vacuum tube in which images are produced when an electron beam strikes a phosphorescent surface. Most desktop computer displays make use of CRTs. The CRT in a computer display is similar to the "picture tube" in a television receiver. All CRT's have three main elements: an electron gun, a deflection system, and a screen. The electron gun provides an electron beam, which is a highly concentrated stream of electrons. The deflection system positions the electron beam on the screen, and the screen displays a small spot of light at the point where the electron beam strikes it.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

A common CRT used in computer monitors & TV

Refresh CRT A beam of electrons (cathode rays), emitted by an electron gun, passes through focusing and deflection systems that direct the beam towards specified position on the phosphor-coated screen. The phosphor then emits a small spot of light at each position contacted by the electron beam. Because the light emitted by the phosphor fades very rapidly, some method is needed for maintaining the screen picture. One way to keep the phosphor glowing is to redraw the picture repeatedly by quickly directing the electron beam back over the same points. This type of display is called a refresh CRT. Basic Operation of a CRT The basic operation of CRT is shown in figure:

Electron Gun The primary components of an electron gun in a CRT are the heated metal cathode and a control grid. The cathod is heated by an electric current passed through a coil of wire called the filament. This causes electrons to be boiled off the hot cathode surface. In the vacuum inside the CRT envelope, negatively charged electrons are then accelerated toward the phosphor coating by a high positive voltage. The accelerating voltage can be generated with a positively charged metal coating on the in side of the CRT envelope near the phosphor screen, or an accelerating anode can be used. Sometimes the electron gun is built to contain the accelerating anode and focusing system within the same unit. Focusing System

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

The focusing system is ised to create a clear picture by focusing the electrons into a narrow beam. Otherwise, electrons would repel each other and beam would spread out as it reaches the screen. Focusing is acomplished with either electric or magnetic fields.

Deflection System Deflection of the electron beam can be controlled by either electric fields or magnetic fields. In case of magnetic field, two pairs of coils are used, one for horizontal deflection and other for vertical deflection. In case of electric field, two pairs of parallel plates are used, one for horizontal deflection and second for vertical deflection as shown in figure above. CRT Screen The inside of the large end of a CRT is coated with a fluorescent material that gives off light when struck by electrons. When the electrons in the beam is collides with phosphor coating screen, they stopped and their kinetic energy is absorbed by the phosphor. Then a part of beam energy is converted into heat energy and the remainder part causes the electrons in the phospor atom to move up to higher energy levels. After a short time the excited electrons come back to their ground state. During this period, we see a glowing spot that quickly fades after all excited electrons are returned to their ground state. Persistence It is defined as the time they continue to emit light after the CRT beam is removed. Persistence is defined as the time it take the emitted light from the screen to decay to one-tenth of its original intensity. Lowerpersistence phosphors require higher refresh rates to maintain a picture on the screen without flicker. A phosphor with low persistence is useful for animation ; a high-persistence phosphor is useful for displaying highly complex, static pictures. Although some phosphor have a persistence greater than 1 second, graphics monitor are usually constructed with a persistence in the range from 10 to 60 microseconds. Resolution The number of points per centimeter that can be used be plotted horizontlly and vertically. Or Total number of points in each direction. The resolution of a CRT is depend on

type of phosphor intensity to be displayed focusing and deflection system

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

Aspect Ratio It is ratio of horizontal to vertical points.

Example: An aspect ratio of 3/4 means that a verticle line plotted with three points has same lenght as horizontal line plotted with four points. Raster Scan Systems ! It is the most common type of graphics monitor based on television technology. In a raster scan system, the electron beam is swept across the screen, one row at a time from top to bottom. When 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 a memory called frame buffer which holds the set of intensity values, which are then retrieved from the frame buffer and pointed on the screen one row at a time as shown in figure below

At the end of each line the beam must be turned off and redirect to the left hand side of the CRT, this is called Horizontal Retrace. At the end of each frame, the electron beam return to top left corner of the screen to begin the next frame called Vertical Retrace as shown in figure below:

Advantages

Disadvantages

produce realistic images also produced different colors and shadows scenes.

low resolution expensive electron beam directed to whole screen

Color CRT Monitors !

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

A color CRT monitor displays color picture by using a combination of phosphors that emit different colored light. By combining the emitted light a range of colors can be generated. Two basic methods for producing color displays are:

Beam Penetration Method Shadow-Mask Method Beam Penetration Method Random scan monitors use the beam penetration method for displaying color picture. In this, the inside of CRT screen is coated two layers of phorphor namely red and green. A beam of slow electrons excites ony the outer red layer, while a beam of fast electrons penetrates red layer and excites the inner green layer. At intermediate beam speeds, combination of red and green light are emitted to show two addtional colorsorange and yellow. Advantages Less expensive Disadvantages Quality of images are not good as comparatable with other methods Four colors are allowed only

Shadow Mask Method

Raster scan system are use shadow mask methods to produce a much more range of colors than beam penetration method. In this, CRT has three phosphor color dots. One phosphor dot emits a red light, second emits a green light and third emits a blue light. This type of CRT has three electrons guns and a shadow mask grid as shown in figure below:

In this figure, three electrons beams are deflected and focused as a group onto the shadow mask which contains a series of holes. When three beams pass through a hole in shadow mask they activate dot triangle as shown in figure

The colors we can see depends on the amount of excitation of red, green and blue phosphor. A white area is a reasult of all three dots with equal intensity while yellow is produced with green and red dots and so on.
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

10

Advantages produce realistic images also produced different colors and shadows scenes.

Disadvantages low resolution expensive electron beam directed to whole screen

Full Color System Color CRTs in graphics systems are designed as RGB monitors. These monitors use shadow mask method and take the intensity level for each gun. A RGB color system with 34 bits of storage per pixel is known as full color system or true color system. Plasma Panels ! The plasma panel is composed of two sheets of glass with a series of ribs ( like corrugated cardboard ) filled with color phosphors in between. The top glass with embedded electrodes seals and forms a pixel where the junctions of the channels and the plate come together. Inside the sealed pixel, is a mixture of rare gases- typically argon and neon, although xenon has also been used.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

11

Actually a small electric capacitor has been created, with one electrode on the rear and a pair on the front. These 3 electrodes control the capacitor charge, sustain and discharge functions intrinsic to the plasma imaging process. The plasma imaging cycle can be broken into following steps. initially, the pixel is at its resting ( ie. Off ) state. while a voltage is applied to the addressing electrodes ( pixel ). When the applied voltage reaches a certain level- say 200+ volts - the resistance in the pixel is overcome, and an electrical discharge is made across the electrodes. Once this discharge occurrs, the mixture of rare gases is ionized into a plasma state, which means the gas mixture can now conduct electricity, an intense burst of ultraviolet ( UV ) light is emitted. This burst of UV energy stimulates the color phosphors, in turn makes them glow brightly.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

12

Once the pixel is switched On, a much lower voltage sustains the UV emissions and keeps the phosphors glowing. This sustain voltage is typically in the 50 volts range. Eventually, the pixel will need to be turned off to rest the phosphors. This is done by removing the sustain voltage first, then reversing the charge in the pixel through the addressing electrodes. At this point, the pixel is back to its resting

Computer Graphics And Multimedia ! An electronic display in which a large orthogonal array of display elements, such as liquid-crystal or electroluminescent elements, form a flat screen. The term flat-panel display is actually a misnomer, since thinness is the distinguishing characteristic. Most television sets and computer monitors currently employ cathode-ray tubes. Cathode-ray tubes cannot be thin because the light is generated by the process of cathodoluminescence whereby a high-energy electron beam is scanned across a screen covered with an inorganic phosphor. The cathode-ray tube must have moderate depth to allow the electron beam to be magnetically or electrostatically scanned across the entire screen. For a flat-panel display technology to be successful, it must at least match the basic performance of a cathode-ray tube by having (1) full color, (2) full gray scale, (3) high efficiency and brightness, (4) the ability to display full-motion video, (5) wide viewing angle, and (6) wide range of operating conditions. Flat-panel displays should also provide the following benefits: (1) thinness and light weight, (2) good

linearity, (3) insensitivity to magnetic fields, and (4) no x-ray generation. These four attributes are not possible in a cathode-ray tube. Flat-panel displays can be divided into three types: transmissive, emissive, and reflective. A transmissive display has a backlight, with the image being formed by a spatial light modulator. A transmissive display is typically low in power efficiency; the user sees only a small fraction of the light from the backlight. An emissive display generates light only at pixels that are turned on. Emissive displays should be more efficient than transmissive displays, but due to low efficiency in the light generation process most emissive and transmissive flat panel displays have comparable efficiency. Reflective displays, which
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

13

reflect ambient light, are most efficient. They are particularly good where ambient light is very bright, such as direct sunlight. They do not work well in low-light environments. Most flat-panel displays are addressed as an X-Y matrix, the intersection of the row and column defining an individual pixel (see illustration). Matrix addressing provides the potential for an all-digital display. Currently available flat-panel display devices range from 1.25-cm (0.5-in.) diagonal displays used in headmounted systems to 125-cm (50-in.) diagonal plasma displays. Currently, most commercially manufactured flat-panel display devices are liquid-crystal displays (LCDs). The benchmark for flat-panel display performance is the active matrix liquid-crystal display (AMLCD). Most portable computers use AMLCDs. Competing flat-panel display technologies include electroluminescent displays, plasma display panels, vacuum fluorescent displays, and field-emission displays. Electroluminescent displays are often used in industrial and medical applications because of their ruggedness and wide range of operating temperatures. Plasma display panels are most often seen as large flat televisions, while vacuum fluorescent displays are used in applications where the information content is fairly low, such as the displays on appliances or in automobiles. Field-emission displays are the most recent of these flat-panel technologies. LED ! An LED display is a video display which uses light-emitting diodes. An LED panel is a small display, or a component of a larger display. They are typically used outdoors in store signs and billboards. LED panels are sometimes used as form of lighting, for the purpose of general illumination, task lighting, or even stage lighting rather than display. A light-emitting diode (LED) is an electronic light source. The LED was first invented in Russia in the 1920s, and introduced in America as a practical electronic component in 1962. Oleg Vladimirovich Losev was a radio technician who noticed that diodes used in radio receivers emitted light when current was passed through them. In 1927, he published details in a Russian journal of the first ever LED.

All early devices emitted low-intensity red light, but modern LEDs are available across the visible, ultraviolet and infra red wavelengths, with very high brightness. LEDs are based on the semiconductor diode. When the diode is forward biased (switched on), electrons are able to recombine with holes and energy is released in the form of light. This effect is called electroluminescence and the color of the light is determined by the energy gap of the semiconductor. The LED is usually small in area (less than 1 mm2) with integrated optical components to shape its radiation pattern and assist in reflection.
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

14

LEDs present many advantages over traditional light sources including lower energy consumption, longer lifetime, improved robustness, smaller size and faster switching. However, they are relatively expensive and require more precise current and heat management than traditional light sources. Applications of LEDs are diverse. They are used as low-energy indicators but also for replacements for traditional light sources in general lighting and automotive lighting. The compact size of LEDs has allowed new text and video displays and sensors to be developed, while their high switching rates are useful in communications technology. LCD Monitors ! (Liquid Crystal Display) A display technology that uses rod-shaped molecules (liquid crystals) that flow like liquid and bend light. Unenergized, the crystals direct light through two polarizing filters, allowing a natural background color to show. When energized, they redirect the light to be absorbed in one of the polarizers, causing the dark appearance of crossed polarizers to show. The more the molecules are twisted, the better the contrast and viewing angle. Because it takes less power to move molecules than to energize a light-emitting device, LCDs replaced the light-emitting diodes (LEDs) in digital watches in the 1970s. LCDs were then widely used for a myriad of monochrome displays and still are. In the 1990s, color LCD screens caused sales of laptop computers to explode, and in 2003, more LCD monitors were sold for desktop computers than CRTs.

A subpixel of a color LCD TYPES OF LCDs Passive Display Called "passive matrix" when used for computer screens and "passive display" when used for small readouts, all the active electronics (transistors) are outside of the display screen. Passive displays have
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

15

improved immensely, but do not provide a wide viewing angle, and submarining is generally noticeable. Following are the types of passive displays. TN - Twisted Nematic - 90 twist and Low-cost displays for consumer products and instruments. Black on gray/silver background. STN - Supertwisted Nematic- 180-270 twist and Used extensively on earlier laptops for mono and color displays. DSTN and FSTN provide improvements over straight STN (180 - green/blue on yellow background; 270 - blue on white/blue background). Dual Scan STN - Improves STN display by dividing the screen into two halves and scanning each half simultaneously, doubling the number of lines refreshed. Not as sharp as active matrix. Active Display (TFT) - Widely used for all LCD applications today (laptop and desktop computers, TVs, etc.). Known as "active matrix" displays, a transistor is used to control each subpixel on the screen. For example, a 1024x768 color screen requires 2,359,296 transistors; one for each red, green and blue subpixel (dot). Active matrix provides a sharp, clear image with good contrast and eliminates submarining. Fabrication costs were originally higher than passive matrix, which caused both types to be used in the early days of laptop flat panels. Active matrix displays use a 90 (TN) twist. Also called "thin film transistor LCD" (TFT LCD). See bad pixel. Reflective Vs. Backlit-Reflective screens used in many consumer appliances and handheld devices require external light and only work well in a bright room or with a desk lamp. Backlit and sidelit screens have their own light source and work well in dim lighting. Note that the meaning of "reflective" in this case differs from light reflecting off the front of the screen into the viewer's eyes. Output Device - Printer ! Printers are the most commonly used output devices for producing hard copy output. The various types of printers in used today are

Dot-Matrix Printers Inkjet Printers Drum Printers Laser Printers

Dot-Matrix Printers

A dot matrix printer or impact matrix printer is a type of computer printer with a print head that runs back and forth, or in an up and down motion, on the page and prints by impact, striking an ink-soaked cloth ribbon against the paper, much like a typewriter. Unlike a typewriter or daisy wheel printer, letters

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

16

Inkjet Printers Inkjet printers form characters and images by spraying small drops of ink on to the paper. They are the most common type of computer printer for the general user due to their low cost, high quality of output, capability of printing in different colors, and ease of use. If you ever look at a piece of paper that has come out of an inkjet printer, you know that:

The dots are extremely small, so small that they are tinier than the diameter of a human hair (70 microns). The dots are positioned very precisely, with resolutions of up to 1440x720 dots per inch. The dots can have different colors combined together to create photo-quality images.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

17

Laser Printers A type of printer that utilizes a laser beam to produce an image on a drum. The light of the laser alters the electrical charge on the drum wherever it hits. The drum is then rolled through a reservoir of toner, which is picked up by the charged portions of the drum. Finally, the toner is transferred to the paper through a combination of heat and pressure. This is also the way copy machines work. Because an entire page is transmitted to a drum before the toner is applied, laser printers are sometimes called page printers. There are two other types of page printers that fall under the category of laser printers even though they do not use lasers at all. One uses an array of LEDs to expose the drum, and the other uses LCDs. Once the drum is charged, however, they both operate like a real laser printer. One of the chief characteristics of laser printers is their resolution -- how many dots per inch (dpi) they lay down. The available resolutions range from 300 dpi at the low end to 1,200 dpi at the high end. By comparison, offset printing usually prints at 1,200 or 2,400 dpi. Some laser printers achieve higher resolutions with special techniques known generally as resolution enhancement. Laser printers produce very high-quality print and are capable of printing an almost unlimited variety of fonts. Most laser printers come with a basic set of fonts, called internal or resident fonts, but you can add additional fonts in one of two ways: Font Cartridges : Laser printers have slots in which you can insert font cartridges, ROM boards on which fonts have been recorded. The advantage of font cartridges is that they use none of the printer's memory. Soft Fonts : All laser printers come with a certain amount of RAM memory, and you can usually increase the amount of memory by adding memory boards in the printer's expansion slots. You can then copy fonts from a disk to the printer's RAM. This is called downloading fonts. A font that has been downloaded is

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

18

often referred to as a soft font, to distinguish it from the hard fonts available on font cartridges. The more RAM a printer has, the more fonts that can be downloaded at one time. Laser printers are controlled through page description languages (PDLs). There are two de facto standards for PDLs: PCL : Hewlett-Packard (HP) was one of the pioneers of laser printers and has developed a Printer Control Language (PCL) to control output. There are several versions of PCL, so a printer may be compatible with one but not another. In addition, many printers that claim compatibility cannot accept HP font cartridges. PostScript : This is the de facto standard for Apple Macintosh printers and for all desktop publishing systems.

Input Device - Plotters ! A plotter is a printer that interprets commands from a computer to make line drawings on paper with one or more automated pens. Unlike a regular printer, the plotter can draw continuous point-to-point lines directly from vector graphics files or commands. There are a number of different types of plotters: a drum plotter draws on paper wrapped around a drum which turns to produce one direction of the plot, while the pens move to provide the other direction; a flatbed plotter draws on paper placed on a flat surface; and an electrostatic plotter draws on negatively charged paper with positively charged toner.Plotters were the first type of printer that could print with color and render graphics and full-size engineering drawings. As a rule, plotters are much more expensive than printers. They are most frequently used for CAE (computeraided engineering) applications, such as CAD (computer-aided design) and CAM (computer-aided manufacturing). A plotter consists of an arm that moves across the paper on which the diagram or graph needs to be drawn . Apen moves along the arm. and the arm itself moves relative to the paper. Acombination of the two thus provides movement along the horizontal and vertical axes.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

19

In some plotters, the paper is held station ary while the arm and the pens move over it. This is called a flatbed plotter. In the other type of plotter, the paper is wrapped around a drum and anchored at anchored at both ends. The drum rotates while the pen moves laterally along a fixed rail. This is called a drum plotter. To draw clear and high-qualit diagrams, a plotter needs high-quality pens with special inks of different colors. A plotter can be connected to a PC through the parallel port. A plotter is more software-dependent than any other peripheral, and needs much more instructions than printer for producing output. Plotter are used in applications like CAD, which requir high-quality graphics on paper. Many of the plotters now available in the market are desktop models that can be used with PCs. Businesses typically use plotters to present an alysis in terms (bar charts, graphs, diagrams, etc.) as well as for engineering drawings. Two commanly type plotters are:

Drum Plotters Flatbed Plotters Drum Plotters In this plotter the pen moves in the horizontally and the drum rolls on the other axis. Generally it is a graphical output device, and it is generally used to plot drawings. the width of the plot is limited by the length of the drum. It is the first graphical output device produced to print large scaled engineering drawings.Colored prints can be made if you use colored ink.This electronic equipment used to plot large sized drawings on a tracing sheet. Plans for building ( architectural drawing) , engineering drawings , dress models ETC are drawn using suitable packages. These drawings are plotted on a tracing sheet, which can be used to produce a large no of blue prints. It is very good for line drawings but it is very slow. Here the pen is held in gantry and it moves in x-axis and the paper moves on y-axis.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

20

Flatbed Plotters This is a plotter where the paper is fixed on a flat surface and pens are moved to draw the image. This plotter can use several different colour pens to draw with. The size of the plot is limited only by the size of the plotter's bed.

Input Devices ! A piece of computer hardware that is used to enter and manipulate information on a computer. Basic input devices include the

Keyboard Mouse Digitizer Trackball Touch Screens Light Pens Microphones Bar code readers Joysticks Scanners Voice Systems
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

21

Input Device - Keyboard ! The keyboard is the most common input device for entering numeric and alphabetic data in to a computer system by pressing a set of keys which are mounted on the keyboard, which is connected to computer system. The keys on computer keyboards are often classified as follows: Alphanumeric Keys - letters and numbers. Punctuation Keys - comma, period, semicolon, and so on. Special Keys - function keys, control keys, arrow keys, Caps Lock key, and so on.

Input Device - Mouse ! A mouse is a small device that a computer user pushes across a desk surface in order to point to a place on a display screen and to select one or more actions to take from that position. A mouse consists of a metal or plastic housing or casing, a ball that sticks out of the bottom of the casing and is rolled on a flat surface, one or more buttons on the top of the casing, and a cable that connects the mouse to the computer. As the ball is moved over the surface in any direction, a sensor sends impulses to the computer that causes a mouse-responsive program to reposition a visible indicator (called a cursor) on the display screen. The positioning is relative to some variable starting place. Viewing the cursor's present position, the user readjusts the position by moving the mouse.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

22

The most conventional kind of mouse has two buttons on top: the left one is used most frequently. In the Windows operating systems, it lets the user click once to send a "Select" indication that provides the user with feedback that a particular position has been selected for further action. The next click on a selected position or two quick clicks on it causes a particular action to take place on the selected object. For example, in Windows operating systems, it causes a program associated with that object to be started. The second button, on the right, usually provides some less-frequently needed capability. For example, when viewing a Web page, you can click on an image to get a . popup menu that, among other things, lets you save the image on your hard disk. Some mouses have a third button for additional capabilities. Some mouse manufacturers also provide a version for left-handed people

Input Device - Digitizer ! A graphics tablet (or digitizing tablet, graphics pad, drawing tablet) is a computer input device that allows one to hand-draw images and graphics, similar to the way one draws images with a pencil and paper. These tablets may also be used to capture data or handwritten signatures. A graphics tablet (also called pen pad or digitizer) consists of a flat surface upon which the user may "draw" an image using an attached stylus, a pen-like drawing apparatus. The image generally does not appear on the tablet itself but, rather, is displayed on the computer monitor. Some tablets however, come as a functioning secondary computer screen that you can interact with directly using the stylus. Some tablets are intended as a general replacement for a mouse as the primary pointing and navigation device for desktop computers.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

23

Input Device - Light Pen ! A Light Pen is a pointing device shaped like a pen and is connected to a VDU. The tip of the light pen contains a light-sensitive element which, when placed against the screen, detects the light from the screen enabling the computer to identify the location of the pen on the screen. Light pens have the advantage of 'drawing' directly onto the screen, but this can become uncomfortable, and they are not as accurate as digitising tablets.

Input Device - Touch Screen ! A touchscreen is a display which can detect the presence and location of a touch within the display area. The term generally refers to touch or contact to the display of the device by a finger or hand. Touchscreens can also sense other passive objects, such as a stylus. However, if the object sensed is active, as with a light pen, the term touchscreen is generally not applicable. The ability to interact directly with a display typically indicates the presence of a touchscreen. The touchscreen has two main attributes. First, it enables one to interact with what is displayed directly on the screen, where it is displayed, rather than indirectly with a mouse or touchpad. Secondly, it lets one do so without requiring any intermediate device, again, such as a stylus that needs to be held in the hand. Such displays can be attached to computers or, as terminals, to networks. They also play a prominent role in the design of digital appliances such as the personal digital assistant (PDA), satellite navigation devices, mobile phones, and video games.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

24

Input Device - Image Scanners ! A scanner is a device that optically scans images, printed text, handwriting, or an object, and converts it to a digital image. Common examples found in offices are variations of the desktop (or flatbed) scanner where the document is placed on a glass window for scanning. Hand-held scanners, where the device is moved by hand, have evolved from text scanning "wands" to 3D scanners used for industrial design, reverse engineering, test and measurement, orthotics, gaming and other applications. Mechanically driven scanners that move the document are typically used for large-format documents, where a flatbed design would be impractical. Modern scanners typically use a charge-coupled device (CCD) or a Contact Image Sensor (CIS) as the image sensor, whereas older drum scanners use a photomultiplier tube as the image sensor. A rotary scanner, used for high-speed document scanning, is another type of drum scanner, using a CCD array instead of a photomultiplier. Other types of scanners are planetary scanners, which take photographs of books and documents, and 3D scanners, for producing three-dimensional models of objects. Another category of scanner is digital camera scanners, which are based on the concept of reprographic cameras. Due to increasing resolution and new features such as anti-shake, digital cameras have become an attractive alternative to regular scanners. While still having disadvantages compared to traditional scanners (such as distortion, reflections, shadows, low contrast), digital cameras offer advantages such as speed, portability, gentle digitizing of thick documents without damaging the book spine. New scanning technologies are combining 3D scanners with digital cameras to create full-color, photo-realistic 3D models of objects.

Input Device - Voice Systems ! voice input device A device in which speech is used to input data or system commands directly into a system. Such equipment involves the use of speech recognition processes, and can replace or supplement other input devices. Some voice input devices can recognize spoken words from a predefined vocabulary, some have to be trained for a particular speaker. Speech recognition (also known as automatic speech recognition or computer speech recognition) converts spoken words to machine-readable input (for example, to key presses, using the binary code for a

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

25

string of character codes). The term "voice recognition" is sometimes incorrectly used to refer to speech recognition, when actually referring to speaker recognition, which attempts to identify the person speaking, as opposed to what is being said. Confusingly, journalists and manufacturers of devices that use speech recognition for control commonly use the term Voice Recognition when they mean Speech Recognition. Input Device - Joystick ! A joystick is an input device consisting of a stick that pivots on a base and reports its angle or direction to the device it is controlling. Joysticks are often used to control video games, and usually have one or more push-buttons whose state can also be read by the computer. A popular variation of the joystick used on modern video game consoles is the analog stick. The joystick has been the principal flight control in the cockpit of many aircraft, particularly military fast jets, where centre stick or side-stick location may be employed. Joysticks are also used for controlling machines such as cranes, trucks, underwater unmanned vehicles and zero turning radius lawn mowers. Miniature finger-operated joysticks have been adopted as input devices for smaller electronic equipment such as mobile phone.

Input Device - Trackball ! A trackball is a pointing device consisting of a ball held by a socket containing sensors to detect a rotation of the ball about two axeslike an upside-down mouse with an exposed protruding ball. The user rolls the ball with the thumb, fingers, or the palm of the hand to move a cursor. Large tracker balls are common on CAD workstations for easy precision. Before the advent of the touchpad, small trackballs were common on portable computers, where there may be no desk space on which to run a mouse. Some small thumbballs clip onto the side of the keyboard and have integral buttons with the same function as mouse buttons. The trackball was invented by Tom Cranston and Fred Longstaff as part of the Royal Canadian Navy's DATAR system in 1952, eleven years before the mouse was invented. This first trackball used a Canadian five-pin bowling ball.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

26

When mice still used a mechanical design (with slotted 'chopper' wheels interrupting a beam of light to measure rotation), trackballs had the advantage of being in contact with the user's hand, which is generally cleaner than the desk or mousepad and doesn't drag lint into the chopper wheels. The late 1990s replacement of mouseballs by direct optical tracking put trackballs at a disadvantage and forced them to retreat into niches where their distinctive merits remained more important. Most trackballs now have direct optical tracking which follows dots on the ball. As with modern mice, most trackballs now have an auxiliary device primarily intended for scrolling. Some have a scroll wheel like most mice, but the most common type is a scroll ring which is spun around the ball. Kensington's SlimBlade Trackball similarly tracks the ball itself in three dimensions for scrolling.

Coordinate System! A method of representing points in a space of given dimensions by coordinates from an origin. Coordinate Transformations A coordinate transformation is a conversion from one system to another, to describe the same space. With every bijection from the space to itself two coordinate transformations can be associated: 1).such that the new coordinates of the image of each point are the same as the old coordinates of the original point (the formulas for the mapping are the inverse of those for the coordinate transformation). 2).such that the old coordinates of the image of each point are the same as the new coordinates of the original point (the formulas for the mapping are the same as those for the coordinate transformation). For example, in 1D, if the mapping is a translation of 3 to the right, the first moves the origin from 0 to 3, so that the coordinate of each point becomes 3 less, while the second moves the origin from 0 to -3, so that the coordinate of each point becomes 3 more.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

27

2D Coordinate Systems

Cartesian coordinate system Polar coordinate system Parabolic coordinate system Bipolar coordinates Hyperbolic coordinates Elliptic coordinates

3D Coordinate Systems

Cartesian coordinate system Cylindrical coordinate system Spherical coordinate system Parabolic coordinate system Parabolic cylindrical coordinates Paraboloidal coordinates Oblate spheroidal coordinates Prolate spheroidal coordinates Ellipsoidal coordinates Resolution ! Refers to the sharpness and clarity of an image. The term is most often used to describe monitors, printers, and bit-mapped graphic images. In the case of dot-matrix and laser printers, the resolution indicates the number of dots per inch. For example, a 300-dpi (dots per inch) printer is one that is capable of printing 300 distinct dots in a line 1 inch long. This means it can print 90,000 dots per square inch. For graphics monitors, the screen resolution signifies the number of dots (pixels) on the entire screen. For example, a 640-by-480 pixel screen is capable of displaying 640 distinct dots on each of 480 lines, or about 300,000 pixels. This translates into different dpi measurements depending on the size of the screen. For example, a 15-inch VGA monitor (640x480) displays about 50 dots per inch. Printers, monitors, scanners, and other I/O devices are often classified as high resolution, medium resolution, or low resolution. The actual resolution ranges for each of these grades is constantly shifting as the technology improves. The basic building block of any graphic image is a pixel, a contraction of "Picture Element", arranged in precise rows and columns. The number of rows and columns of pixels is referred to as the "resolution" of the image and is usually expressed by the number of horizontal pixels (rows) multiplied by the number of vertical pixels (columns), for example: 800*600, 1024*768, 1152*864. Note that these resolutions are

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

28

sized at a 4:3 ratio. The reason for this is that monitors are manufactured with a 4:3 aspect ratio, therefore for a pixel to appear square it must appear at the same 4:3 width to height aspect ratio. However, the resolution alone defines nothing except the physical size of the image. Each of these resolutions also has an associated "bit depth", which defines the number of colors that can be displayed. The bit depth refers to how many bits of data are associated with each pixel and are available to store a colour value. A 24 bit image, commonly referred to as "true colour", allows for the storage of 24 bits of data per pixel. To clarify the measurement, there are of course 8 bits in every byte. This raises the question of how colors are defined. Homogeneous Coordinates Syatem ! One of the many purposes of using homogeneous coordinates is to capture the concept of infinity. In the Euclidean coordinate system, infinity is something that does not exist. Mathematicians have discovered that many geometric concepts and computations can be greatly simplified if the concept of infinity is used. This will become very clear when we move to curves and surfaces design. Without the use of homogeneous coordinates system, it would be difficult to design certain classes of very useful curves and surfaces in computer graphics and computer-aided design. Let us consider two real numbers, a and w, and compute the value of a/w. Let us hold the value of a fixed and vary the value of w. As w getting smaller, the value of a/w is getting larger. If w approaches zero, a/w approaches to infinity! Thus, to capture the concept of infinity, we use two numbers a and w to represent a value v, v=a/w. If w is not zero, the value is exactly a/w. Otherwise, we identify the infinite value with (a,0). Therefore, the concept of infinity can be represented with a number pair like (a, w) or as a quotient a/w. Let us apply this to the xy-coordinate plane. If we replace x and y with x/w and y/w, a function f(x,y)=0 becomes f(x/w,y/w)=0. If function f(x,y) = 0 is a polynomial, multiplying it with wn will clear all denominators, where n is the degree of the polynomial. For example, suppose we have a line Ax + By + C = 0. Replacing x and y with x/w and y/w yields A(x/w) + B(y/w) + C = 0. Multiplying by w changes it to Ax + By + Cw = 0. Let the given equation be a second degree polynomial Ax2 + 2Bxy + Cy2 + 2Dx + 2Ey + F = 0. After replacing x and y with x/w and y/w and multiplying the result with w2, we have Ax2 + 2Bxy + Cy2 + 2Dxw + 2Eyw + Fw2 = 0 If you look at these two polynomials carefully, you will see that the degrees of all terms are equal. In the case of a line, terms x, y and w are of degree one, while in the second degree polynomial, all terms (i.e., x2, xy, y2, xw, yw and w2) are of degree two.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

29

Given a polynomial of degree n, after introducing w, all terms are of degree n. Consequently, these polynomials are called homogeneous polynomials and the coordinates (x,y,w) the homogeneous coordinates. Given a degree n polynomial in a homogeneous coordinate system, dividing the polynomial with wn and replacing x/w, y/w with x and y, respectively, will convert the polynomial back to a conventional one. For example, if the given degree 3 homogeneous polynomial is the following: x3 + 3xy2 - 5y2w + 10w3 = 0 the result is x3 + 3xy2 - 5y2 + 10 = 0 This works for three-dimension as well. One can replace a point (x, y, z) with (x/w, y/w, z/w) and multiply the result by w raised to certain power. The resulting polynomial is a homogeneous one. Converting a degree n homogeneous polynomial in x, y, z and w back to the conventional form is exactly identical to the two-variable case. Note Converting from a homogeneous coordinates to a conventional one is unique; but, converting a conventional coordinates to a homogeneous one is not.

A Simple Geometric Interpretation Given a homogeneous coordinate (x,y,w) of a point in the xy-plane, let us consider (x,y,w) to be a point in space whose coordinate values are x, y and w for the x-, y- and w- axes, respectively. The line joining this point and the coordinate origin intersects the plane w = 1 at a point (x/w, y/w, 1). Please verify this fact yourself. The following figure illustrates this concept.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

30

This transformation treats a two-dimensional homogeneous point as a point in three-dimensional space and projects (from the coordinate origin) this three-dimensional point to the plane w=1. Therefore, as a homogeneous point moves on a curve defined by homogeneous polynomial f(x,y,w)=0, its corresponding point moves in three-dimensional space, which, in turn, is projected to the plane w=1. Of course, (x/w,y/w) moves on a curve in plane w=1. The above figure also shows clearly that while the conversion from the conventional Euclidean coordinates to homogeneous coordinates is unique, the opposite direction is not because all points on the line joining the origin and (x,y,w) will be projected to (x/w,y/w,1). Scan Conversion ! Scan conversion or scan rate converting is a technique for changing the vertical / horizontal scan frequency of video signal for different purposes and applications. The device which performs this conversion is called scan converter. The application of scan conversion is wide and covers video projectors, cinema equipment , TV and video capture cards, standard and HDTV televisions, LCD monitors and many different aspects of picture and video processing. Scan conversion process, not only needs to make changes in synchronization (sync) frequencies, changes in picture information data rate are also mandatory in most cases. There are two distinct methods for doing the process: 1).Analog Methods (Non retentive, memory-less or real time method) This conversion is done using large numbers of delay cells and is appropriate for analog video. 2).Digital methods (Retentive or buffered method) In this methods , picture is stored in a line or frame buffer with n1 speed (data rate) and is read with n2 speed, several picture processing techniques are applicable when the picture is stored in buffer memory
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

31

including kinds of interpolation from simple to smart high order comparisons, motion detection and to improve the picture quality and prevent the conversion artifacts. Digital Differential Analyzer ! DDA is used for linear interpolation of variables over an interval between start and end point. DDAs are used for rasterization of lines, triangles and polygons. In its simplest implementation the DDA algorithm interpolates values in interval [(xstart, ystart) ... (xend, yend)] by computing for each xi the equations xi = xi1+1, yi = yi1 + y/x, where x = xend xstart and y = yend ystart.

Bresenham Line Algorithm ! The Bresenham line algorithm is an algorithm which determines which points in an n-dimensional raster should be plotted in order to form a close approximation to a straight line between two given points. It is commonly used to draw lines on a computer screen, as it uses only integer addition, subtraction and bit shifting, all of which are very cheap operations in standard computer architectures. It is one of the earliest algorithms developed in the field of computer graphics. A minor extension to the original algorithm also deals with drawing circles.

While algorithms such as Wu's algorithm are also frequently used in modern computer graphics because they can support antialiasing, the speed and simplicity of Bresenham's line algorithm mean that it is still important. The algorithm is used in hardware such as plotters and in the graphics chips of modern graphics cards. It can also be found in many software graphics libraries. Because the algorithm is very simple, it is often implemented in either the firmware or the hardware of modern graphics cards. Algorithm The common conventions that pixel coordinates increase in the down and right directions and that pixel centers have integer coordinates will be used. The endpoints of the line are the pixels at (x0, y0) and (x1, y1), where the first coordinate of the pair is the column and the second is the row. The algorithm will be initially presented only for the octant in which the segment goes down and to the right (x0x1 and y0y1), and its horizontal projection x1 x0 is longer than the vertical projection y1 y0 (in other words, the line has a slope less than 1 and greater than 0.) In this octant, for each column x

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

32

between x0 and x1, there is exactly one row y (computed by the algorithm) containing a pixel of the line, while each row between y0 and y1 may contain multiple rasterized pixels. Bresenham's algorithm chooses the integer y corresponding to the pixel center that is closest to the ideal (fractional) y for the same x; on successive columns y can remain the same or increase by 1. The general equation of the line through the endpoints is given by:

Since we know the column, x, the pixel's row, y, is given by rounding this quantity to the nearest integer:

The slope (y1 y0) / (x1 x0) depends on the endpoint coordinates only and can be precomputed, and the ideal y for successive integer values of x can be computed starting from y0 and repeatedly adding the slope. In practice, the algorithm can track, instead of possibly large y values, a small error value between 0.5 and 0.5: the vertical distance between the rounded and the exact y values for the current x. Each time x is increased, the error is increased by the slope; if it exceeds 0.5, the rasterization y is increased by 1 (the line continues on the next lower row of the raster) and the error is decremented by 1.0. In the following pseudocode sample plot(x,y) plots a point and abs returns absolute value:

function line(x0, x1, y0, y1) int deltax := x1 - x0 int deltay := y1 - y0 real error := 0 real deltaerr := deltay / deltax // Assume deltax != 0 (line is not vertical), int y := y0 for x from x0 to x1 plot(x,y) error := error + deltaerr if abs(error) 0.5 then y := y + 1 error := error - 1.0
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

33

Circle Drawing Algorithm ! The first thing we can notice to make our circle drawing algorithm more efficient is that circles centred at (0, 0) have eight-way symmetry.

Procedure Begin Plot(x,y); Plot(y,x); Plot(y,-x); Plot(x,-y); Plot(-x,-y); Plot(-y,-x); Plot(-y,x); Plot(-x,y) End; The equation for a circle is:

Circle_Points(x,y

:Integer);

where r is the radius of the circle So, we can write a simple circle drawing algorithm by solving the equation for y at unit x intervals using:
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

34

However, unsurprisingly this is not a brilliant solution!


Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

35

Firstly, the resulting circle has large gaps where the slope approaches the vertical Secondly, the calculations are not very efficient The square (multiply) operations The square root operation try really hard to avoid these! We need a more efficient, more accurate solution. Algorithm Begin {Circle} x := r; y := 0; d := 1 - r; Repeat Circle_Points(x,y); y := y + 1; If d < 0 Then d := d + 2*y + 1 Else Begin x := x - 1; d := d + 2*(y-x) + 1 End Until x < y End; {Circle}

Polar Coordinates ! The polar coordinate system is a two-dimensional coordinate system in which each point on a plane is determined by a distance from a fixed point and an angle from a fixed direction. The fixed point (analogous to the origin of a Cartesian system) is called the pole, and the ray from the pole with the fixed direction is the polar axis. The distance from the pole is called the radial coordinate or radius, and the angle is the angular coordinate, polar angle. Using polar coordinates x = r . cos y = r . sin From 0 to /4 (45), take small steps in and calculate x and y for each .
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

36

Bresenham's Circle Algorithm ! The midpoint circle algorithm is an algorithm used to determine the points needed for drawing a circle. The algorithm is a variant of Bresenham's line algorithm, and is thus sometimes known as Bresenham's circle algorithm, although not actually invented by Bresenham. In the mid-point circle algorithm we use eight-way symmetry so only ever calculate the points for the top right eighth of a circle, and then use symmetry to get the rest of the points. Assume that we have just plotted point (xk, yk). The next point choice between (xk+1, yk) and (xk+1, yk-1). We would like to the point that is nearest to the actual circle So how do we make this choice? is a choose

Lets re-jig the equation of the circle slightly to give us:


Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

37

fcirc(x,y) = x + y - r The equation evaluates as follows: By evaluating this function at the midpoint between the candidate pixels we can make our decision

Assuming we have just plotted the pixel at (xk,yk) so we need to choose between (xk+1,yk) and (xk+1,yk1). Our decision variable can be defined as: Pk = fcirc(xk+1, yk-1/2) = (xk+1)2 + (yk - 1/2)2 - r2 If pk < 0 the midpoint is inside the circle and and the pixel at yk is closer to the circle. Otherwise the midpoint is outside and yk-1 is closer. To ensure things are as efficient as possible we can do all of our calculations incrementally First consider:

or:

where yk+1 is either yk or yk-1 depending on the sign of pk. The first decision variable is given as:

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

38

Then if pk < 0 then the next decision variable is given as:

If pk > 0 then the decision variable is:

Ellipse ! Ellipse is the finite or bounded case of a conic section, the geometric shape that results from cutting a circular conical or cylindrical surface with an oblique plane. It is also the locus of all points of the plane whose distances to two fixed points add to the same constant. Ellipses also arise as images of a circle or a sphere under parallel projection, and some cases of perspective projection. Indeed, circles are special cases of ellipses. An ellipse is also the closed and bounded case of an implicit curve of degree 2, and of a rational curve of degree 2. It is also the simplest Lissajous figure, formed when the horizontal and vertical motions are sinusoids with the same frequency. The circle algorithm can be generalized to work for an ellipse but only four way symmetry can be used. Ellipse Properties Given two fixed positions F1 and F2 the sum of the two distances from these points to any point P on the ellipse (d1+d2) is constant.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

39

Ellipse Equation With the major and minor axes aligned with the coordinate axes the ellipse is said to be in standard position:

One Approach Take small steps in x from xc to xc+rx and calculate y:

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

40

Symmetry can be used Only one quadrant needs to be calculated since symmetry gives the three other quadrants.

2D Transformations ! Transformations are central in computer graphics. They are used to map from one space to another along the graphics pipeline. It is a process of changing the position of the object or may be combination of these. We know that an image of picture is drawn using the picture coordinates. This image of picture when displayed on display devices, we need to convert these picture coordinates to the display devices coordinates. This task is done by transformation. There are two types of transformations

Geometric Transformation Coordinate Transformations

Geometric Transformation A geometric transformation changes the plane or 3-dimensional space. In this, object itself is moved relative to a stationary coordinate system. Transformations in geometry include: translation, reflection, rotation, glide, all of which leaves the shape unchanged while a stretch, shear, enlargement and a topological transformation alters the original shape. Let us impose a coordinate system on a plane. An object in the plane can be considered as a set of points. Every Object point P has coordinate (X,Y) and object is the sum of all its coordinate points as shown in figure:

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

41

Coordinate Transformations A coordinate transformation is a conversion from one system to another, to describe the same space. In this, object is held stationary while the coordinate system is moved relative to the object. Suppose that we have two coordinate systems in the plane. The first system located at the origion O and has cordinate axes XY while the second system located at the origion O' and has cordinate axes X'Y'. Then each point in the plane has two coordinate descriptions: 1).(X,Y) w.r.t. XY coordinate system 2).(X',Y') w.r.t. X'Y' coordinate system If we think of the second system X'Y' as arising from a transformation applied to the first system XY, then we can say that a coordinate transformation has been applied as shown in figure:

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

42

Translation ! Repositioning an object along a straight line path from one coordinate location to another. Adding translation distances, tx and ty, to the original coordinate position. x'= y'= y + t y Matrix Form: x + tx

Example

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

43

Rotation! Rotation is Turning; changing of direction. A transformation where a figure turns through a specific angle about a fixed point, called the centre of rotation. The centre of rotation may be inside or outside the figure which is being transformed. If the figure is turned in an anti-clockwise direction, the rotation is considered positive, while a negative rotation turns the figure clockwise. A rotation moves a point along a cirular path centered at the origin (the pivot). It is a simple trigonometry problem to show that rotating P=[xy] counter-clockwise by (theta) radians produces a new point P'=[x'y'] given by x' = xcos ysin y' = ycos + ysin For example, pretend P=[1 1] and = / 2. Then P'=[-1 1], which you should agree correctly matches the description. we can express the rotation in matrix form

The Inverse of a Rotation The inverse of a rotation by radians can be created by rotating by - radians, but this is not the best way to view it. Consider the trigonometic identities

Scaling ! Scaling alters the size of an object. Pretend you are given a point p=(xyz) which is an object vertex, and let (sxsysz) be scale factors in xyz respectively. Then the point can be scaled to a new point by the matrix

In particular:
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

44

To scale (enlarge or shrink) the size of an object, each object vertex is multiplied by the scale matrix Sas shown above. Inverse of a Scale As long as we do not scale by zero, a scale can always be inverted (undone) by the matrix:

The product SS-1= S-1S=I, the 3 X 3 indentity matrix.

Mirror Reflection ! Mirror Reflection produces a mirror image of an object. In Matrix Form:

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

45

Shearing ! Distorts the shape of an object such that the transformed shape appears as if the object were composed of internal layer that had been caused to slide over each other. In Matrix Form:

x-direction shear of unit cube

y-direction shear of unit cube

Zooming ! A zooming user interface ZUI is a graphical environment where users can change the scale of the viewed area in order to see more detail or less, and browse through different documents. A ZUI is a type of graphical user interface (GUI). Information elements appear directly on an infinite virtual desktop (usually created using vector graphics), instead of in windows. Users can pan across the virtual surface in two dimensions and zoom into objects of interest. For example, as you zoom into a text object it may be
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

46

represented as a small dot, then a thumbnail of a page of text, then a full-sized page and finally a magnified view of the page. ZUIs use zooming as the main metaphor for browsing through hyperlinked information. Objects present inside a zoomed page can in turn be zoomed themselves to reveal further detail, allowing for recursive nesting and an arbitrary level of zoom. When the level of detail present in the resized object is changed to fit the relevant information into the current size, instead of being a proportional view of the whole object, it's called semantic zooming. Some experts consider the ZUI interface paradigm as a flexible and realistic successor to the traditional windowing GUI. But little effort is currently spent developing ZUIs, while there are ongoing efforts for developing GUIs Panning ! Panning is the horizontal movement of a camera as it scans a moving subject. And since someone out there whos mind is permanently blocked to technical jargon, as mine is, there was bound to be a huh? or two. So let me break it down a bit. When you pan youre moving your camera in synchronicity with your subject as it moves parallel to you. Still a little wordy huh? Its not as complicated as it sounds. Shake your head no. Go on and do it. Now cut that in half and pretend like youre moving you head along with a cheetah as is it flies by and youve got the idea. In order to pan successfully your camera has got to follow the subjects movement and match its speed and direction as perfectly as possible. Proper panning implies motion. However, panning creates the feeling of motion and speed without blurring the subject as a slow shutter speed sans panning would tend to do. Take for example the images below. This image is an example of panning. Notice how the car is clear and crisp but the rest of the image is blurred to show the motion of the vehicle. This effect was achieved by panning.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

47

Rubber Band Methods ! 1).Rubber Band Methods used to construct and position straight lines.

2).Rubber Band Methods used to construct circular arcs.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

48

3).Rubber Band Methods used to scale objects.

4).Rubber Band Methods used to distort objects by allowing only the line segments attached to a single vertex to change.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

49

Dragging ! Drag-and-Drop or DnD is the action of clicking on a virtual object and dragging it to a different location or onto another virtual object. In general, it can be used to invoke many kinds of actions, or create various types of associations between two abstract objects. As a feature, support for drag-and-drop is not found in all software, though it is sometimes a fast and easyto-learn technique for users to perform tasks. However, the lack of affordances in drag-and-drop implementations means that it not always obvious that an item can be dragged. The basic sequence involved in drag-and-drop is: 1).Press, and hold down, the button on the mouse or other pointing device, to "grab" the object 2)."Drag" the object/cursor/pointing device to the desired location 3)."Drop" the object by releasing the button.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

50

Tweening ! Short for in-betweening, the process of generating intermediate frames between two images to give the appearance that the first image evolves smoothly into the second image. Tweening is a key process in all types of animation, including computer animation. Sophisticated animation software enables you to identify specific objects in an image and define how they should move and change during the tweening process. Tweening in Flash is the process of creating an animation based on the start frame and end frame. For example, In the start frame, if you have and object at position A and in the end frame you move the object to position B and ask Flash to create a Tween, Flash will automatically generate the intermediate frames to show a smooth animation of the object moving from position A to B. Graphic Operations Clipping !

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

51

Clipping refers to the removal of part of a scene. Internal clipping removes parts of a picture outside a given region; external clipping removes parts inside a region. Clipping avoid drawing parts of primitives outside window.

Clipping refers to the removal of part of a scene. Window defines part of scene being viewed. Must draw geometric primitives only inside window. Internal clipping removes parts of a picture outside a given region. External clipping removes parts inside a region. Types of Clipping Points Clipping Lines Clipping Polygons Clipping Text Clipping Etc.

Before Clipping

After Clipping

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

52

Points Clipping ! Clipping a point (x; y) is easy assuming that the clipping window is an axis aligned rectangle defined by (xwmin; ywmin) and (xwmax; ywmax): Keep point (x; y) if xwmin ywmin y ywmax otherwise clip the point. x xwmax

Using normalized coordinates, we have (xwmin = -1; ywmin = -1) and (xwmax = 1; ywmax = 1).

Line Clipping ! Line clipping is the process of removing lines or portions of lines outside of an area of interest. Typically, any line or part thereof which is outside of the viewing area is removed.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

53

1).Line is always drawn if both end points lie inside rectangle. 2).Line is not drawn If both end points lie left, right, above, or below the clipping rectangle. 3).If none of the above, the line has to be clipped. Example 1).Find the part of a line inside the clip window

2).Find the part of a line inside the clip window

There are two common algorithms for line clipping:


Cohen-Sutherland Line Clipping Midpoint Subdivison Algorithm


Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

54

Cohen Sutherland Line Clipping ! This algorithm divides a 2D space into 9 parts, of which only the middle part (viewport) is visible. These 9 regions can be uniquely identified using a 4 bit code, often called an outcode. The 9 regions are: top-left, top-center, top-right, center-left, center, center-right, bottom-left, bottom-center, and bottom-right. If the beginning coordinate and ending coordinate both fall inside the viewport then the line is automatically drawn in its entirety. If both fall in the same region outside the viewport, it is disregarded and not drawn. If a line's coordinates fall in different regions, the line is divided into two, with a new coordinate in the middle. The algorithm is repeated for each section; one will be drawn completely, and the other will need to be divided again, until the line is only one pixel The algorithm includes, excludes or partially includes the line based on where the two endpoints are: 1).Both endpoints are in the viewport (bitwise OR of endpoints == 0): trivial accept. 2).Both endpoints are on the same side of the rectangle, which is not visible (bitwise AND of endpoints != 0): trivial reject. 3).Both endpoints are in different parts: In case of this non trivial situation the algorithm finds one of the two points that are outside the viewport (there is at least one point outside). The intersection of the outpoint and extended viewport border is then calculated (i.e. with the parametric equation for the line) and this new point replaces the outpoint. The algorithm repeats until a trivial accept or reject occurs. An outcode is computed for each of the two points in the line. The first bit is set to 1 if the point is above the viewport. The bits in the outcode represent: Top, Bottom, Right, Left. For example the outcode 1010 represents a point that is top-right of the viewport. Note that the outcodes for endpoints must be recalculated on each iteration after the clipping occurs.

**4-bit codes for end points in different regions**

Algorithm
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

55

For each line segment (1) compute clip codes (2) if both are 0 0 0 0 accept line segment else if c1 & c2 != 0 discard line segment else /* c1 & c2 = 0 */ clip against left clip against right clip against bottom clip against top if anything remains accept clipped segment

Example

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

56

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

57

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

58

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

59

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

60

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

61

Midpoint Subdivison Algorithm ! This algorithm is based on the bisection method. According to this method, we calculate the mid value of a line using the endpoints value and then we divide the line into two line segments. Each segment in partially visible category is divided again into smaller segments and categorized. The bisection and categorization process continuous untill all the segment are in visible or invisible category. The midpoint coordinates (Xm, Ym) of a line segment P1(X1Y1) p2(X2Y2) are given by: Xm = X1 + X2 / 2 Ym = Y1 + Y2 / 2

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

62

Algorithm 1).If every endpoint is in visible area of clipping window, then process is complete else continue next step. 2).If line is not visible then process is complete else continue next step. 3).If line is partially visible then divide line into smaller line segments using bisection method. Then go to step 1. 4).The bisection and categorization process continuous untill all the segment are in visible or invisible category.

Polygon Clipping ! A polygon is generally stored as a collection of vertices. Any clipping algorithm takes one collection, and outputs a new collection. A clipped polygon, after all, is also a polygon. Notice that the clipped polygon often will have more vertices than the unclipped one, but it can also have the same number, or less. If the unclipped polygon lies completely outside the clipping boundary, the clipped polygon even has zero vertices. Before Cliping

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

63

After Clipping

Open Polygon

Step by step Polygons Clipping Step1: Original Polygon

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

64

Step2: Clip Left

Step3: Clip Right

Step4: Clip Bottom

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

65

Step5: Clip Top

Sutherland Hodgman Algorithm ! Sutherland-Hodgman uses a divide-and-conquer strategy to attack the problem. First, it clips the polygon against the right clipping boundary. The resulting, partly clipped polygon is then clipped against the top boundary, and then the process is repeated for the two remaining boundaries. (Of course, it also works in another order.) In a way, it is the most natural thing to do. If you had to clip a paper polygon with a pair of scissors, you would probably proceed the same way.

Sutherland-Hodgman's divide-and-conquer strategy. To clip a polygon against a rectangular boundary window, successively clip against each boundary. Algorithm 1).Polygons can be clipped against each edge of the window one at a time. Windows/edge intersections, if any, are easy to find since the X or Y coordinates are already known.
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

66

2).Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges. 3).Note that the number of vertices usually changes and will often increases. 4).We are using the Divide and Conquer approach. To clip against one boundary, the algorithm loops through all polygon vertices. At each step, it considers two of them, called 'previous' and 'current.' First, it determines whether these vertices are inside or outside the clipping boundary. This, of course, is simply a matter of comparing the horizontal or vertical position to the boundary's position. Then, it applies the following simple rules: 1).If 'previous' and 'current' are both inside: Output 'current.'

2).If 'previous' is inside, and 'current' is outside: Output the intersection point of the corresponding edge and the clipping boundary.

3).If 'previous' and 'current' are both outside: Do nothing.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

67

4).If 'previous' is outside, and 'current' is inside: Output the intersection point, and then output 'current.'

This way, you get a new polygon, clipped against one boundary, and ready to be clipped against the next boundary. The method works, but has one disadvantage: To clip against all four boundaries, you have to store the intermediate, partly clipped polygons. It's evident that this is a costly operation. The Sutherland-Hodgman polygon clipping algorithm clips polygons against convex clipping windows. It does so by clipping the subject polygon against each clip edge producing intermediate subject polygons. Although we have not done so, the Sutherland-Hodgman algorithm easily extends to 3 dimensions. The Sutherland-Hodgman may produce connecting lines that were not in the original polygon. When the subject polygon is concave (not convex) these connecting lines may be undesirable artifacts. Difference between Cohen-Sutherland algorithm & Sutherland-Hodgman's polygon-clipping algorithm The difference between polygon-clipping strategy for a polygon and the Cohen-Sutherland algorithm for clipping a line: The polygon clipper clips against four edges in succession, whereas the line clipper tests the outcode to see which edge is crossed, and clips only when necessary. Window & Viewport ! Window The window on the screen. It is an infinite region where we can define what we want to display.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

68

Viewport Part of the display window where the contents of the clipping window is mapped to/drawn. A viewport is a rectangular region in computer graphics which area displayed on screen.

Windowing/Viewing Transformation ! Displaying an image of a picture involves mapping the coordinates of the points and lines that form the picture into the appropriate coordinates on the device or workstation where the image is to be displayed. This is done through the use of coordinate transformations known as viewing transformations. To perform a viewing transformation we deal with window and viewport. We use the several different coordinate systems as: Word Coordinate System (WCS) WCS describe the picture to be dislayed with coordinates. Physical Device Coordinate System(PDCS) PDCS is correspondos to a device where image of particular is to be displayed. Normalized Device Coordinate System(NDCS) NDCS is, in which display area of virtual display device is to unit (1X1) square whose lower left corner is at origin of the coordinate system. The Viewing Transformation is given by V = W.N
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

69

where N : Normalized Transformation maps Word Coordinate System to Normalized Device Coordinate System. W : Workstation Transformation maps Normalized Device Coordinate System to Physical Device Coordinate System. The viewing transformation involves scaling, so undesirable distortions may be introduced. For example, Circle in the window may be displayed as ellisped and square as rectangles. To avoid the distortion we use the concept of aspect ratio. The aspect ratio of a window or viewport is: a = Xmax - Xmin / Ymax - Ymin

Stack Based Fill Algorithm ! This algorithm is developed using stack for filling boundary defined region. A stack is a simply an array in which insertion or push of elements take place on the top of previously inserted elements. If we want to delete or pop an element from the stack then last element which was pushed onto stack will be poped first. Operations are performed as LIFO(Last In First Out) form. Steps for performed this operations are: 1).Push the starting or seed pixel onto stack. 2).Repeat while stack is not empty. (a).Delete the starting pixel from the stack and fill the pixel with a fixed color or value. (b).Check the surrounding pixels around seed pixel, if it is not previously filled with color and not a boundary pixel, then insert it onto stack otherwise ignored it. 3).End of step 2. 4).Now stack is empty and polygon is filled. Scan Line Seed Fill Algorithm ! A seed pixel on a span is popped from a stack containing the seed pixel. The span containing the seed pixel is filled to the right and left of seed pixel along a scan line until a boundary is found. The algorithm remembers the extreme left and the extreme right pixel in the span as xleft and xright. In the range of xleft x xright the scan lines immediately above & immediately below the current scan line are examined to see if they completely contain either boundary pixels or previously filled points. If
Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

70

these scan lines do not contain either boundary or previously filled pixels, then in the range Xleft x Xright the extreme right pixel in 0each span is marked as a seed pixel and pushed onto the stack. The Seed Fill Algorithms assume that at least one pixel is interior to a polygon or region is known. The algorithm then attempts to find and color or fill all other pixels interior to the region. The method of the seed fill is to start with a seed and recursively check neighboring points to fill in the polygon. 1).Start with a point known to be contained within the polygon. This is the seed. 2).Set the buffer for this seed and draw it. 3).Check each neighbor point. A neighbor point is a point for which the x and/or y values are exactly one greater or less than the current point's values. For each neighbor that is not a boundary point and is not already set, recursively call this function. The following will demonstrate this method. The polygon below is outlined by black pixels. Start with the point (23, 11), as the seed. This is filled in blue. The buffer would be set so as not to draw this pixel again. Then each neighbor would be checked. For example, let's check point (24, 10). This point is in the polygon, so we would recursively call the seed fill algorithm on it. At that point, the pixel would be drawn. Then the neighbors of point (24, 10) would be checked. If we checked pointer (25, 9), we would see that it is a border point and not draw it or recursively call the seed fill algorithm. You can see that this method would lead to a slightly different polygon than one filled with the scan-line method. The top and left edges would not be drawn in the seed fill since no edges are drawn.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

71

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

72

3D Modeling of Objects! 3D modeling is the process of developing a mathematical, wireframe representation of any threedimensional object (either inanimate or living) via specialized software. The product is called a 3D model. It can be displayed as a two-dimensional image through a process called 3D rendering or used in a computer simulation of physical phenomena. The model can also be physically created using 3D Printing devices. Models may be created automatically or manually. The manual modeling process of preparing geometric data for 3D computer graphics is similar to plastic arts such as sculpting. 3D models represent a 3D object using a collection of points in 3D space, connected by various geometric entities such as triangles, lines, curved surfaces, etc. Being a collection of data (points and other information), 3D models can be created by hand, algorithmically (procedural modeling), or scanned.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

73

3D models are widely used anywhere in 3D graphics. Actually, their use predates the widespread use of 3D graphics on personal computers. Many computer games used pre-rendered images of 3D models as sprites before computers could render them in real-time. Today, 3D models are used in a wide variety of fields. The medical industry uses detailed models of organs. The movie industry uses them as characters and objects for animated and real-life motion pictures. The video game industry uses them as assets for computer and video games. The science sector uses them as highly detailed models of chemical compounds. The architecture industry uses them to demonstrate proposed buildings and landscapes through Software Architectural Models. The engineering community uses them as designs of new devices, vehicles and structures as well as a host of other uses. In recent decades the earth science community has started to construct 3D geological models as a standard practice. Representation Almost all 3D models can be divided into two categories. Solid - These models define the volume of the object they represent (like a rock). These are more realistic, but more difficult to build. Solid models are mostly used for nonvisual simulations such as medical and engineering simulations, for CAD and specialized visual applications such as ray tracing and constructive solid geometry. Shell/boundary - these models represent the surface, e.g. the boundary of the object, not its volume (like an infinitesimally thin eggshell). These are easier to work with than solid models. Almost all visual models used in games and film are shell models. Modeling processes There are four popular ways to represent a model: Polygonal modeling - Points in 3D space, called vertices, are connected by line segments to form a polygonal mesh. Used for example by 3DS Max. The vast majority of 3D models today are built as textured polygonal models, because they are flexible and because computers can render them so quickly. However, polygons are planar and can only approximate curved surfaces using many polygons. NURBS modeling - NURBS Surfaces are defined by spline curves, which are influenced by weighted control points. The curve follows (but does not necessarily interpolate) the points. Increasing the weight for a point will pull the curve closer to that point. NURBS are truly smooth surfaces, not approximations using small flat surfaces, and so are particularly suitable for organic modeling. Maya and Rhino 3d are the most well-known commercial software that uses NURBS natively. Splines & Patches modeling - Like NURBS, Splines and Patches depend on curved lines to define the visible surface. Patches fall somewhere between NURBS and polygons in terms of flexibility and ease of use.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

74

Primitives modeling - This procedure takes geometric primitives like balls, cylinders, cones or cubes as building blocks for more complex models. Benefits are quick and easy construction and that the forms are mathematically defined and thus absolutely precise, also the definition language can be much simpler. Primitives modeling is well suited for technical applications and less for organic shapes. Some 3D software can directly render from primitives (like POV-Ray), others use primitives only for modeling and convert them to meshes for further operations and rendering. 3D Display Techniques ! A wire frame model is a visual presentation of a three dimensional or physical object used in 3D computer graphics. It is created by specifying each edge of the physical object where two mathematically continuous smooth surfaces meet, or by connecting an object's constituent vertices using straight lines or curves. The object is projected onto the computer screen by drawing lines at the location of each edge.

Using a wire frame model allows visualization of the underlying design structure of a 3D model. Traditional 2-dimensional views and drawings can be created by appropriate rotation of the object and selection of hidden line removal via cutting planes. Since wireframe renderings are relatively simple and fast to calculate, they are often used in cases where a high screen frame rate is needed (for instance, when working with a particularly complex 3D model, or in real-time systems that model exterior phenomena). When greater graphical detail is desired, surface textures can be added automatically after completion of the initial rendering of the wireframe. This allows the designer to quickly review changes or rotate the object to new desired views without long delays associated with more realistic rendering. 3D Coordinate System! In a 3D Cartesian coordinate system, a point P is referred to by three real numbers (coordinates), indicating the positions of the perpendicular projections from the point to three fixed, perpendicular, graduated lines, called the axes which intersect at the origin. Often the x-axis is imagined to be horizontal and pointing roughly toward the viewer (out of the page), the y-axis is also horizontal and pointing to the right, and the z-axis is vertical, pointing up. The system is called right-handed if it can be rotated so that the three axes are in the position as shown in the figure above. The x-coordinate of of the point P in the figure is a, the y-coordinate is b, and the z-coordinate is c.

Gayathri D, DOS IN CS, MGM

COMPUTER GRAPHICS

75

To define a cylindrical coordinate system, we take an axis (usually called the z-axis) and a perpendicular plane, on which we choose a ray (the initial ray) originating at the intersection of the plane and the axis (the origin). The coordinates of a point P are the polar coordinates (r, f) of the projection of P on the plane, and the coordinate z of the projection of P on the z-axis. The coordinate r is always positive and the range of f is from 0 to 2p (360o). To transform from Cartesian to cylindrical coordinates and vice versa, we use the transformation equations: x = r cosf, r = (x2 + y2)1/2, y = r sinf, z = z, z = z.

f = tan-1(y/x),

To define spherical coordinates, we take an axis (the polar axis) and a perpendicular plane (the equatorial plane), on which we choose a ray (the initial ray) originating at the intersection of the plane and the axis (the origin O). The coordinates of a point P are the distance r from P to the origin; the angle q (zenith) between the line OP and the positive polar axis; and the angle f (azimuth) between the initial ray and the projection of OP onto the equatorial plane. The range of f is from 0 to 2p (360o)., and the range of q is from 0 to p (180o). To transform from Cartesian to spherical coordinates and vice versa, we use the transformation equations: x = r sinq cosf, y = r sinq sinf, z = r cosq,

r = (x2 + y2 + z2)1/2, q =tan-1(z/(x2+y2)1/2), f = tan-1(y/x).

Gayathri D, DOS IN CS, MGM

Vous aimerez peut-être aussi