+ All Categories
Home > Documents > 3 DIMENSIONAL VIEWING - Middle East Technical...

3 DIMENSIONAL VIEWING - Middle East Technical...

Date post: 04-Feb-2018
Category:
Upload: trinhthu
View: 217 times
Download: 0 times
Share this document with a friend
35
3 DIMENSIONAL 3 DIMENSIONAL VIEWING VIEWING Ceng 477 Computer Engineering Lecture notes METU
Transcript
Page 1: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

3 DIMENSIONAL3 DIMENSIONALVIEWINGVIEWING

Ceng 477 Computer EngineeringLecture notes

METU

Page 2: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Model

Model

Model

M1

M2

M3

3D WorldScene

3D ViewScene

V

P Clip Normalize2D/3D DeviceScene

2D Image

Projection

Rasterization

ModelingTransformations

ViewingTransformations

MCS WCS VCS

NDCS DCSSCS

3D Viewing Pipeline, Revisited

Page 3: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Model coordinates to World coordinates:Modelling transformationsModel coordinates:1 sphere (head),2 semispheres (eyes),1 semisphere (nose),1 torus (hat),1 cone (hat).With their relative coordinates and sizes

World coordinates:All shapes with theirabsolute coordinates and sizes.

zworld

xworld

yworld

Page 4: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● World coordinates to Viewing coordinates:Viewing transformations

World coordinates Viewing coordinates:Viewers (Camera) position and view angles. i.e. rotated/translated

zworld

xworld

yworld x

view

yview

zview

Page 5: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Projection: 3D to 2D. Perspective or parallel. Depth cue. Visible surface detection.

xview

yview

zview

Page 6: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Clipping: Find parts of the object in the viewing area. Project, then clip in 2D vs. clip against a view volume, then project.

Page 7: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Device Independent Coordinates to Device Coordinates. Rasterization. Illumination, shading.

Unit measures Pixels

Device Independent Coordinates

Screen Coordinates orDevice Coordinates

Page 8: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Viewing Transformation

● How to define the viewing coordinate system (or view reference coordinate system):

– Position of the viewer P (enough?)

– Orientation of the viewer:● Viewing direction. N

(view plane normal)● View up vector. V ● N and V should be

orthogonal. (if it is not?)

zw

xw

yw

P N

V

xv

yv

zv

vun

Page 9: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Transformation Between Coordinate Systems

● Given the objects in world coordinates, find the transformation matrix to transform them in view coordinates. n, v, u : unit vectors defining view coordinates.

zw

xw

yw

PN

V

Page 10: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Translation: Move view reference point to origin.

P= x0, y0, z0

T=[1 0 0 −x0

0 1 0 −y0

0 0 1 −z0

0 0 0 1]

xw

yw

PN

V

zw

xw

yw

zw

N

V

Page 11: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Rotation: find orthogonal base vectors for the transformation, n, v and u.

Align nwith zw ; v with yw ; uwith xw

n= N∣N∣

u= V×N∣V×N∣

v=n×u

R=[u1 u2 u3 0v1 v2 v3 0n1 n2 n3 00 0 0 1

] MWC ,VC=R⋅T

xw

yw

zw

N

V

xw

yw

zw

n

v u

xw

yw

zw

vu

n

Page 12: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Projections

● Classification of projections. Based on:

– Center of projection: infinity (parallel) or a point (perspective)

– Projection lines wrt. projection plane: orthogonal (orthographic), another angle (oblique)

Center of projection Projection plane

Center of projection

Projection plane

Center of projection

Projection plane

OrthographicPerspective Oblique

Page 13: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Planar Geometric Projections

Parallel Perspective

Orthograpic Oblique

Top

FrontSide

Axonometric

Other

Isometric

One-point

Cavalier

Other 2-point3-pointCabinet

Page 14: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Multiview Orthographic:

– Parallel projection to z=0,y=0,x=0 planes

– Used for engineering drawings, architectural drawing

– Accurate, scales preserved. Not 3D realistic.

Top

FrontSide

