Viewing in 3D (Chapt. 6 in FVD, Chapt. 12 in Hearn & Baker) - - PDF document

viewing in 3d
SMART_READER_LITE
LIVE PREVIEW

Viewing in 3D (Chapt. 6 in FVD, Chapt. 12 in Hearn & Baker) - - PDF document

Viewing in 3D (Chapt. 6 in FVD, Chapt. 12 in Hearn & Baker) Specifying the Viewing Coordinates Viewing Coordinates system , [x v , y v , z v ], describes 3D objects with respect to a viewer. A viewing plane ( projection plane ) is


slide-1
SLIDE 1

Viewing in 3D

(Chapt. 6 in FVD, Chapt. 12 in Hearn & Baker)

Specifying the Viewing Coordinates

  • Viewing Coordinates system,

[xv, yv, zv], describes 3D objects with respect to a viewer.

  • A viewing plane (projection

plane) is set up perpendicular to zv and aligned with (xv,yv).

  • To set a view plane we have to

specify a view-plane normal vector, N, and a view-up vector, V, (both, in world coordinates):

slide-2
SLIDE 2

yw xw zw

P P0 N

v xv yv zv

V i e w p l a n e

  • P0=(x0,y0,z0) is a point where a

camera is located.

  • P is a point to look-at.
  • N=(P0-P)/|P0-P| is the view-plane

normal vector.

  • V=zw is the view up vector,

whose projection onto the view- plane is directed up.

  • How to form Viewing

coordinate system :

  • The transformation, M, from

world-coordinate into viewing- coordinates is:

v v v v v

x z y N V N V x N N z × = × × = = ; ;

T R z y x z z z y y y x x x M

v v v v v v v v v

⋅ =             − − −               = 1 1 1 1 1

3 2 1 3 2 1 3 2 1

slide-3
SLIDE 3

Projections

  • Viewing 3D objects on a 2D display

requires a mapping from 3D to 2D.

  • A projection is formed by the

intersection of certain lines (projectors) with the view plane.

  • Projectors are lines from the center
  • f projection through each point in

the object.

Center of Projection

  • Center of projection at infinity

results with a parallel projection.

  • A finite center of projection results

with a perspective projection.

slide-4
SLIDE 4
  • A parallel projection preserves

relative proportions of objects, but does not give realistic appearance (commonly used in engineering drawing).

  • A perspective projection produces

realistic appearance, but does not preserve relative proportions.

Parallel Projection

  • Projectors are all parallel.
  • Orthographic: Projectors are

perpendicular to the projection plane.

  • Oblique: Projectors are not

necessarily perpendicular to the projection plane.

Orthographic Oblique

slide-5
SLIDE 5
  • Since the viewing plane is aligned

with (xv,yv), orthographic projection is performed by:

Orthographic Projection

                        =             =             1 1 1 1 1 1

v v v v v p p

z y x y x y x

P0

xv yv zv

(x,y,z) (x,y)

  • Lengths and angles of faces

parallel to the viewing planes are preserved.

  • Problem: 3D nature of projected
  • bjects is difficult to deduce.

Front view T

  • p

V i e w Side View

slide-6
SLIDE 6

Oblique Projection

  • Projectors are not perpendicular to

the viewing plane.

  • Angles and lengths are preserved

for faces parallel to the plane of projection.

  • preserves 3D nature of an object.

yv

(x,y,z) (x,y)

xv

(xp,yp)

  • Two types of oblique projections

are commonly used: – Cavalinear: α=45ο =tan−1(1) – Cabinet: α=tan-1(2)

yv

(0,0,1) (x,y)

xv

(xp,yp) φ

α

a

            + + =                         =             1 sin cos 1 1 sin 1 cos 1 1 φ φ φ φ a z y a z x z y x a a y x

v v v v v v v p p 1/a=tan(α) z/b= 1/a b=za xp=z⋅a⋅cos(φ) yp=z⋅a⋅sin(φ)

(x,y,z) b

slide-7
SLIDE 7
  • Cavalinear projection :

– Preserves lengths of lines perpendicular to the viewing plane. – 3D nature can be captured but shape seems distorted.

  • Cabinet projection:

– lines perpendicular to the viewing plane project at 1/2 of their length. – A more realistic view than the Cavalinear projection.

45°

1 1 1 x z y x z

45°

1/2 1 1

Cabinet Projection Cavalinear Projection

Perspective Projection

  • In a perspective projection, the center
  • f projection is at a finite distance from

the viewing plane.

  • Parallel lines that are not parallel to the

viewing plane, converge to a vanishing point. – A vanishing point is the projection of a point at infinity.

Z-axis vanishing point y x z

slide-8
SLIDE 8

Vanishing Points

  • There are infinitely many general

vanishing points.

  • There can be up to three axis

vanishing points (principal vanishing points).

  • Perspective projections are

categorized by the number of principal vanishing points, equal to the number of principal axes intersected by the viewing plane.

  • Most commonly used: one-point

and two-points perspective.

x y z

One point (z axis) perspective projection Two points perspective projection

z axis vanishing point. x axis vanishing point.

slide-9
SLIDE 9
  • Using similar triangles it follows:

x y z

(x,y,z)

(xp,yp,0)

center of projection

d d x z

(x,y,z)

xp

d z y d y d z x d x

