0% found this document useful (0 votes)
14 views

Unit 1 CG

Notes

Uploaded by

Ritika Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Unit 1 CG

Notes

Uploaded by

Ritika Yadav
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 25

Unit 1

Computer Graphics
Refresh Cathode-Ray Tubes
Figure below illustrates the basic operation of a CRT. A beam of electrons (cathode rays), emitted by an electron gun, passes
through focusing and deflection systems that direct the beam toward specified positions on the phosphomted 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.

The primary components of an electron gun in a CRT are the heated metal cathode and a control grid. Heat is supplied to the
cathode by directing a current through a coil of wire, called the filament, inside the cylindrical cathode structure. This causes
electrons to be 'killed off" the hot cathode surface. In the vacuum inside the CRT envelope, the free, 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 overview of Graphics Systems 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.

Intensity of the electron beam is controlled by setting voltage levels on the control grid, which is a metal cylinder that fits
over the cathode. A high negative voltage applied to the control grid will shut off the beam by repelling electrons and
stopping them from passing through the small hole at the end of the control grid structure. A smaller negative voltage on
the control grid simply decreases the number of electrons passing through. Since the amount of light emitted by the
phosphor coating depends on the number of electrons striking the screen, we control the brightness of a display by varying
the voltage on the control grid.
The maximum number of points that can be displayed without overlap on a CRT is referred to as the resolution. A more
precise definition of resolution is the number of points per centimeter that can be plotted horizontally and vertically,
although it is often simply stated as the total number of points in each direction. Typical resolution on high-quality systems is
1280 by 1024, with higher resolutions available on many systems. High-resolution systems are often referred to as high-
definition systems.

Raster-Scan Displays
The most common type of graphics monitor employing a CRT is the raster-scan display, 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. 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 a 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. Each screen point is referred to as a pixel or pel (shortened forms of picture element).
The capability of a raster-scan system to store intensity information for each screen point makes it well suited for the
realistic display of scenes containing subtle shading and color patterns. Home television sets and printers are examples of
other systems using raster-scan methods.

In a simple black-and-white system, each screen point is either on or off, so only one bit per pixel is needed to control the
intensity of screen positions. For a bit level system, a bit value of 1 indicates that the electron beam is to be turmed on at
that position, and a value of 0 indicates that the beam intensity is to be off.

Additional bits are needed when color and intensity variations can be displayed. Up to 24 bits per pixel are included in high-
quality systems, which can require severaI megabytes of storage for the frame buffer, depending on the resolution of the
system. A system with 24 bits per pixel and a screen resolution of 1024 by 1024 requires 3 megabytes of storage for the
frame buffer. On a black-and-white

system with one bit per pixeI, the frame buffer is commonly called a bitmap. For systems with multiple bits per pixel, the
frame buffer is often referred to as a pixmap.

Refreshing on raster-scan displays is carried out at the rate of 60 to 80 frames per second, although some systems are
designed for higher refresh rates. Sometimes, refresh rates are described in units of cycles per second, or Hertz (Hz), where
a cycle corresponds to one frame. Using these units, we would describe a refresh rate of 60 frames per second as simply 60
Hz.
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. The return to the left of the screen, after refreshing each scan line, is called the horizontal retrace of the
electron beam. And at the end of each frame (displayed in 1/80th to 1/60th of a second), the electron beam returns (vertical
retrace) to the top left comer of the screen to begin the next frame.

On some raster-scan systems (and in TV sets), each frame is displayed in two passes using an interlaced refresh
procedure. In the first pass, the beam sweeps across every other scan line fmm top to bottom. Then after the vertical
retrace, the beam sweeps out the remaining scan lines . Interlacing of the scan lines in this way allows us to see the entire s
m n displayed in one-half the time it would have taken to sweep amss all the lines at once fmm top to bottom.

Interlacing is primarily used with slower refreshing rates. On an older, 30 frameper-second, non interlaced display, for
instance, some flicker is noticeable. But with interlacing, each of the two passes can be accomplished in 1/60th of a second,
which brings the refresh rate nearer to 60 frames per second. This is an effective technique for avoiding flicker, providing
that adjacent scan lines contain similar display information.

Random-Scan Displays

