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

Module 4

Uploaded by

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

Module 4

Uploaded by

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

Two-Dimensional Viewing and Clipping

Computer Graphics Window:


Coordinate System "Handedness"

In a 2-D coordinate system the X axis generally points from left to right, and the
Y axis generally points from bottom to top. ( Although some windowing
systems will have their Y coordinates going from top to bottom. )

When we add the third coordinate, Z, we have a choice as to whether the Z-axis
points into the screen or out of the screen:

Right Hand Coordinate System (RHS)


Z is coming out of the page

Counter clockwise rotations are positive


if we rotate about the X axis : the rotation Y->Z is positive
if we rotate about the Y axis : the rotation Z->X is positive
if we rotate about the Z axis : the rotation X->Y is positive

Left Hand Coordinate System (LHS)


Z is going into the page

Clockwise rotations are positive


if we rotate about the X axis : the rotation Y->Z is positive
if we rotate about the Y axis : the rotation Z->X is positive
if we rotate about the Z axis : the rotation X->Y is positive

Multiple Coordinate Systems in a Graphics Program

In a typical graphics program, we may need to deal with a number of different


coordinate systems, and a good part of the work is the conversion of coordinates
from one system to another. We'll learn about the conversion process a little later,
but in the meantime, here is a list of some of the coordinate systems you may
encounter:

• World Coordinate System - Also known as the "universe" or sometimes


"model" coordinate system. This is the base reference system for the
overall model, ( generally in 3D ), to which all other model coordinates
relate.
• Object Coordinate System - When each object is created in a modelling
program, the modeller must pick some point to be the origin of that
particular object, and the orientation of the object to a set of model axes.
For example when modelling a desk, the modeller might choose a point in
the center of the desk top for the origin, or the point in the center of the
desk at floor level, or the bottom of one of the legs of the desk. When this
object is moved to a point in the world coordinate system, it is really the
origin of the object ( in object coordinate system ) that is moved to the new
world coordinates, and all other points in the model are moved by an equal
amount. Note that while the origin of the object model is usually
somewhere on the model itself, it does not have to be. For example, the
origin of a doughnut or a tire might be in the vacant space in the middle.
• Hierarchical Coordinate Systems - Sometimes objects in a scene are
arranged in a hierarchy, so that the "position" of one object in the hierarchy
is relative to its parent in the hierarchy scheme, rather than to the world
coordinate system. For example, a hand may be positioned relative to an
arm, and the arm relative to the torso. When the arm moves, the hand
moves with it, and when the torso moves, all three objects move together.
• Viewpoint Coordinate System - Also known as the "camera" coordinate
system. This coordinate system is based upon the viewpoint of the
observer, and changes as they change their view. Moving an object
"forward" in this coordinate system moves it along the direction that the
viewer happens to be looking at the time.
• Model Window Coordinate System - Not to be confused with desktop
windowing systems ( MS Windows or X Windows ), this coordinate
system refers to the subset of the overall model world that is to be displayed
on the screen. Depending on the viewing parameters selected, the model
window may be rectalinear or a distorted viewing frustrum of some kind.
• Screen Coordinate System - This 2D coordinate system refers to the
physical coordinates of the pixels on the computer screen, based on current
screen resolution. ( E.g. 1024x768 )
• Viewport Coordinate System - This coordinate system refers to a subset
of the screen space where the model window is to be displayed. Typically
the viewport will occupy the entire screen window, or even the entire
screen, but it is also possible to set up multiple smaller viewports within a
single screen window.

What is Window?

Window is a world coordinate area selected for display. So, the Window
defines what is to be viewed . First of all, we have to decide which portion of the
real world, we want to display.

The method of selecting and enlarging a portion of a drawing is called


windowing. The area chosen for this display is called a window. The window is
selected by world-coordinate.

Sometimes we are interested in some portion of the object and not in full object.
So we will decide on an imaginary box. This box will enclose desired or interested
area of the object. Such an imaginary box is called a window.
View-Port

A View-Port is an area on a display device. Where we map a window. So,


Viewport defines where is to be viewed. We also have to decide that at which
portion of the display device, we want to view a particular scene.

Basically, the window is an area in object space. It encloses the object. After the
user selects this, space is mapped on the whole area of the viewport. Almost all
2D and 3D graphics packages provide means of defining viewport size on the
screen. It is possible to determine many viewports on different areas of display
and view the same object in a different angle in each viewport.

Window – world coordinate area for display


Viewport – area on display device to which window is mapped

Window – what is viewed


Viewport – where it is displayed
Window to View-Port Transformation: Now there are two coordinate systems.

One is the World Coordinate system. While other is the Device Coordinate

system. Therefore, The mapping of a world coordinate scene to device coordinate

is Window to Viewport Transformation or Windowing transformation.