p p

+ = + = ; ; ; = + ⋅ = + ⋅ =

p p p

z d z y d y d z x d x

  • Thus, a perspective projection

matrix is defined:

              = 1 1 1 1 d M per               + =                           = d d z y x z y x d P M per 1 1 1 1 1

; ; = + ⋅ = + ⋅ =

p p p

z d z y d y d z x d x

slide-10
SLIDE 10

Observations

  • Mper is singular (|Mper|=0), thus

Mper is a many to one mapping (for example: MperP=Mper2P).

  • Points on the viewing plane

(z=0) do not change.

  • The vanishing point of parallel

lines directed to (Ux,Uy,Uz) is at [dUx/Uz, dUy/Uz].

  • When d ∞, Mper Mort

What is the difference between moving the center of projection and moving the projection plane?

Center of Projection

z

Projection plane Center of Projection

z

Projection plane Center of Projection

z

Projection plane

Original Moving the Center of Projection Moving the Projection Plane

slide-11
SLIDE 11

Summary

Planar geometric projections

Parallel Perspective Orthographic Oblique Cavalinear Cabinet Other Top Front Side Other Two point One point Three point

Demo

slide-12
SLIDE 12

View Window

  • After objects were projected onto the

viewing plane, an image is taken from a View Window.

  • A view window cab be placed

anywhere on the view plane.

  • In general the view window is aligned

with the viewing coordinates and is defined by its extreme points: (xwmin,ywmin) and (xwmax,ywmax)

yv xv zv

View plane View window

(xwmin,ywmin) (xw

m a x,yw m a x)

View Volume

  • Given the specification of the view

window, we can set up a View Volume.

  • Only objects inside the view volume

will appear in the display, the rest are clipped.

slide-13
SLIDE 13
  • In order to limit the infinite view volume we

define two additional planes: Near Plane and Far Plane.

  • Only objects in the bounded view volume

will appear.

  • The near and far planes are parallel to the

view plane and specified by znear and zfar.

  • A limited view volume is defined:

– For orthographic: a rectangular parallelpiped. – For oblique: an oblique parallelpiped. – For perspective: a frustum. zv

Near Plane Far Plane w i n d

  • w

w i n d

  • w

zv

Near Plane Far Plane

Canonical View Volumes

  • In order to determine the objects that

are seen in the view window we have to clip objects against six planes forming the view volume.

  • Clipping against arbitrary 3D plane

requires considerable computations.

  • For fast clipping we transform the

general view volume to a canonical view volume against which clipping is easy to apply.

Viewing Coordinates

Projection Transformation Canonical view Transformation Clipping

slide-14
SLIDE 14

Canonical Volume for General Parallel-Projection

zv

window

zv

window Oblique Projection Shear

            + + =                         =             1 sin cos 1 1 1 sin 1 cos 1 1

v v v v v v v v c c c

z a z y a z x z y x a a z y x φ φ φ φ

Depth preserving Shear transformation: Translation:

                  + + + − + − =                                   + + − + − =                 1 2 2 2 1 1 2 1 2 1 2 1 1 ' ' ' n f z b t y l r x z y x n f b t l r z y x

c c c c c c c c c

zv far near yv xv left right top bottom

zv

window

zv

Translation

slide-15
SLIDE 15

zv zv

scaling 1

  • 1
  • 1

1

Scaling:

                      − ′ ⋅ − − ′ ⋅ − ′ ⋅ =                       ′ ′ ′                       − − − − =                       ′ ′ ′ ′ ′ ′ 1 2 2 2 1 1 2 2 2 1 n f z b t y l r x z y x n f b t l r z y x

c c c c c c c c c zv far near yv xv left right top bottom

Canonical Volume for General Perspective-Projection

slide-16
SLIDE 16

                                  + + =                 1 1 1 2 1 2 1 1

v v v c c c

z y x n b t n l r z y x

Depth preserving Shear transformation:

z

                  − =                     − + +                     + + 1 1 2 2 1 1 2 1 2 1 n n b t l r n b t n l r

z z z

Scaling:

                                      − − =                   ′ ′ ′ 1 1 1 2 2 1

c c c c c c

z y x b t n l r n z y x n n

slide-17
SLIDE 17

z z

1

  • 1
  • 1

1

Perspective transformation:

                  ′ ′ ′                   − − − − + − =                   ′ ′ ′ ′ ′ ′ 1 1 2 1 1 1

c c c c c c

z y x n f fn n f n f z y x

  • 1

z x x z x x ′ − ′ = ′ ′ ⇒ ′ − ′ = ′ ′ 1 z y y z y y ′ − ′ = ′ ′ ⇒ ′ − ′ = ′ ′ 1

[ ] [ ]

1 1 1 − → − n

[ ] [ ]

1 1 1 → − f

OpenGL Transformation Pipe-Line

Homogeneous coordinates in World System ModelView Matrix ModelView Matrix Projection Matrix Projection Matrix Clipping Clipping Viewport Transformation Viewport Transformation Viewing Coordinates Clip Coordinates Window Coordinates

slide-18
SLIDE 18

Viewport Transformation

(x0,y0) width height

  • 1

1

  • 1

1

( ) ( )

2 1 2 1 y height y y x width x x

c win c win

+ + ′ ′ = + + ′ ′ =