When operated as a random-scan display unit, a CRT has the electron beam directed only to the parts of the screen where a
picture is to be drawn. Random scan monitors draw a picture one line at a time and for this reason are also referred to as
vector displays (or stroke-writing or calligraphic displays). The component lines of a picture can be drawn and refreshed by a
random-scan system in any specified order. A pen plotter operates in a similar way and is an example of a random-scan,
hard-copy device. Refresh rate on a random-scan system depends on the number of lines to be displayed. Picture definition
is now stored as a set of line drawing commands in an area of memory r e f e d to as the refresh display file. Sometimes the
refresh display file is called the display list, display program, or simply the refresh buffer. 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 line drawing

commands have been 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. High quality vector systems are capable of
handling approximately 100,000 "short" lines at this refresh rate. When a small set of lines is to be displayed, each refresh
cycle is delayed to avoid refresh rates greater than 60 frames per second. Otherwise, faster refreshing of the set of lines
could burn out the phosphor.
Random-scan systems are designed for line drawing applications and cannot display realistic shaded scenes. Since picture
definition is stored as a set of line drawing instructions and not as a set of intensity values for all screen points, vector
displays generally have higher resolution than raster systems. Also, vector displays produce smooth line drawings because
the CRT beam directly follows the line path. A raster system, in contrast, produces jagged lines that are plotted as point sets.

Random Scan Raster Scan

1. It has high Resolution 1. Its resolution is low.

2. It is more expensive 2. It is less expensive

3. Any modification if needed is easy 3.Modification is tough

4. Solid pattern is tough to fill 4.Solid pattern is easy to fill

5. Refresh rate depends or resolution 5. Refresh rate does not depend on the
picture.

6. Only screen with view on an area is 6. Whole screen is scanned.


displayed.

7. Beam Penetration technology come under 7. Shadow mark technology came under
it. this.

8. It does not use interlacing method. 8. It uses interlacing

9. It is restricted to line drawing applications 9. It is suitable for realistic display.

Color CRT Monitors


A CRT monitor displays color pictures by using a combination of phosphors that emit different-colored light. By combining
the emitted light from the different phosphors, a range of colors can be generated. The two basic techniques for producing

color displays with a CRT are the beam-penetration method and the shadow-mask method. The beam-penetration method
for displaying color pictures has been used with random-scan monitors. Two layers of phosphor, usually red and
green, are coated onto the inside of the CRT screen, and the displayed color depends on how far the electron beam
penetrates into the phosphor layers. A beam of slow electrons excites only the outer red layer. A beam of very fast
electrons penetrates through the red layer and excites the inner green layer. At intermediate beam speeds,
combinations of red and green light are emitted to show two additional colors, orange and yellow. The speed of the
electrons, and hence the screen color at any point, is controlled by the beam-acceleration voltage. Beam penetration

has been an inexpensive way to produce color in random-scan monitors, but only four colors are possible, and the
quality of pictures is not as good as with other methods.

Shadow-mask methods are commonly used in raster scan systems (including color TV) because they produce a
much wider range of colors than the beam penetration method. A shadow-mask CRT has three phosphor color
dots at each pixel position. One phosphor dot emits a red light, another emits a green light, and the third emits a
blue light. This type of CRT has three electron guns, one for each color dot, and a shadow-mask grid just behind
the phosphor-coated screen.

It illustrates the delta shadow-mask method, commonly used in color CRT systems. The three electron beams are
deflected and focused as a group onto the shadow mask, which contains a series of holes aligned with the

phosphor-dot patterns. When the three beams pass through a hole in the shadow mask, they activate a dot
triangle, which appears as a small color spot on the screen. The phosphor dots in the triangles are arranged so
that each electron beam can activate only its corresponding color dot when it passes through the shadow mask.
Another configuration for the three electron guns is an in-line arrangement in which the three electron guns, and
the corresponding red-green-blue color dots on the screen, are aligned along one scan line instead of in a
triangular pattern. This in-line arrangement of electron guns is easier to keep in alignment and is commonly used
in high-resolution color CRTs.

Other Display devices


Direct-View Storage Tubes

An alternative method for maintaining a screen image is to store the picture information inside the CRT instead of
refreshing the screen. Direct-view storage tube (DVST) stores the picture information as a charge distribution just
behind the phosphor-coated screen. Two electron guns are used in a DVST. One, the primary gun, is used to store
the picture pattern; the second, the flood gun, maintains the picture display.
A DVST monitor has both disadvantages and advantages compared to the refresh CRT. Because no refreshing is
needed, very complex pictures can be displayed at very high resolutions without flicker. Disadvantages of DVST
systems are that they ordinarily do not display color and that selected parts of a picture cannot he erased. To
eliminate a picture section, the entire screen must be erased and the modified picture redrawn. The erasing and
redrawing process can take several seconds for a complex picture. For these reasons, storage displays have

