Download as pdf or txt
Download as pdf or txt
You are on page 1of 15

Raster Scan and Random Scan

Raster scan and random scan are the mechanisms used in displays for rendering
the picture of an object on the screen of the monitor. The main difference
between raster scan and random scan lies in the drawing of a picture where the
raster scan points the electron beam at the entire screen but incorporating just
one line at a time in the downward direction. On the other hand, in the random
scan, the electron beam is guided on just those regions of the screen where the
picture actually lies.

BASIS FOR RASTER SCAN RANDOM SCAN

COMPARISON

Electron beam Swept across the screen and Directed to the portions

handles one row at a time and in of the screen where a

downward direction. picture is to be rendered.

Resolution Poor, since it generates Good, as this produces even

meander lines which are lines drawing.

organized as distinct point sets.

Picture definition Stored as the combination of Stored as a group of line

intensity values for all screen drawing instructions in a

points. display file.

Realistic display Effectively displays realistic Unable to display realistic


scenes.
shaded scenes.

Picture rendering Using pixels With the help of

mathematical functions
The Raster Scan is a scanning technique in graphics monitor where the electron
beam is moved along the screen covering one line at a time from top to bottom.
The beam intensity is set at high and low levels as the beam sweeps around the
screen to generate a pattern of illuminated spots.
Refresh buffer or frame buffer is then used to save the picture definition, more
specifically the memory area contains the combination of intensity values for
various screen points. These stored intensities are fetched from refresh buffer
and represented on the screen one scan line at a time. The fundamental unit for
defining a single screen point is known as Pixel or Pel (Picture element).

The raster scan systems are appropriate for the realistic display of scenes as
these systems are capable of saving the intensity data for each screen point
where subtle shading and colour patterns can also be involved. However, the
television sets and printers are examples of other systems.

A typical system having a screen resolution of 1024 by 1024 and contain 24 bits
per pixel can consume 3 megabytes for the frame buffer. In black-and-white
systems, the frame buffer is known as a bitmap where only one bit per pixel is
consumed while the frame buffer of systems with multiple bits per pixel is called
as a pixmap. The rate of refreshing on raster-scan displays is operated at the rate
of 60-80 frames per second.
The Random scan works in a completely different manner to the raster scan
where the electron beam is pointed to merely those areas of the screen where the
picture is to be drawn. However, it only involves one line at a time when
drawing a picture that is why it is also known as the vector or calligraphic
display. The component lines of an object by a random scan is drawn in the way
as shown in the diagram below.

The refresh rate of a random scan relies on the number of lines that are to be
showed on the screen. Similar to the raster scan the random scan also stores the
picture definition as a set of line drawing commands using some sort of
medium known as refresh display file. The other names for refresh file display
are display list, display program or refresh buffer. A system displays a certain
picture by revoluting the group of commands in the display file and drawing
each component line after each turn. After processing all line drawing
commands, the system cycle is sent to the first line command.

A random scan is capable of drawing all the component of a picture about 30 to 60


times per second. In the provided refresh rate the high-quality vector systems are
competent enough to handle 100000 short lines. At the time displaying short lines,
the refresh cycles are delayed to eliminate refresh rates higher than 60 frames per
second. Otherwise, swift refreshing of the group of lines can damage or burn the
phosphor.

Conclusion
When it comes to refreshing rate, the raster scan has higher refresh rate about 60
to 80 times per second while random scan consumes less time for refreshing the
screen, i.e., 30 to 60 times per second. Raster scan can also use interlaced refresh
method which is not used in the random scan.
Cohen Sutherland line clipping algorithm

Cohen Sutherland line clipping algorithm divides a two-dimensional space into


9 regions and then efficiently determines the lines and portions of lines that are
inside the given rectangular area.
The algorithm can be outlines as follows-
Nine regions are created, eight "outside" regions and one "inside" region.

For a given line extreme point (x, y), we can quickly find its region's four-bit
code. Four-bit code can be computed by comparing x and y with four values:
(x_min, x_max, y_min and y_max).