Viewing transformation or window to viewport transformation or


windowing transformation: The mapping of a part of a world-coordinate scene
to device coordinates is referred to as a viewing transformation etc.
Viewing transformation in several steps:

First, we construct the scene in world coordinate using the output primitives and
attributes.

To obtain a particular orientation, we can set up a 2-D viewing coordinate system


in the window coordinate plane and define a window in viewing coordinates
system.

Once the viewing frame is established, are then transform description in world
coordinates to viewing coordinates.

Then, we define viewport in normalized coordinates (range from 0 to 1) and map


the viewing coordinates description of the scene to normalized coordinates.

At the final step, all parts of the picture that (i.e., outside the viewport are dipped,
and the contents are transferred to device coordinates).

By changing the position of the viewport: We can view objects at different


locations on the display area of an output device as shown in fig:
By varying the size of viewports: We can change the size and proportions of
displayed objects. We can achieve zooming effects by successively mapping
different-sized windows on a fixed-size viewport.

As the windows are made smaller, we zoom in on some part of a scene to view
details that are not shown with larger windows.
Viewing Pipeline: Viewing Pipeline defines sequence of operations for

Windowing Transformations.

• The coordinates in which we create individual objects (models) are model (or
object) coordinates.
• When we assemble several objects into a scene, we can describe them
by world coordinates.
• After transformation into the coordinate system of the camera (viewer), then
they become viewing coordinates.
• Also, 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.
Viewing coordinate Reference Frame

We use it to provide a method for setting up different orientations for the


rectangular windows. So, We set up a 2D viewing coordinate system in the
window coordinate plane and define a window in the viewing coordinate
system.
Normalized Coordinates

Viewports are defined within the unit square called normalized coordinates.
Normalized coordinates are useful for separating viewing and other
transformations from specific output device requirements so that the graphics
package is largely device-independent.
Applications of View-Port

We can view objects at different positions on the display area of an output


device by changing the positions of the viewport. Therefore, We can change the
size and proportions of displayed objects by varying the size of the viewport. It
is also possible to determine many viewports on different areas of display and
view the same object at a different angle in each viewport.
Zooming Effect

Zooming Effect is Successively mapping different sized windows on a fixed


size viewport. As the windows are made smaller, so we zoom in on some part of
a scene to view details that were not visible in large windows. Also, We can
obtain more overview by zooming out from a section of a scene with
successively larger windows.

Panning Effect

Panning Effect is actually moving a fixed size window across various objects in
a scene.
Window to viewport Transformation

A window is specified by 4 world coordinates, wxmax, wxmin, wymax, wymin .


While, A viewport is specified by vxmax, vxmin, vymax, vymin. Moreover, The
objective of window to viewport mapping is to convert the world coordinate
(wx,wy) of an arbitrary point to its corresponding normalized device coordinate
(vx,vy).

Viewport Transformation

You have to map a point at the position wx, wy in the window into the position
vx, vy in the viewport.
Window to Viewport Mapping

In order to maintain the same relative placement of the point in the viewport as
in window, we require

We can do this in following steps:


Step1:Translate window to origin Tx= -wxmin Ty= -wymin
Step2: Then, Scaling of the window to match its size to the viewport
Sx = (vxmax– vxmin) / (wxmax– wxmin)
Sy = ( vymax– vymin) / (wymax– wymin)
Step3:Again translate viewport to its correct position on screen. Tx=
vxmin Ty= vymin
Moreover, We can represent above three steps in matrix form:
VT=T1 * S * T
T = Translate window to the origin
S=Scaling of the window to viewport size
T1=Translating viewport on screen.
Viewing Transformation=T1 * S * T
Window to View-Port Transformation Numerical

Find normalization transformation that maps a window whose lower-left


corner is at (1,1) and upper right corner is at (3,5) onto: a)Viewport with
lower-left corner (0,0) and upper right corner (1,1) b) Viewport with lower
left corner (0,0) and upper right corner (1/2,1/2)
wxmin=1, wymin=1 , wxmax=3, wymax=5
a) vxmin=0 , vymin=0
Also, vxmax=1, vymax=1
b) vxmin=0, vymin=0
Also, vxmax=1/2 , vymax=1/2
a) Sx = (vxmax– vxmin) / (wxmax– wxmin) , Sy = ( vymax– vymin) / (wymax– wymin)
While, Putting the values:
Sx = 1-0/3-1 = 1/2 ,
Sy=1-0/5-1 = 1/4
b) Sx = (vxmax– vxmin) / (wxmax– wxmin), Sy = ( vymax– vymin) / (wymax– wymin)
While, Putting the values:
Sx = (1/2-0)/3-1 = (½)/2 = 1/4
Sy=(1/2-0)/5-1 = (1/2)/4 = 1/8

You might also like