been largely replaced by raster systems.

Flat Panel Display:


The Flat-Panel display refers to a class of video devices that have reduced volume, weight and power requirement
compare to CRT.

Example: Small T.V. monitor, calculator, pocket video games, laptop computers, an advertisement board in
elevator.
1. Emissive Display: The emissive displays are devices that convert electrical energy into light. Examples are
Plasma Panel, thin film electroluminescent display and LED (Light Emitting Diodes).

2. Non-Emissive Display: The Non-Emissive displays use optical effects to convert sunlight or light from some
other source into graphics patterns. Examples are LCD (Liquid Crystal Device).

Plasma Panel Display

Plasma panels, also called gas-discharge displays, are constructed by filling the region between two glass plates
with a mixture of gases that usually includes neon. A series of vertical conducting ribbons is placed on one glass
panel, and a set of horizontal ribbons is built into the other glass panel. Firing voltages applied to a pair of
horizontal and vertical conductors cause the gas at the intersection of the two conductors to break down into a
glowing plasma of electrons and ions. Picture definition is stored in a refresh buffer, and the firing voltages are
applied to refresh the pixel positions (at the intersections of the conductors) 60 times per second. Alternate
methods are used to provide faster application of the firing voltages, and thus brighter displays. Separation

between pixels is provided by the electric field of the conductors.

One disadvantage of plasma panels has been that they were strictly monochromatic devices, but systems have
been developed that are now capable of displaying color and grayscale.

Thin-film electroluminescent displays are similar in construction to a plasma panel. The difference is that the
region between the glass plates is filled with a phosphor, such as zinc sulfide doped with manganese, instead of a
gas. When a sufficient high voltage is applied to a pair of crossing electrodes, the phosphor becomes a conductor
in the area of the intersection of the two electrodes. Electrical energy is then absorbed by the manganese atoms,
which then release the energy as a spot of light similar to the glowing plasma effect in a plasma panel.
Electroluminescent displays require more power than plasma panels, and good color and gray scale displays are
hard to achieve.

LED (Light Emitting Diode)


In an LED, a matrix of diodes is organized to form the pixel positions in the display and picture definition is stored
in a refresh buffer. Data is read from the refresh buffer and converted to voltage levels that are applied to the
diodes to produce the light pattern in the display.

LCD (Liquid Crystal Display)


Liquid Crystal Displays are the devices that produce a picture by passing polarized light from the surroundings or
from an internal light source through a liquid-crystal material that transmits the light.

LCD uses the liquid-crystal material between two glass plates; each plate is the right angle to each other between
plates liquid is filled. One glass plate consists of rows of conductors arranged in vertical direction. Another glass
plate is consisting of a row of conductors arranged in horizontal direction. The pixel position is determined by the
intersection of the vertical & horizontal conductor. This position is an active part of the screen.

Liquid crystal display is temperature dependent. It is between zero to seventy degree Celsius. It is flat and requires
very little power to operate.

Advantage:

1. Low power consumption.

2. Small Size

3. Low Cost

Disadvantage:

1. LCDs are temperature-dependent (0-70°C)

2. LCDs do not emit light; as a result, the image has very little contrast.

3. LCDs have no color capability.

4. The resolution is not as good as that of a CRT.

Aliasing and anti-aliasing in Raster technology


In computer graphics, aliasing is the stair-stepped appearance of diagonal lines when there are not enough pixels
in the image or on screen to represent them realistically. Also called "stair-stepping" and "jaggies."

Antialiasing is a technique used in computer graphics to remove the aliasing effect. The aliasing effect is the
appearance of jagged edges or “jaggies” in a rasterized image (an image rendered using pixels). The problem of
jagged edges technically occurs due to distortion of the image when scan conversion is done with sampling at a
low frequency, which is also known as Undersampling. Aliasing occurs when real-world objects which comprise
smooth, continuous curves are rasterized using pixels. The cause of anti-aliasing is Undersampling.
Methods of Anti-Aliasing (AA)

There are four methods of Anti-Aliasing. These methods are mentioned below.

 High-Resolution Display

 Post-Fingering

 Pre-Filtering

 Pixel Phasing

1. Using High-Resolution Display

