0% found this document useful (0 votes)
10 views15 pages

Coordinate System

Module 4 discusses the Cartesian coordinate system, which allows for the unique identification of points in a plane using ordered pairs. It covers concepts such as Cartesian reference frames, window to viewport transformations, and clipping techniques used in computer graphics to manage visible and invisible parts of images. The document also details algorithms like Cohen-Sutherland for line clipping and Sutherland-Hodgeman for polygon clipping, providing a framework for rendering graphics accurately on display devices.

Uploaded by

Krishnendhu C.M
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views15 pages

Coordinate System

Module 4 discusses the Cartesian coordinate system, which allows for the unique identification of points in a plane using ordered pairs. It covers concepts such as Cartesian reference frames, window to viewport transformations, and clipping techniques used in computer graphics to manage visible and invisible parts of images. The document also details algorithms like Cohen-Sutherland for line clipping and Sutherland-Hodgeman for polygon clipping, providing a framework for rendering graphics accurately on display devices.

Uploaded by

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

Module 4

Coordinate System
 The coordinate system, also known as the Cartesian coordinate system,
was developed by René Descartes in the 17th century. It provides a way
to uniquely identify each point in a plane using an ordered pair of
numbers, typically called coordinates (x, y).
 A number line is a one-dimensional representation of numbers,
extending infinitely in both positive and negative directions from the
origin (0).
 When two such number lines are placed perpendicular to each other in a
plane, they form the coordinate plane or Cartesian plane.
 The horizontal axis (x-axis) and vertical axis (y-axis) intersect at the origin
(0,0). Each point in the plane is located by its x-coordinate (horizontal
position) and y-coordinate (vertical position).
 In the Cartesian coordinate system, every point is represented as (x, y) in
2D or (x, y, z) in 3D. The two reference lines (axes) are x-axis (horizontal
line) and y-axis (vertical line). The origin (0,0) is where the x-axis and y-
axis intersect.
 The perpendicular distance of a point from the y-axis, is measured along
the x-axis. The perpendicular distance of a point from the x-axis, is
measured along the y-axis. For example, a point (3, 2), here point 3 is the
perpendicular distance from the y-axis, measured along the x-axis and
point 2 is the perpendicular distance from the x-axis, measured along the
y-axis.
 Most graphics software (like AutoCAD, Photoshop, and game engines)
use the Cartesian system to plot points, draw shapes, and render images.
However, some coordinate systems (like spherical or hyperbolic) might
be used in physics and engineering. Before using these non-Cartesian
systems in graphics, they must be converted to Cartesian coordinates.
Cartesian Reference Frame
 A Cartesian Reference Frame is a coordinate system used to define the
position of points or objects in space. It consists of perpendicular x, y
(and sometimes z) axes, with an origin (0,0) or (0,0,0) as the reference
point.
 Different reference frames are used in computer graphics, physics, and
engineering to describe objects and their positions in a scene.
Different Cartesian Reference Frames in Graphics
1. Modeling Coordinates (Local/Master Coordinates)
We can construct the shape of individual objects, such as trees or
furniture, in a scene within separate coordinate reference frames called
modeling coordinates, or sometimes local coordinates or master
coordinates.
2. World Coordinates
Once individual object shapes have been specified, we can place the
objects into appropriate positions within the scene using a reference
frame called world coordinates.
3. Displaying the Scene (Device Coordinates)
After the scene is constructed in world coordinates, it must be displayed
on a screen or output device (like a monitor or printer). This requires
conversion from world coordinates to device coordinates (or screen
coordinates).
Window to Viewport Transformation
The Window to Viewport Transformation is the process of converting a 2D
world-coordinate scene into device coordinates (screen coordinates) for
display.
Key Terms:

1. World Coordinates: The coordinate system used to define objects in a


scene (real-world units).
2. Window: The selected portion of the world coordinate scene that we
want to display. The window defines what is to be viewed.
3. Viewport: The area on the display screen where the window content is
mapped. The viewport defines where it is to be displayed.
4. Viewing Transformation: The process of mapping world coordinates
(window) to device coordinates (viewport). The two-dimensional viewing
transformation is referred to as window to viewport transformation.
5. World Coordinates: It is the Cartesian coordinate, which defines the
diagram i.e. Xwmin, Xwmax, Ywmin, Ywmax
6. Device Coordinates: It is the screen coordinate where the object is to be
displayed i.e. Xvmin, Xvmax, Yvmin, Yvmax

In particular, objects inside the world or clipping window are mapped to the
viewport. The viewport is displayed in the interface window on the screen. In
other words, the clipping window is used to select the part of the scene that
is to be displayed. The viewport then positions the scene on the output
device.
Example:

