Docsity

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

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