One way to reduce the aliasing effect and increase the sampling rate is to simply display objects at a higher
resolution. Using high resolution, the jaggies become so small that they become indistinguishable from the human
eye. Hence, jagged edges get blurred out and edges appear smooth.

Practical applications: For example, retina displays in Apple devices, and OLED displays have high pixel density
due to which jaggies formed are so small that they blurred and are indistinguishable by our eyes.

2. Post Filtering (Supersampling)

In this method, we are increasing the sampling resolution by treating the screen as if it’s made of a much more
fine grid, due to which the effective pixel size is reduced. But the screen resolution remains the same. Now,
intensity from each subpixel is calculated and the average intensity of the pixel is found from the average of
intensities of subpixels. Thus we do sampling at a higher resolution and display the image at a lower resolution or
resolution of the screen, hence this technique is called supersampling. This method is also known as post filtration
as this procedure is done after generating the rasterized image.
Practical Applications: In gaming, SSAA (Supersample Antialiasing) or FSAA (Full-Scene Antialiasing) is used to
create the best image quality. It is often called pure AA and hence is very slow and has a very high computational
cost. This technique was widely used in the early days when better AA techniques were not available. Different
modes of SSAA available are: 2X, 4X, 8X, etc. denoting that sampling is done x times (more than) the current
resolution. A better style of Anti-Aliasing is MSAA (Multisampling Antialiasing) which is a faster and more
approximate style of supersampling AA. It has a lesser computational cost. Better and more sophisticated
supersampling techniques are developed by graphics card companies like CSAA by NVIDIA and CFAA by AMD.

3. Pre-Filtering (Area Sampling)

In area sampling, pixel intensities are calculated proportionally to areas of overlap of each pixel with objects to be
displayed. Here pixel color is computed based on the overlap of the scene’s objects with a pixel area.

Example: Suppose, a line passes through two pixels. The pixel covering a bigger portion(90%) of the line displays
90% intensity while less area(10%) covering the pixel displays 10-15% intensity. If the pixel area overlaps with
different color areas, then the final pixel color is taken as an average of colors of the overlap area. This method is
also known as pre-filtering as this procedure is done BEFORE generating the rasterized image. It’s done using
some graphics primitive algorithms.

4. Pixel Phasing

It’s a technique to remove aliasing. Here pixel positions are shifted to nearly approximate positions near object
geometry. Some systems allow the size of individual pixels to be adjusted for distributing intensities which is
helpful in pixel phasing.

Types of Anti-Aliasing

Anti-Aliasing can be broadly classified into two broad categories. These two categories are listed below.

 Spatial Anti-Aliasing: Spatial Anti-Aliasing is a technique that is used in cases when a low-resolution picture
has jaggies. It is used to minimize the distortion effects upon the representation of the higher image to a
lower image. These are classified as:

 Super Sampling Anti-Aliasing

 Multi-Sample Anti-Aliasing

 Post-Process Anti-Aliasing: Post-Processing Anti-Aliasing is a technique used when every process is blurred
in the rendering processing. It is a quicker technique in comparison to Spatial Anti-Aliasing. It is of the
following types:
 Temporal AntiAliasing

 Enhanced Subpixel Morphological Antialiasing

Applications of Anti-Aliasing Techniques

 Compensating for Line Intensity Differences: When a horizontal line and a diagonal line are plotted on the
raster display, the number of pixels required to display both lines is the same, even though the diagonal
line is 1.414 times larger than the horizontal line. This leads to a decrease in the intensity of the longer
line. To compensate for this decrease in intensity, the intensity of pixels is assigned according to the length
of the line using anti-aliasing techniques.

 Anti-Aliasing Area Boundaries: Anti-aliasing concepts can also be applied to remove jaggies along area
boundaries. These procedures can be applied to scanline algorithms to smoothen out area boundaries. if
repositioning of pixels is possible then pixel positions are adjusted to positions closer to area boundaries.
Other methods adjust pixel intensity at a boundary position according to the percent of pixel area inside
the boundary. These methods effectively smoothen out area boundaries.

Input Devices

The Input Devices are the hardware that is used to transfer transfers input to the computer. The data can be in the
form of text, graphics, sound, and text. Output device display data from the memory of the computer. Output can be
text, numeric data, line, polygon, and other objects.

Keyboard:

The most commonly used input device is a keyboard. The data is entered by pressing the set of keys. All keys are
labeled. A keyboard with 101 keys is called a QWERTY keyboard.