The size of the viewport may be smaller than the size of the window or
greater than the size of the window. In this case, we have to increase or
decrease the size of the window according to the size of the viewport. So,
some mapping is required to convert the size of the window to the size of the
viewport. Some mathematical computations are required to map the window
to the viewport.
Steps for the Window to Viewport Transformation

Steps:
Step 1: Translate the window towards the origin. While shifting the window
towards the origin, the translation factor will become negative (-tx, -ty).
Tx = -Xwmin
Ty = -Ywmin
Step 2: Resize the window to the size of the viewport. For this calculate Sx
and Sy
Sx = (Xvmax-Xvmin) / (Xwmax-Xwmin)
Sy = (Yvmax-Yvmin) / (Ywmax-Ywmin)
Step 3: Translate the window (the position of the window must same as the
position of the viewport).
Tx = Xvmin
Ty = Yvmin
The Above three steps can be represented in matrix form:
VT = T * S * T1
T = Translate the window to the origin
S = Scaling of the window to viewport size
T1 = Translating window to viewport on the screen.
Viewing Transformation = T * S * T1

 The Advantage of the window to viewport transformation is that we


can display the picture on the device or display system according to
our requirements.
Clipping
 Clipping is a type of transformation used in computer graphics to
remove lines, objects, and segments of lines that are outside the
computer screen or viewing pane.
 The clipping is a process of identifying the visible and invisible parts of
the image, object, or any line segment. We only select the visible part
and remove the invisible part of the line.
 Clipping can be used in two-dimensional and three-dimensional
graphics. In the two-dimensional graphics system, clipping is a process
in which all pixels of an image lie inside the boundary of a view pane
(window).
Applications of clipping
 We can use clipping for drawing operations.
 It is used for separating the important parts of an image.
 We can perform various operations that correlate with the pointing of
an object. For example, delete, copy, insert, and move selected parts
of an object, etc.
 Clipping can be applied through hardware as well as software. In some
computers, hardware devices automatically do the clipping. If the
hardware clipping is not possible, the software clipping can be used.
Types of Clipping
1. Point Clipping
Point Clipping is used to determine whether the point is inside the
window or not. So, to determine whether the point is inside or outside
the window the following four conditions are checked:
 x >= xmin
 x <= xmax
 y >= ymin
 y <= ymax

Example:

The above figure shows the (x, y) coordinate of the point. If any point does
not satisfy the four conditions, then the point will fall outside the window
and will not be considered to be visible.
In the given example, the point falls inside the window i.e. it satisfies the four
conditions, so the point is considered to be visible
2. Line Clipping
In computer graphics, line clipping is the process of determining which
parts of a line are visible within a specified region (like a viewport or
window) and discarding the parts outside, using algorithms such as:
 Cohen-Sutherland Line Clipping Algorithm
 Midpoint Subdivision Line Clipping Algorithm
 Liang-Barsky Line Clipping Algorithm
Cohen-Sutherland Line Clipping Algorithm
This algorithm was named by “Danny Cohen” and “Ivan Sutherland”. In
this algorithm, we will divide the view pane(window) into nine equal
segments and each segment is represented by 4 bits. The allocation of
bits depends on the “TBRL” (Top, Bottom, Right, Left) rule.
The center area is having the code 0000 i.e. region 5 is considered a
rectangle window/selection window or view area.
In Cohen-Sutherland Algorithm we will divide the lines into following
categories:
Visible Line: When both points (starting and ending) of the line are
entirely situated inside the window.
Invisible Line: When both points (Starting and ending) of the line are
completely situated outside the window.
Clipped Line: Every line has two endpoints. If one point of the line is
inside the window and the other one is outside the window, then the line
is known as Clipped Line.

In the above figure:


 Line A-B is a clipped case.
 Line C-D is completely visible.
 Line E-F is completely invisible.
 Line G-H is a clipped case.
 Line K-L is completely invisible.
 Line I-J is a clipped case.
Advantage of Cohen Sutherland Line Clipping:
 It calculates the endpoints very quickly and rejects or accepts the lines
quickly.
 It can clip pictures that are larger than the screen size.

Algorithm:
Step 1: Calculate positions of both endpoints of the line (region code).
Step 2: Perform OR operation on both of these endpoints (region code).
Step 3:
If the OR operation gives the code 0000
Then, line is considered to be visible
Else
Perform AND operation on both endpoints
If AND ≠ 0000 then the line is invisible
Else
AND = 0000 then the line is considered to be clipped case.
Step 4: If a line is clipped case, find an intersection with boundaries of the
window
m = (y2 - y1) / (x2 - x1)
Step 4.1: If the TOP bit is 1 line intersects with the top boundary
y = ywmax
x = x1 + (y - y1)/m
Step 4.2: If the BOTTOM bit is 1 line intersects with the bottom boundary
y = ywmin
x = x1 + (y - y1)/m