Page 15: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Axonometric Projections

– Projection plane is not parallel to coordinate planes

– Isometric: all angles betweenprincipal axes are equal

– Dimetric: angles between two principal axes are equal

– Trimetric: all angles different

120120

120

αα

Page 16: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Isometric Projection (i.e. N=[c,c,c])

– More realistic. Scales preserved along axes.

– Used in designs and catalogues. Suitable for rectangular bodies.

– Exercise: Calculate rotation matrix for isometric projection, up vector on x=z.

Page 17: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Oblique projections

– Projectors have an oblique angle

– One of the sides have exact dimensions. Others are proportional.

– Mechanical viewing

Page 18: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Types of Oblique projections:– Cavalier: Angle between projectors and projection plane is 45.

Depth is projected full scale

– Cabinet: Angle between projectors and proejction plane is arctan(2)=63.4... . Depth is projected ½ scale.

11

1 11

1

1

1

½ 1

Page 19: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Parallel Projection Summary

● Multiview orthographic

– VPN || a principal coordinate axis

– DOP || VPN

– Single face, exact dimensions

● Axonometric

– VPN not || a principal coordinate axis

– DOP || VPN

– Not exact dimensions

● Oblique

– VPN || a principal coordinate axis

– DOP not || VPN

– One face exact dimension.

VPN

DO

P

VPN

DOP

VPN

DOP

Page 20: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Perspective Projection

● Single point center of projection

● Shapes are projected smaller as their distance increase.

● More realistic (human eye is a perspective projector)

● Depending on number of principal axes intersecting the viewing plane: 1, 2 or 3 vanishing points

Projection plane

Center of projection

Page 21: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● One point perspectiveonly z axis intersectssingle vanishing point

● Two-point perspectivex and z axes intersecttwo vanishing points

● Three-point perspectiveall axes intersectthree vanishing points

Page 22: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Axonometric Parallel Projections

● If view plane normal is alignedto one of the axes, simply ignorethat axis.

● Other Axonometric projections:apply the required rotation to align view plane normal to z axis, and apply the projection above.

P (x,y,z)P (x,y)x p=x y p= y

M parallel=[1 0 0 00 1 0 00 0 0 00 0 0 1

]

Page 23: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Oblique Projections

● Two angles selected:α: points, projection and view planeφ: direction of z axis in projection

P (x,y,z)

P (x,y,z)

(x,y)

L

(x,y)

L

(xp,y

p)

(xp,y

p)

α

φ

(x,y)

(xp,y

p)

L is the distance between: x , y and x p , y p

L= ztan

If L1=1

tan, also L at z=1:

L=z L1

x p=xz L1 cosy p= yz L1 cos

M oblique=[1 0 L1 cos 00 1 L1sin 00 0 0 00 0 0 1

]

Page 24: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Cavalier projection:

● Cabinet projection:

11

1 11

1

1

1

½ 1

=45 ˚ , L1=1

=45 ˚ =30 ˚

=63.4 ˚ , L1=12

=30 ˚=45 ˚

Page 25: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Perspective Projection

● x and y dimensions dependson values of their values andz values.

P (x,y,z)

P (x,y,z)

(x,y)

(xp,y

p)

(xp,y

p,z

vp)

(0,0,zvp

) (0,0,zprp

) dp

z prp−z

z prp−zvp

= yy p

d p=z prp−z vp

y p= yd p

z prp−zsimilarly: x p=x

d p

z prp−z

Special case: zvp=0

x p=x1

1−z / z prp

y p= y1

1−z / z prp

Special case: z prp=0

x p=xzvp

zy p= y

zvp

z

Page 26: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Perspective projection is not linear. Solution: homogenous coordinates, forth axis:

● Where does zh comes from?

● Special cases

[ xh

yh

zh

h]=[1 0 0 0

0 1 0 00 0 −zvp /d p z vp z prp /d p0 0 −1/d p z prp /d p

]⋅[ xyz1] h=

z prp−z

d p

x p=xh

h

y p=yh

h