If x is less than x_min then bit number 1 is set.


If x is greater than x_max then bit number
2 is set. If y is less than y_min then bit
number 3 is set.
If y is greater than y_max then bit number 4 is set

There are three possible cases-


1. Completely inside the given rectangle: Bitwise OR of region of two end
points of line is 0 (Both points are inside the rectangle)
2. Completely outside the given rectangle: Both endpoints share at least
one outside region which implies that the line does not cross the visible
region. (bitwise AND of endpoints! = 0).
3. Partially inside the window: Both endpoints are in different regions. In
this case, the algorithm finds one of the two points that is outside the
rectangular region. The intersection of the line from outside point and
rectangular window becomes new corner point and the algorithm repeats.
Algorithm

Step 1: Assign a region code for two endpoints of given line.


Step 2: If both endpoints have a region
code 0000 then given line is
completely inside.
Step 3: Else, perform the logical AND operation for both region codes.
Step 3.1: If the result is not 0000, then given line is
completely outside.
Step 3.2: Else line is partially inside.
Step 3.2.1: Choose an endpoint of the
line that is outside the given
rectangle.
Step 3.2.2: Find the intersection point of the
rectangular boundary (based on region
code).
Step 3.2.3: Replace endpoint with the intersection
point and update the region code.
Step 3.2.4: Repeat step 2 until we find a clipped line
either trivially accepted or trivially rejected.
Step 4: Repeat step 1 for other lines.
Java Implementation:

import java.io.*;

class Main {

// Defining region codes


static final int INSIDE = 0; // 0000
static final int LEFT = 1; // 0001
static final int RIGHT = 2; // 0010
static final int BOTTOM = 4; // 0100
static final int TOP = 8; // 1000

// Defining x_max, y_max and x_min, y_min for


// clipping rectangle. Since diagonal points are
// enough to define a rectangle
static final int x_max = 10;
static final int y_max = 8;
static final int x_min = 4;
static final int y_min = 4;

// Function to compute region code for a point(x, y)


static int computeCode(double x, double y)
{
// initialized as being inside
int code = INSIDE;

if (x < x_min) // to the left of rectangle


code |= LEFT;
else if (x > x_max) // to the right of rectangle
code |= RIGHT;
if (y < y_min) // below the rectangle
code |= BOTTOM;
else if (y > y_max) // above the rectangle
code |= TOP;

return code;
}

// Implementing Cohen-Sutherland algorithm


// Clipping a line from P1 = (x2, y2) to P2 = (x2, y2)
static void cohenSutherlandClip(double x1, double y1,
double x2, double y2)
{
// Compute region codes for P1, P2
int code1 = computeCode(x1, y1);
int code2 = computeCode(x2, y2);
// Initialize line as outside the rectangular window
boolean accept = false;

while (true) {
if ((code1 == 0) && (code2 == 0)) {
// If both endpoints lie within rectangle
accept = true;
break;
}
else if ((code1 & code2) != 0) {
// If both endpoints are outside rectangle,
// in same region
break;
}
else {
// Some segment of line lies within the
// rectangle
int code_out;
double x = 0, y = 0;

// At least one endpoint is outside the


// rectangle, pick it.
if (code1 != 0)
code_out = code1;
else
code_out = code2;

// Find intersection point;


// using formulas y = y1 + slope * (x - x1),
// x = x1 + (1 / slope) * (y - y1)
if ((code_out & TOP) != 0) {
// point is above the clip rectangle
x = x1
+ (x2 - x1) * (y_max - y1)
/ (y2 - y1);
y = y_max;
}
else if ((code_out & BOTTOM) != 0) {
// point is below the rectangle
x = x1+ (x2 - x1) * (y_min - y1)/ (y2 - y1);
y = y_min;
}
else if ((code_out & RIGHT) != 0) {
// point is to the right of rectangle
y = y1+ (y2 - y1) * (x_max - x1)/ (x2 - x1);
x = x_max;
}
else if ((code_out & LEFT) != 0) {
// point is to the left of rectangle
y = y1+ (y2 - y1) * (x_min - x1)/ (x2 - x1);
x = x_min;
}
// Now intersection point x, y is found
// We replace point outside rectangle
// by intersection point
if (code_out == code1) {
x1 = x;
y1 = y;
code1 = computeCode(x1, y1);
}
else {
x2 = x;
y2 = y;
code2 = computeCode(x2, y2);
}
}
}
if (accept) {
System.out.println("Line accepted from " + x1+ ", " + y1 + " to " + x2
+ ", " + y2);
// Here the user can add code to display the
// rectangle along with the accepted (portion
// of) lines
}
else
System.out.println("Line rejected");
}

public static void main(String[] args)


{
// First Line segment
// P11 = (5, 5), P12 = (7, 7)
cohenSutherlandClip(5, 5, 7, 7);

// Second Line segment


// P21 = (7, 9), P22 = (11, 4)
cohenSutherlandClip(7, 9, 11, 4);

// Third Line segment


// P31 = (1, 5), P32 = (4, 1)
cohenSutherlandClip(1, 5, 4, 1);
}
}
Parallel and Perspective Projections

