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

Computer Graphics Elements (Primitives)

The document discusses several key concepts in computer graphics: 1. The basic output primitives are polylines, text, and filled regions which are used to build other graphic elements. 2. Polylines are connected line segments that can form curves, polygons, or open shapes. Text and filled regions are also introduced. 3. Common transformations like translation, rotation, and scaling are described which manipulate the position, size, and orientation of graphic primitives.

Uploaded by

odin phone
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
37 views

Computer Graphics Elements (Primitives)

The document discusses several key concepts in computer graphics: 1. The basic output primitives are polylines, text, and filled regions which are used to build other graphic elements. 2. Polylines are connected line segments that can form curves, polygons, or open shapes. Text and filled regions are also introduced. 3. Common transformations like translation, rotation, and scaling are described which manipulate the position, size, and orientation of graphic primitives.

Uploaded by

odin phone
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 41

Computer Graphics Elements

(Primitives)
Lecture 2
Introduction
• How output primitives of graphics images appear?
• The primitives are:
- Polylines
- Text
- filled regions
• All other graphic elements are built from these primitives.
Polylines
• A polyline is a connected sequence of straight lines.
• To the eye, a polyline can appear as a smooth curve.
• Simple polyline attributes are colour and thickness.
• The simplest polyline is a single straight line segment.
• A line segment is specified by its two endpoints, such as
(x1, y1) and (x2, y2).
• When there are several lines in a polyline, each one is called
an edge, and two adjacent lines meet at a vertex.
• The edges of a polyline can cross one another but a polyline
does not have to be closed.
• A polygon has its first and last points connected by an edge.
• If no two edges cross, the polygon is called a simple polygon.
• An example of a polyline is shown in figure (a), and a polygon
is shown in figure (b) below:
Polylines

Figure (a) Polyline


Polygon

Figure (b) Polygon


Text
• Some graphics devices have two distinct display modes: text
mode and graphics mode.
• In text mode, text is generated using a built-in character
generator.
• Text in graphics mode is drawn.
• Text attributes are such as colour, size, font, spacing and
orientation.
Filled Regions
• A filled region is a shape filled with some colour or pattern. An
example is a filled polygon as shown in the figure below:

Figure: Filled Regions


Summary
• The basic graphics primitives: polylines, text and filled regions were
presented.
• They are characterised by attributes such as colour, size, font and
thickness.
• These primitives are used to create other graphics.
• Questions:
-
Picture Transformations
• Transformations are one of the fundamental operations
performed in computer graphics.
• In computer graphics, images are not only created, but also
transformed to make them appear different from what they
look like.
• This lecture presents definitions and basic picture
transformation techniques for object attributes, such as
changing their position, size and orientation as viewed on
display devices.
• The session also presents the 2D viewing pipeline where 2D
world coordinate system images are mapped to device
coordinates.
Key terms
• World coordinates: Dimensional coordinates that define the
location of objects in the real world.
• Viewpoint (Camera) coordinates: The coordinates are based
upon the viewpoint of the observer, and changes as they
change their view.
• Screen coordinates: Physical coordinates of the pixels on the
computer screen, based on current screen resolution.
Definitions and Transformation Basics
• When objects defined in one coordinate system are required
to be observed on another coordinate system,
transformation techniques are usually used.
• Transformation is performed such as to shift a picture from
one place to some other place on a screen, or to increase or
decrease its size.
- definition of transformation
- matrix representation of points
- the basics of transformation.
• What is Transformation?
• Transformation is a process which is used to obtain a
different kind of picture from an existing one by
manipulating the attributes of the original picture.
• These attributes are position, size, and orientation of the
picture.
• Matrix Representation of Points
• A picture can be thought of as being a combination of points.
• The idea is to identify the points which form a picture that is
being drawn or displayed.
• A screen is also thought to be a made up of a number of
pixels, each pixel corresponding to a point.
• Those pixels, which form a part of the picture being drawn
are made to light up so that the picture is visible on the
screen.
• Based on the Cartesian coordinate system, a point is represented by
two values as (x, y).
• x represents the distance of the point from the origin in the horizontal
direction and y in the vertical direction.
• In the context of graphics, a point is represented as a 3 valued entity
[x, y, 1].
• X and Y are the coordinates, and 1 is a value which is used for
representation.
• The figure below shows a point on a Cartesian coordinate
system at position (4, 2):

Figure: A point on Cartesian coordinates