The keyboard has alphabetic as well as numeric keys. Some special keys are also available.
1. Numeric Keys: 0, 1, 2, 3, 4, 5, 6, 7, 8, 9

2. Alphabetic keys: a to z (lower case), A to Z (upper case)

3. Special Control keys: Ctrl, Shift, Alt

4. Special Symbol Keys: ; , " ? @ ~ ? :

5. Cursor Control Keys: ↑ → ← ↓

6. Function Keys: F1 F2 F3....F9.

7. Numeric Keyboard: It is on the right-hand side of the keyboard and used for fast entry of numeric data.

Function of Keyboard:

1. Alphanumeric Keyboards are used in CAD. (Computer Aided Drafting)

2. Keyboards are available with special features line screen co-ordinates entry, Menu selection or graphics
functions, etc.

3. Special purpose keyboards are available having buttons, dials, and switches. Dials are used to enter scalar
values. Dials also enter real numbers. Buttons and switches are used to enter predefined function values.
Advantage:

1. Suitable for entering numeric data.

2. Function keys are a fast and effective method of using commands, with fewer errors.

Disadvantage:

1. Keyboard is not suitable for graphics input.

Mouse:

A Mouse is a pointing device and used to position the pointer on the screen. It is a small palm size box. There are
two or three depression switches on the top. The movement of the mouse along the x-axis helps in the horizontal
movement of the cursor and the movement along the y-axis helps in the vertical movement of the cursor on the
screen. The mouse cannot be used to enter text. Therefore, they are used in conjunction with a keyboard.

Trackball
It is a pointing device. It is similar to a mouse. This is mainly used in notebook or laptop computer, instead of a
mouse. This is a ball which is half inserted, and by changing fingers on the ball, the pointer can be moved

Advantage:

1. Trackball is stationary, so it does not require much space to use it.


2. Compact Size

Spaceball:
It is similar to trackball, but it can move in six directions where trackball can move in two directions only. The
movement is recorded by the strain gauge. Strain gauge is applied with pressure. It can be pushed and pulled in
various directions. The ball has a diameter around 7.5 cm. The ball is mounted in the base using rollers. One-third
of the ball is an inside box, the rest is outside.

Applications:

1. It is used for three-dimensional positioning of the object.

2. It is used to select various functions in the field of virtual reality.

3. It is applicable in CAD applications.

4. Animation is also done using spaceball.

5. It is used in the area of simulation and modeling.

Joystick:

A Joystick is also a pointing device which is used to change cursor position on a monitor screen. Joystick is a stick
having a spherical ball as its both lower and upper ends as shown in fig. The lower spherical ball moves in a socket.
The joystick can be changed in all four directions. The function of a joystick is similar to that of the mouse. It is
mainly used in Computer Aided Designing (CAD) and playing computer games.

Light Pen
Light Pen (similar to the pen) is a pointing device which 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 its tip is
moved over the monitor screen, and pen button is pressed, its photocell sensing element detects the screen
location and sends the corresponding signals to the CPU.

Uses:

1. Light Pens can be used as input coordinate positions by providing necessary arrangements.

2. If background color or intensity, a light pen can be used as a locator.

3. It is used as a standard pick device with many graphics system.

4. It can be used as stroke input devices.

5. It can be used as valuators

Digitizers:

The digitizer is an operator input device, which contains a large, smooth board (the appearance is similar to the
mechanical drawing board) & an electronic tracking device, which can be changed over the surface to follow
existing lines. The electronic tracking device contains a switch for the user to record the desire x & y coordinate
positions. The coordinates can be entered into the computer memory or stored or an off-line storage medium such
as magnetic tape.

Advantages:

1. Drawing can easily be changed.


2. It provides the capability of interactive graphics.

Disadvantages:

1. Costly

2. Suitable only for applications which required high-resolution graphics.

Input Techniques

Rubber-Band techniques
Rubber banding is a popular technique of drawing geometric primitives such as line, polylines, rectangle, circle and
ellipse on the computer screen.

It becomes an integral part and de facto standard with the graphical user interface (GUI) for drawing and is almost
universally accepted by all windows based applications.

The user specifies the line in the usual way by positioning its two endpoints. As we move from the first endpoint to
the second, the program displays a line from the first endpoint to the cursor position, thus he can see the lie of the
line before he finishes positioning it.

