computer graphics 2-dimensional concepts

19
Announcements Two-Dimensional Viewing Computer Graphics Autumn 2009 CS4815

Upload: syedkareemhkg

Post on 08-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 1/19

AnnouncementsTwo-Dimensional Viewing

Computer Graphics

Autumn 2009

CS4815

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 2/19

AnnouncementsTwo-Dimensional Viewing

Outline

1 Announcements

2 Two-Dimensional ViewingTwo-Dimensional Viewing Pipeline

CS4815

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 3/19

AnnouncementsTwo-Dimensional Viewing

Announcements

Extra lecture: 16.00, Thursday, Week07, Room CS-G25

Mid-term: 13.00, Friday, Week07No lecture Mon. Week08Today, 16th Oct. Hamilton’s Day

CS4815

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 4/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Outline

1 Announcements

2 Two-Dimensional ViewingTwo-Dimensional Viewing Pipeline

CS4815

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 5/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Coordinate Systems

Several coordinate systems used in graphics systems.World coordinates are the units of the scene to bemodelled; we select a “window” of this world for viewingViewing coordinates are where we wish to present the

view on the output device; we can achieve zooming bymapping different sized clipping windows to a xed-sizeviewport ; can have multiple viewports

CS4815

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 6/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Coordinate Systems

Several coordinate systems used in graphics systems.World coordinates are the units of the scene to bemodelled; we select a “window” of this world for viewingViewing coordinates are where we wish to present the

view on the output device; we can achieve zooming bymapping different sized clipping windows to a xed-sizeviewport ; can have multiple viewports

World Coordinates

Viewport Coordinates

Clipping WindowViewport (possibly different size)

CS4815

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 7/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Coordinate Systems

Several coordinate systems used in graphics systems.World coordinates are the units of the scene to bemodelled; we select a “window” of this world for viewingViewing coordinates are where we wish to present the

view on the output device; we can achieve zooming bymapping different sized clipping windows to a xed-sizeviewport ; can have multiple viewports

World Coordinates

Viewport Coordinates

Clipping Window Viewport (different size)

CS4815

A

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 8/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Coordinate Systems (contd.)

The clipping window selects what ; the viewport indicateswhere on output deviceNormalized coordinates are introduced to make viewing

process independent of any output device (paper vs.mobile phone); clipping normally and more efcientlydone in these coordinatesDevice coordinates are specic to output device: printerpage, screen display, etc.

The Viewing Pipeline.

CS4815

Announcements

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 9/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Coordinate Systems (contd.)

The clipping window selects what ; the viewport indicateswhere on output deviceNormalized coordinates are introduced to make viewing

process independent of any output device (paper vs.mobile phone); clipping normally and more efcientlydone in these coordinatesDevice coordinates are specic to output device: printerpage, screen display, etc.

The Viewing Pipeline.

CS4815

Announcements

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 10/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Coordinate Systems (contd.)

The clipping window selects what ; the viewport indicateswhere on output deviceNormalized coordinates are introduced to make viewing

process independent of any output device (paper vs.mobile phone); clipping normally and more efcientlydone in these coordinatesDevice coordinates are specic to output device: printerpage, screen display, etc.

The Viewing Pipeline.

CS4815

Announcements

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 11/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Coordinate Systems (contd.)

The clipping window selects what ; the viewport indicateswhere on output deviceNormalized coordinates are introduced to make viewingprocess independent of any output device (paper vs.mobile phone); clipping normally and more efcientlydone in these coordinatesDevice coordinates are specic to output device: printerpage, screen display, etc.

Construct World−Coordinate Scene

Convert World Coords.to Vie wing Coords.

Viewing Coords. areNormalized

Map Normalized Coords.to Device Coords.

The Viewing Pipeline.

CS4815

Announcements

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 12/19

AnnouncementsTwo-Dimensional Viewing

Two-Dimensional Viewing Pipeline

Viewing-Coordinate Clipping Window

Given a scene in world coordinates, how do we transform apoint w = ( w x , w y ) to viewing coordinates v = ( v x , v y ) forclipping, etc.?

x (worl d)

y (world)

a

b

C l i p p i n g w i n d o w