Projection are defined as mapping of three-dimensional points to a two-


dimensional plane. There are two type of projection parallel and perspective.
1. Parallel Projection :
Parallel projections are used by architects and engineers for creating working
drawing of the object, for complete representations require two or more views of
an object using different planes.
Parallel Projection use to display picture in its true shape and size. When
projectors are perpendicular to view plane then is called orthographic
projection. The parallel projection is formed by extending parallel lines from
each vertex on the object until they intersect the plane of the screen. The point of
intersection is the projection of vertex.

2. Perspective Projection :
Perspective projections are used by artist for drawing three-dimensional scenes.
In Perspective projection lines of projection do not remain parallel. The lines
converge at a single point called a center of projection. The projected image on
the screen is obtained by points of intersection of converging lines with the
plane of the screen. The image on the screen is seen as of viewer’s eye were
located at the centre of projection, lines of projection would correspond to path
travel by light beam originating from object.
Two main characteristics of perspective are vanishing points and perspective
foreshortening. Due to foreshortening object and lengths appear smaller fromthe
center of projection. More we increase the distance from the center of
projection, smaller will be the object appear.

Difference Between Parallel Projection And Perspective Projection :

SR.N Parallel Projection Perspective Projection


O

Parallel projection represents the Perspective projection represents the


1 object in a different way like object in three dimensional way.
telescope.

In parallel projection, these In perspective projection, objects that are


2 effects are not created. far away appear smaller, and objects that
are near appear bigger.

The distance of the object from The distance of the object from the
3 the center of projection is center of projection is finite.
infinite.
SR.N Parallel Projection Perspective Projection
O

4 Parallel projection can give the Perspective projection cannot give the
accurate view of object. accurate view of object.

5 The lines of parallel projection The lines of perspective projection are not
are parallel. parallel.

6 Projector in parallel projection is Projector in perspective projection is not


parallel. parallel.

Two types of parallel projection : Three types of perspective projection:


7 1.Orthographic, 1.one point perspective,
2. Two point perspective,
2.Oblique
3. Three point perspective,

8 It does not form realistic view of It forms a realistic view of object.


object.
ANIMATION

DESIGN OF ANIMATION SEQUENCES


In general, an animation sequence is designed with the tollowing steps:
1. Storyboard layout
2. Object definitions
3. Key-frame specifications
4. Generation of in-between frames

This standard approach for animated cartoons is applied to other animation


applications as well, although there are many special application that do not follow
this sequence.

