Viewing The Camera and Projection Gail Carmichael ([email protected])

31
Viewing The Camera and Projection Gail Carmichael ([email protected])

Transcript of Viewing The Camera and Projection Gail Carmichael ([email protected])

Page 1: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Viewing

The Camera and Projection

Gail Carmichael ([email protected])

Page 2: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

The Goal

Understand the process of getting from 3D line

segments to images of these lines on the screen.

Page 3: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Canonical View Volume

Windowing transform brings points to pixels: MW

Page 4: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

xpixel

ypixel

1

=

xcanonical

ycanonical

1

Canonical View Volume

Mw

Page 5: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Orthographic Projection

Orthographic Perspective

Page 6: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Orthographic Viewing Volume

Page 7: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Orthographic View to Canonical View

x

y

z

1

World to Canonical Coordinates

Scale Move toOrigin

Page 8: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Orthographic View to Canonical View

2/(r-l)

0 0 0

02

/(t-b)0 0

0 02

/(n-f)0

0 0 0 1

x

y

z

1

1 0 0-(l+r)

/2

0 1 0-(b+t)

/2

0 0 1-(n+f)

/2

0 0 0 1

World to Canonical Coordinates

Page 9: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Drawing Lines in Orthographic View

Mo=Mw Mscale Mmove_to_origin

xpixel

ypixel

zcanonical

1

= Mo

x

y

z

1

Page 10: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Arbitrary View Positions

Camera is looking this

wayCamera is centered here

Top of cameragoes this way

Page 11: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Arbitrary View Positions

w = - (g / ||g||)

u = (t × w) / || t × w ||

v = w × u

Page 12: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Arbitrary View Positions

Page 13: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Coordinate Transformations

Page 14: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Coordinate Transformations

Page 15: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Coordinate Transformations

Page 16: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Coordinate Transformations

p = (xp,yp) ≡ o + xpx + ypy

p = (up,vp) ≡ e + upu + vpv

Page 17: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Coordinate Transformationsp = (xp,yp) ≡ o + xpx + ypy

p = (up,vp) ≡ e + upu + vpv

Page 18: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Coordinate Transformations

xp

yp

1

=

up

vp

1

? ?

p = (xp,yp) ≡ o + xpx + ypy

p = (up,vp) ≡ e + upu + vpv

Page 19: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Coordinate Transformations

xp

yp

1

=

1 0 xe

0 1 ye

0 0 1

up

vp

1

xu xv 0

yu yv 0

0 0 1

p = (xp,yp) ≡ o + xpx + ypy

p = (up,vp) ≡ e + upu + vpv

Page 20: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Camera Coordinate Transform

Page 21: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Camera Coordinate Transform

Mv =

1 0 0 -xe

0 1 0 -ye

0 0 1 -ze

0 0 0 1

xu yu zu 0

xv yv zv 0

xw yw zw 0

0 0 0 1

Page 22: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Drawing with Arbitrary View and Orthographic Projection

xpixel

ypixel

zcanonical

1

= Mo Mv

x

y

z

1

Page 23: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Perspective Projection

ys = y(d/z)

Page 24: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Perspective Via Orthographic

Page 25: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Perspective Via Orthographic

Page 26: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Perspective Via Orthographic

Page 27: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Perspective Transform

Mp =

1 0 0 0

0 1 0 0

0 0(n+f)

/n-f

0 01

/n0

Page 28: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Perspective Transform

Mp

x

y

z

1

=

x

y

z[(n+f)/n] - f

z/n

nx/z

ny/z

n + f – (fn/z)

1

Page 29: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Perspective Transform

Mp =

n 0 0 0

0 n 0 0

0 0 (n+f) -fn

0 0 1 0

Page 30: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

Drawing with Arbitrary View and Perspective Projection

xpixel

ypixel

zcanonical

1

= Mo Mp Mv

x

y

z

1

Page 31: Viewing The Camera and Projection Gail Carmichael (gail_c@scs.carleton.ca)

CAUTION!!

Everything up until now used the more common right-hand

coordinate system.

Direct3D uses the left-hand coordinate system.

See:http://msdn.microsoft.com/en-us/library/windows/desktop/bb204853%28v=vs.85%29.aspx