zvp=0 [1 0 0 00 1 0 00 0 0 00 0 −1/ z prp 1] z prp=0 [1 0 0 0

0 1 0 00 0 1 00 0 1/ zvp 0]

Page 27: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

View Volumes

● Clipping planes:

– left, right, top, bottom

– front, back

● Front: objects closer not focusable, hide most of the scene, perspective projection give distorted shapes.

● Back: very small, not visible but expensive.

● Clip the objects out of the view volume

Page 28: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● View volumes (parallel)

window

VPN

DOP

window

VPN

DOP

windowVPN D

OP

window

VPN D

OP

orthogonal

oblique

Page 29: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

window

window

● View volumes (perspective)

VPN

DOP

DOP

windowVPN D

OP

VPN

DO

P

DOP ortogonal

DOP obliqueVPN

window

Page 30: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

General Parallel Projections● Given the projection reference point and viewing vector,

find the projection transformationN

V'

window

View volume

N

window

V

View volume

if V= px , p y , p z, align V on N :

V '=M⋅V=[ 00pz

0] M is a shearing transformation mapping V to N , solve:

M=[1 0 a 00 1 b 00 0 1 00 0 0 1

] pxa p z=0p yb pz=0

a=−px

p z

b=− p y

p z

Page 31: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

● Parallel projection transformation:

● Note the similarity in oblique projection calculations.

M parallel=[1 0 − px / pz 00 1 −p y / pz 00 0 1 00 0 0 1

]

Page 32: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

General Perspective Projection

● Given a perspective point and window, find the projection transformation giving a parallel view volume.

1. Translate perspective point to (0, 0, zprp).

2. Shear so that line from perspective point to window center be orthogonal to viewing frustum

3. Map frustum to a parallelpipe

window

View volume

window

View volume

(xprp,yprp,zprp)

window

View volume

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

Page 33: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Translate and shear to align x prp , y prp , z prp vector to view plane normal

M shear=[1 0 a −a z prp

0 1 b −b z prp

0 0 1 00 0 0 1

] a=−x prp−xwminxwmax/2

z prp

b=−y prp− ywmin ywmax/2

z prp

x '=xa z−z prpy '= yb z−z prpz '=zMap values in frustum to a parallelpipe

x ' '=x ' z prp−zvp

z prp−zx prp

zvp−z

z prp−z

y ' '= y ' z prp−zvp

z prp−z y prp

zvp−z

z prp−z

M scale=[1 0−x prp

d

x prp zvp

d

0 1−y prp

d

y prp zvp

d0 0 1 00 0 −1/d z prp/d

] M pers=M scale⋅M shear

Page 34: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Normalized View Volume

● Mapping the projected view volume into a unit cube:

– Device independent standart view volume

– Clipping is simplified, unit clipping planes

– Simpler depth cueing● Scale and translate into normalized view volume:

x=0 , x=1, y=0, y=1, z=0, z=1

[Dx 0 0 K x

0 D y 0 K y

0 0 Dz K z

0 0 0 1]

Dx=xvmax−xvmin

xwmax−xwmin

D y=yvmax− yvmin

ywmax− ywmin

Dz=zvmax−zvmin

zback−z front

K x=xvmin−xwmin Dx

K y= yvmin− ywmin D y

K z=zvmin−z front Dz

Page 35: 3 DIMENSIONAL VIEWING - Middle East Technical Universityocw.metu.edu.tr/.../251/mod_resource/content/0/3dviewing.pdf · Given the projection reference point and viewing vector, find

Clipping

● 2D clipping algorithms can be extended to handle 3D clipping. Instead of intersection with border lines, intersection with planes are considered

● Cohen-Sutherland bits:

● Parametric line equations

bit1=1, if xxvmin (left)bit2=1, if xxvmax (right)bit3=1, if y yvmin (below)bit4=1, if y yvmax (above)bit5=1, if zzvmin (front)bit6=1, if zzvmax (back)

x=x1x2−x1u , 0u1y= y1 y2− y1uz=z1 z2−z1u


Recommended