The effect is of an elastic line stretched between the first endpoint and the cursor; hence the name for these
techniques.

Selection of Terminal Point of the Line:


The user moves the cursor to the appropriate position and selects.

Then, as the cursor is moved, the line changes taking the latest positions of the cursors as the end-point.

As long as the button is held down, the state of the rubber band is active.

The process is explained with the state transition diagram of rubber banding in fig:
Advantage:

1. It is used for drawing all geometric entities such as line, polygon, circle, rectangle, ellipse, and other curves.

2. It is easy to understand and implement.

Disadvantage:

1. It requires computational resources like software and CPU speed.

2. Expensive

Dragging

Dragging is used to move an object from one position to another position on the computer screen. To drag any
other object, first, we have to select the object that we want to move on the screen by holding the mouse button
down. As cursor moved on the screen, the object is also moved with the cursor position. When the cursor reached
the desired position, the button is released.

The following diagram represents the dragging procedure:


Positioning Techniques:
 It very basic technique of graphical input. It is also known as locating.

 With the help of input device, user indicates position on the screen. To display object this position marks
location. Example: input position can be used to insert symbol to specify endpoint of line.

 The process of positioning involves two steps, in first step user have to move cursor to desired spot on
screen and in second step user inform computer by pressing key or button.

 The positioning is very often used in geometric modeling applications, where if user wants to define new
element of model or to change position of already existing model.

Positioning Constraints :
Constraint is rule which is used by user to change value of coordinates to produce required alignment of displayed
coordinates. There are 3 types of positioning constraints which are as follows:
Directional constraint –
Directional constraint is used to straight line segment. It is basically used to create horizontal and vertical lines;
without thinking about endpoint coordinates. The user specifies two endpoints. Usually program specify line
drawn by user is more nearly horizontal or vertical and draws line parallel to axis which he wants to draw. The
distance between two input points is length of line.

Modular constraint –
This constraint uses grid of rectangular areas which is displayed o screen. Any input coordinate position is to be
present on nearest intersection of two grid lines. This constraint is applicable to symbols as well as line endpoints.
In the above figure, it is shown that there is usage of grid lines to draw line. Cursor is shifted to nearest grid
intersection point and user draw line between these grid points.

Gravity Field –
This constraint is useful where there is need to attach line or line in already existing picture. In this, picture does
not lie on grid system. The name of this constraint is so because there is gravitational pull in between lines on
screen.

In this constraint, input position which is near line is converted to input position on line. In this, there is invisible
area around each of line which has shape like of dumbbell or sausage which is as shown in the following figure:

Gravity fields size is chosen not very large enough to aid positioning but small to reduce chances of overlapping
with other lines.

2 D Transformations
1. Translation

A translation is applied to an object by repositioning it along a straight-line path from one coordinate location to
another. We translate a two-dimensional point by adding translation distances, tx and ty to the original coordinate
position (x, y) to move the point to a new position ( x ' , y').

The translation distance pair (tx, ty,) is called a translation vector or shift vector.

This allows us to write the two-dimensional translation equations in the matrix form:
P`= P + T

Original position of Triangle

After translation position of Triangle

Transformation function in three by three matrix representation

P` = T = P =

2. Scaling
A scaling transformation alters the size of an object. This operation can be carried out for polygons by multiplying
the coordinate values (x, y) of each vertex by scaling factors s, and s, to produce the transformed coordinates (x', y')

x`= x*sx y`= y*sy

Scaling factor sx, scales objects in the x direction, while sy scales in the y direction. The transformation equations
can also be written in the matrix form:

Or

P` = S . P

A scaling transformation relative to the coordinate origin is now expressed as the matrix multiplication.

3. Rotation
A two-dimensional rotation is applied to an object by repositioning it along a circular path in the xy plane. It is a
process of changing the angle of the object. Rotation can be clockwise or anticlockwise. For rotation, we have to
specify the angle of rotation and rotation point. Rotation point is also called a pivot point. It is print about which
object is rotated.

Types of Rotation:

1. Anticlockwise

2. Counterclockwise

The positive value of the pivot point (rotation angle) rotates an object in a counter-clockwise (anti-clockwise)
direction.

The negative value of the pivot point (rotation angle) rotates an object in a clockwise direction.

When the object is rotated, then every point of the object is rotated by the same angle.

Matrix for homogeneous co-ordinate rotation (clockwise)


Matrix for homogeneous co-ordinate rotation (anticlockwise)

You might also like