Basic Transformation
• Manipulation of images on a screen involves two kinds of
processes.
• The first one deals with changing the appearance of the
picture by modifying its colour and surface texture, as well as
changing its appearance by changing the lightning model
that the computer uses to make it visible.
• The second process is geometric, in which the relative or
absolute location of the picture in the coordinate system is
changed.
• The picture in this case may be moved around the screen, or
appear to become larger or smaller.
• For example, a picture can be moved from the centre to the
top left hand corner of a screen.
• The picture can also be increased or decreased to twice or
half its size, respectively.
• The picture can also be turned/rotated 45 or 90 degrees.
• The three basic transformations are:
1. Translation
2. Rotation
3. Scaling
• These transformations are essentially mathematical
operations which are performed on points and hence
pictures, since a picture can be viewed as a collection of
points.
Translation
• Translation refers to the shifting of a point to
some other place, whose distance with regard to
the present point is known.
• This process shifts the position of a point from one set of
coordinates to another.
• Consider a point P(x1, y1) to be translated to another point
Q(x2, y2).
• If the point values of (x2, y2) are known, the point can directly
be shifted to Q by displaying the pixel at (x2, y2).
• If the distance by which the point is to be shifted is known,
for instance Tx and Ty along the x and y axes respectively,
then the coordinates can be derived by x2 =x1 +Tx and y2 =
y1+ Ty.
• Example: if a triangle with coordinates A(20,10), B(30,100) and
C(40,70) is to be shifted by 20 units along the x axis and 10 units
along the y axis, then the new triangle will be at A1(20+20, 10+10)
B1 (30+20, 10+10) C1(40+20, 70+10).
• In matrix form, [x2 y2 1] = [x1 y1 1]*
Rotation
• Rotation is the rotation of a point about an axis.
• The axis can be any of the coordinates or any other specified
line.
• Suppose a point (x1 y1) is to be rotated clockwise through an
angle θ about the origin of the coordinate system.
• Mathematically the new coordinates of the point (x2 y2) can
be expressed as:
x2 = x1cosθ + y1sinθ
y2 = x1sinθ – y1cosθ
• These equations are applicable only if the rotation is about
the origin.
• The matrix for [x2 y2 1] = [x1 y1 1] *
Scaling
• Scaling is the increasing or decreasing the size of a picture in
one or either directions.
• The size of the picture is changed by increasing or decreasing
the distance between the end points of the picture and
changing the intermediate points as per requirements.
• Suppose a point (x1 y1) is to be scaled by a factor sx along the
x direction and by a factor sy along the y direction, the new
coordinates become:
x2 = x1 * sx
y2 = y1 * sy

• Scaling a point physically means moving the point away but


does not magnify the point.
• However, when a picture is scaled, each of the points are
scaled differently and hence the dimensions of the picture
changes.
The translation, rotation and scaling are summarized in the Figure

Figure: Types of transformations


Summary
• This lecture presented the types of transformations, i.e.
translation, scaling and rotation.
• In translation, a picture’s position is altered by altering its
coordinates.
• In scaling, a picture’s size is altered, i.e. increased or decreased,
while in rotation, a picture is rotated about an axis through an
angle, clockwise or anticlockwise.
- These operations are necessary in computer graphics such that
pictures can be manipulated and transformed in terms of their
size, position and orientation, to give various effects of the
pictures.
2D Viewing Pipeline
• In many cases, the size of display devices is generally limited
in terms of physical dimension as well as resolution.
• When displaying pictures on devices, their dimensions may
be limited by the size of the display device.
• In such cases, the pictures need to be “fitted” on the display
device, and undergoes a series of transformations, which are
termed viewing pipeline, so that it can be displayed on a
physical device.
• The Viewing Pipeline describes a series of transformations,
which are passed by geometry data to end up as image data
being displayed on a device.
• The 2D viewing pipeline describes this process for 2D data:
• The coordinates in which individual objects (models) are
created are called model (or object) coordinates.
• When several objects are assembled into a scene, they are
described by world coordinates.
• After transformation into the coordinate system of the
camera (viewer) they become viewing coordinates.
• Their projection onto a common plane (window) yields
device-independent normalized coordinates.
• Finally, after mapping those normalized coordinates to a
specific device, we get device coordinates.
Window – Viewport Transformation
• A window-viewport transformation describes the mapping
of a (rectangular) window in one coordinate system into
another (rectangular) window in another coordinate system.
• This transformation is defined by the section of the original
image that is transformed (clipping window), the location of
the resulting window (viewport), and how the window is
translated, scaled or rotated.
Line Clipping
• Clipping is the method of cutting away parts of a picture that lie
outside the displaying window (as in the previous figure).
• The earlier clipping was done within the viewing pipeline, the
more unnecessary transformations of parts which are invisible
anyway can be avoided:
- in world coordinates, which means analytical calculation as early as
possible
- during raster conversion, i.e. during the algorithm, which transforms a
graphic primitive to points
- per pixel, i.e. after each calculation, just before drawing a pixel.
• Since clipping is a very common operation it has to be performed
simply and quickly.
Polygon Clipping
• Have to make sure, that the result is one single polygon again,
even if the clipping procedure cuts the original polygon into more
than one piece.
• The figure below (upper part) shows a polygon clipped by a line
clipping algorithm.
• Afterwards it is not decidable what is inside and what is outside
the polygon.
• The lower part shows the result of a correct polygon clipping
procedure.
• The polygon is divided into several pieces, each of which can be
filled correctly.
Text Clipping
• At first glance clipping of text seems to be trivial, however,
one little point has to be kept in mind: Depending on the
way the letters are created it can happen, that either only
text is displayed that is fully readable (i.e. all letters lie
completely inside the window), or that text is clipped letter
by letter (i.e. all letters disappear that do not lie completely
inside the window), or that text is clipped correctly (i.e. also
half letters can be created).

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy