Understanding Window-to-Viewport Mapping in Computer Graphics, Slides of Computer Graphics

The concept of window-to-viewport mapping in computer graphics, which is used to transform points from world coordinates to screen coordinates. The basics of screen and world coordinate systems, the need for window-to-viewport mapping, and the steps to calculate the corresponding screen coordinates for a given world coordinate. It also includes an example using opengl and a more detailed explanation of the calculation process.

Typology: Slides

2012/2013

Uploaded on 04/27/2013

balraj
balraj 🇮🇳

4.6

(8)

36 documents

1 / 15

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Computer Graphics
2D Graphic Systems
Docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff

Partial preview of the text

Download Understanding Window-to-Viewport Mapping in Computer Graphics and more Slides Computer Graphics in PDF only on Docsity!

Computer Graphics

2D Graphic Systems

2D Graphics: Coordinate Systems

n Screen coordinate system

n World coordinate system

n World window

n Viewport

n Window to Viewport mapping

Screen Coordinate System

Insert screen

dump from

OHIO

World Coordinate System

  • Problems with drawing in screen coordinates:
    • Inflexible
    • Difficult to use
    • One mapping: not application specific
  • World Coordinate system: application-specific
  • Example: drawing dimensions may be in meters, km, feet,

etc.

Definition: Viewport

•Rectangular region in the screen used to display drawing

•Defined in screen coordinate system

V.L V.R

V.B

V.T

Window to Viewport Mapping

n Would like to:

n Specify drawing in world coordinates

n Display in screen coordinates

n Need some sort of mapping

n Called Window-to-viewport mapping

n Basic W-to-V mapping steps:

n Define a world window

n Define a viewport

n Compute a mapping from window to viewport

Window to Viewport Mapping (Our Way)

n How is window-to-viewport mapping done?

n Trigonometry: derive Window-to-Viewport mapping

n Basic principles:

n Calculate ratio: proportional mapping ratio (NO distortion)

n Account for offsets in window and viewport origins

n You are given:

n World Window: W.R, W.L, W.T, W.B

n Viewport: V.L, V.R, V.B, V.T

n A point (x,y) in the world

n Required: Calculate corresponding point (s.x, s.y) in screen

coordinates

Window to Viewport Mapping (Our Way)

(x,y) (sx,sy)

V R V L

Sx V L

W R W L

x W L

V T V B

Sy V B

W T W B

y W B

W.T-W.B

W.R-W.L

V.T-V.B

V.R-V.L

Window to Viewport Mapping (Our Way)

Solve, given the formulas:

Sx = Ax −^ (^ A ( W .L ) − V .L )

Sy = By −^ (^ B ( W .B ) − V .B )

W = (W .L,W.R,W.B,W.T) = ( 0 , 4 , 0 , 2 )

What is (Sx,Sy) for point (3.4,1.2) in world coordinates if:

V = (V .L,V.R,V.B,V.T) = ( 60 , 380 , 80 , 240 )

Window to Viewport Mapping (Our Way)

Solution:

W R W L

V R V L

A

Sx Ax A W L V L

W T W B

V T V B

B

Sy By B W B V B

Sx = 80 x + 60 = 332 Sy =^80 y +^80 =^176

Hence, point (3.4,1.2) in world = point (332,176) on screen