Step 4.3: If the RIGHT bit is 1 line intersects with the right boundary
x = xwmax
y = y1 + m (x - x1)
Step 4.4: If the LEFT bit is 1 line intersects with the left boundary.
x= xwmin
y = y1 + m (x - x1)
Step 5: The intersection point is (x, y) and clipping is applied on (x, y).
Example of Cohen-Sutherland Line Clipping Algorithm:
3. Area or Polygon Clipping
Polygon
“A Polygon can be described as the enclosed collection or group of the
lines.” In a Polygon, all lines are connected. Lines can be a combination of
edges and vertices, which together form a polygon. Examples of polygons
are Triangle (3 sides), Pentagon (5 sides), Hexagon (6 sides) etc.
Types of Polygons
There are two basic types of polygons
1. Convex Polygon
 A convex polygon is a polygon with at least one interior angle less
than 180°.
 In a convex polygon, all the vertices are pointing outward.
 In a concave polygon, all the diagonals lie inside the polygon.
 Examples: equilateral triangle, square, rectangle, and regular
pentagon.
2. Concave Polygon
 A concave polygon is a polygon with at least one interior angle
greater than 180°.
 In a concave polygon, at least one vertex appears pushed inward.
 In a concave polygon, at least one diagonal passes outside the
polygon.
 The shape of the concave polygon is usually irregular. A concave
polygon is also known as a non-convex polygon.
 Examples: star, arrowhead.
Polygon Clipping
Polygon clipping is a process in which we only consider the part that is
inside the view pane or window. We will remove or clip the part that is
outside the window. The clipping of a polygon is done with the help of an
algorithm called Sutherland-Hodgeman Polygon Clipping Algorithm.
Sutherland-Hodgeman Polygon Clipping Algorithm
A polygon can be clipped by checking its edges one by one against each
side of the clipping window. First, the polygon is clipped against the left
boundary, producing a new set of vertices. This updated set is then passed
to the right boundary clipper, followed by the top boundary clipper, and
finally the bottom boundary clipper. At each stage, a new set of vertices is
generated and passed to the next clipper. This approach forms the core of
the Sutherland-Hodgeman polygon clipping algorithm, which handles four
distinct clipping cases, with the output of each case serving as the input
for the next.
Algorithm:
Step 1: Start
Step 2: Read the coordinates of all vertices of the Polygon.
Step 3: Read the coordinates of the dipping window
Step 2: Consider the left edge of the window
Step 5: Compare the vertices of each edge of the polygon, individually
with the clipping plane.
Step 6: Save the resulting intersections and vertices in the new list of
vertices according to four possible relationships between the edge and
the clipping boundary.
Step 7: Repeat steps 5 and 6 for the remaining edges or the clipping
window. Each time the resultant list of vertices is successively passed to
process the next edge of the clipping window.
Step 8: Stop
Example of four clipping cases:
CASE 1:
Left Clip: In the left side polygon clipping, we only remove the left part of
the polygon, which is outside the window. We only save the portion inside
the window.
CASE 2:
Right Clip: In the right-side polygon clipping, we only remove the right
part of the polygon, which is outside the window. We only save the
portion inside the window.

CASE 3:
Top Clip: On the top side polygon clipping, we only remove the top part of
the polygon, which is outside the window. We only save the portion inside
the window.

CASE 4:
Bottom Clip: In the bottom side polygon clipping, we only remove the
bottom part of the polygon, which is outside the window. We only save
the portion inside the window.
Conditions/Testing for Clipping a Polygon
First Vertex Second Vertex Output Vertex List
Outside Inside
Vi Vi+1 Vi’(intersection point) ,
Vi+1
Inside Outside
Vi Vi+1 Vi’(intersection point)
Inside Inside
Vi Vi+1 Vi+1
Outside Outside
Vi Vi+1 none

Condition 1 (Out-In): If the first vertex of the polygon is outside and the
second vertex is inside the window, then the output will be the
intersection point and second vertex.
Condition 2 (In-Out): If the first vertex of the polygon is inside and the
second vertex is outside the window, then the output will be the
intersection point.
Condition 3 (In-In): If both vertices of the polygon are inside the window,
then the output will be the second vertex.
Condition 4 (Out-Out): If both vertices of the polygon are outside the
window, then the output will be nothing. It means we found a clipped
polygon.

You might also like