The Storyboard layout is an outline of the action. It defines the motion sequence
as a set of basic events that are to take place. Depending on the type of animation
to be produced, the storyboard could consist of a set of rough sketches or it could
be a list of the basic ideas for the motion.
An object definition is given for each participant in the action. Objects can
bedefined interms of basic shapes, such as polygons or splines. In addition, the
associatedmovements for each object are speeded along with the shape.
A keyframe is a detailed drawing of the scene at a certain time in the animation
sequence. Within each key frame, each object is positioned according to the time
for that frame. Some key frames are chosen at extreme positions in the action;
others are spaced so that the time interval between key frames is not to great. More
key frames are specified for intricate motions than for simple, slowly varing
motions.
In-between frames are the intermediate frames between the key frames. The
nurnber of in-betweens needed is determined by the media to be used to display
theanimation. Film requires 24 frames per second, and graphics terminals are
refreshedat the rate of 30 to 60 frames per second. Typically, time intervals for
themotion are set up so that there arr from three to five in-betweens for each pair
ofkey frames.
GENERAL COMPUTER-ANIMATION FUNCTIONS

Some steps in the development of an animation sequence are well-suited to


computer solution. These include object manipulations and rendering, camera
motions, and the generation of in-betweens. Animation packages, such as
Wavefront,
One function available in animation packages is provided to store and manage the
object database. Object shapes and associated parameters are stored and updated in
the database. Other object functions include those for motion generation and those
for object rendering. Motions can be generated according to specified constraints
using two-dimensional or three-dimensional transformations.

RASTER ANIMATIONS
On raster systems, we can generate real-time animation in limited applications
using raster operations. Sequences of raster operations can be executed to produce
real-time animation of either two-dimensional or three-dimensional objects, as
long as we restrict the animation to motions in the projection plane. Then no
viewing or visible- surface algorithms need be invoked.The animation is then
accomplished by changing the color-table values so that the object is "on"at
successively positions along the animation path as the preceding position is set-to
the background intensity

COMPUTER-ANIMATION LANGUAGES

Design and control of animation sequences are handled with a set of


animationroutines. A general-purpose language, such as C, Lisp, Pascal, or
FORTRAN, is often used to program the animation functions, but several
specialized animation languages have been developed. Animation functions
include: a graphics editor, a key-frame generator, an in-between generator, and
standard graphics routines. The graphics editor allows us to design and modify
object shapes, using spline surfaces, constructive solid-geometry methods, or other
representation schemes.
A typical task in an animation specification is scene description. This includes the
positioning of objects and light sources, defining the photometric parameters
(light-source intensities and surface-illumination properties), and setting the
camera parameters (position, orientation, and lens characteristics).
Another standard function is action specification. This involves the layout of
motion paths for the objects and camera. And we need the usual graphics routines:
viewing and perspective transformations, geometric transformations to generate
object movements as a function of accelerations or kinematics path specifications,
visible-surface identification, and the surface-rendering operations.
KEY FRAME SYSTEMS
We generate each set of in-betweens from the specification of two (or more)
keyframes. Motion paths can be given with a kinematic a s a set of spline curves,
or the motions can be physicdly bnscd by specifying the for acting on the objects to
be animated.For complex scenes, we can separate the frames into individual
components or objects called cels celluloid transparencies)
MORPHING
Transformation of object shapes from one form to another is called
morphing,which is a shortened form of metamorphosis. Morphing methods can he
applied to any motion or transition involving a change in shape.Givcn two key
frames for an object transformation, we first adjust the object specification in one
of the frames so that the number of polygon edges (or the number of vertices) is
the same for the two frames.

MOTION SPECIFICATIONS There are several ways in which the motions of


objects can be specified in an animation system.

Direct Motion SpecificationThe most straightforward method for defining a


motion sequence is direct specification of the motion parameters. Here, we
explicitly give the rotation angles and translation vectors. Then the geometric
transformation matrices are applied to transform coordinate positions.
Goal-Directed Systems At the opposite extreme, we can specify the motions that
are to take place in general terms that abstractly describe the actions. These
systems are referred to as goal directed because they determine specific motion
parameters given the goalsof the animation.

You might also like