CS4815

AnnouncementsT Di i l Vi i Pi li

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 13/19

Two-Dimensional ViewingTwo-Dimensional Viewing Pipeline

Viewing-Coordinate Clipping Window

Given a scene in world coordinates, how do we transform apoint w = ( w x , w y ) to viewing coordinates v = ( v x , v y ) forclipping, etc.?

x (worl d)

y (world)

y ( v i e w )

x ( v i e w )

a

b

CS4815

AnnouncementsT Di i l Vi i g Pi li

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 14/19

Two-Dimensional ViewingTwo-Dimensional Viewing Pipeline

Viewing-Coordinate Clipping Window (contd.)

If the view coordinate system is located at (a , b ) we rstlytranslate it back to the world origin by subtracting theview-up vector , V = ( a , b )The angle, θ, that V makes with the y -world axis is what w must be rotated by to transform it in to viewing coordinates

Then the composite transformation M W , V to make thistransformation from w (world) to v (viewport) is

v = M W , V w

where

M W , V = R × T Translate rst, then Rotate

=cos θ − sin θ 0sin θ cos θ 0

0 0 1

1 0 − a 0 1 − b 0 0 1

CS4815

AnnouncementsTwo Dimensional Viewing Pipeline

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 15/19

Two-Dimensional ViewingTwo-Dimensional Viewing Pipeline

Normalization and Viewport Transformations

In some graphics systems normalization andwindow-to-viewport transformations are combined in toone operationIn this case axes of viewport coord. system are often given

in range of [0 , 1]After clipping, the square is mapped to the output displayAs an alternative, in other systems normalization andclipping are applied before viewport transformations

In these systems, the viewport boundaries are specied inscreen coords relative to the display-window positionWhat both systems have in common is a need to map apoint (x , y ) in one rectangle to (x , y ) in another

CS4815

AnnouncementsTwo-Dimensional Viewing Pipeline

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 16/19

Two-Dimensional ViewingTwo-Dimensional Viewing Pipeline

Normalization and Viewport Transformations (contd.)

cy

xc

Cy

Cx n x

n y

Nx

Clipping Window Normalization Window

Ny

(x,y)

(x’,y’)

What is transformation that maps (x , y ) within, say, theclipping window to (x , y ) in, say, a normalised window?In order to maintain the same relative position

x − n x

N x − n x = x − c x

C x − c x

y − n y

N y − n y =

y − c y

C y − c y

CS4815

AnnouncementsTwo-Dimensional Viewing Pipeline

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 17/19

Two-Dimensional ViewingTwo Dimensional Viewing Pipeline

Normalization and Viewport Transformations (contd.)

After solving for (x , y ) we get...

x = s x x + t x

y = s y y + t y

The scalings, s x and s y are

s x =N x − n x

C x − c x , s y =

N y − n y

C y − c y

The translation factors are

t x =C x n x − c x N x

C x − c x t y =

C y n y − c y N y

C y − c y

CS4815

Announcementsl

Two-Dimensional Viewing Pipeline

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 18/19

Two-Dimensional ViewingTwo Dimensional Viewing Pipeline

Normalization and Viewport Transformations (contd.)

So we get a composite transformation, M C , N that combinesa translation and a scaling

M C , N = T · S

=s x 0 t x 0 s y t y 0 0 1

CS4815

AnnouncementsT Di i l Vi i

Two-Dimensional Viewing Pipeline

8/7/2019 Computer Graphics 2-Dimensional Concepts

http://slidepdf.com/reader/full/computer-graphics-2-dimensional-concepts 19/19

Two-Dimensional Viewingg p

Normalization and Viewport Transformations (contd.)

This expression holds for any mapping from onerectangular coordinate system to anotherWhether the clipping window to viewport transformation isdone in one step or in two, the same procedure fordetermining the transformation matrix can be usedFor example, if we map from the clipping window to anormalized square [− 1 , 1] × [− 1 , 1], (then clip in thissquare and then convert to screen coords) the rsttransformation matrix of this pipeline is

M C , NS =

2C x − c x

0 − C x + c x C x − c x

0 2C y − c y

−C y + c y C y − c y

0 0 1

CS4815