3d Viewing Trans

download 3d Viewing Trans

of 51

Transcript of 3d Viewing Trans

  • 7/29/2019 3d Viewing Trans

    1/51

    Projection Transformations

    and

    ew ng pe ne

  • 7/29/2019 3d Viewing Trans

    2/51

    App ly3 - D w o r ldcoo rd ina te

    Cl ip ag ain stcanon ica l

    n o r m a z n gt r a n s f o r m a t i o n

    o u t p u tr i m i t i v e s

    ViewV o l u m e

    Pro jec tTr a n sf o r m i n t o

    v iew or t in

    Pro jec t ion2D d ev icecoo rd ina tes

    2D d ev icecoo rd ina tes

    fo r d i sp lay

  • 7/29/2019 3d Viewing Trans

    3/51

    Canon ica l v i ew vo lum e fo r ara l le l p ro jec t i on i s de f in ed by s ix p lanes:

    X = 1 ; Y = 1 ; Z = - 1 .

    X = - 1 ; Y = - 1 ; Z = 0 ;

    X o r Y

    1

    BP

    - Z- 1

    -

  • 7/29/2019 3d Viewing Trans

    4/51

    Canon ica l v i ew vo lum e fo r er s ect iv e p ro jec t i on i s de f in ed by s ix p lanes:

    X = - Z; Y = Z; Z = - 1 .

    = ; = - ; = - m in ;

    X o r Y

    1FP

    - Z- 1

    - 1

    BP

  • 7/29/2019 3d Viewing Trans

    5/51

    VP, VRP, VUP, VPN, PRP, DOP, CW , VRC

    v

    (umax, vmax)

    VRPCW

    VPN(umin, vmin)

  • 7/29/2019 3d Viewing Trans

    6/51

    v

    u v

    VRPCW

    u

    VPN

    (umin, vmin)

    v

    n

    VRPCWVP u

    VPN

    ar b i t r a r y 3 D v i ew

    n COP/ PRP

  • 7/29/2019 3d Viewing Trans

    7/51

    Spec i fy ing an Arb i t r a r y 3D View

    V i e w i n g Example Valuese e e

    VRP WC 0 , 0 , 54 16 , 0 , 54 0 , 0 , 0

    VPN ( W C) ( 0 , 0 , 1 ) ( 0 , 1 , 0 ) ( 0 , 0 , 1 )

    VUP ( W C) ( 0 , 1 , 0 ) ( - 1 , 0 , 0 ) ( 0 , 1 , 0 )

    , , , , , ,

    W i n d o w ( - 1 , 1 7 , ( - 1 , 2 5 , ( - 5 0 , 5 0 ,

    -1 , 17 -5 , 21 -5 0 , 50Pro jec t ion

    Type

    F & B(VRC)

    + , - - -

  • 7/29/2019 3d Viewing Trans

    8/51

    St eps for im plem ent ing nor m al izingt ransfo rm at ion mat r ix fo r

    ar al le l ro ec t ion

    Tr ans lat e t h e VRP t o o r ig in

    Rot a t e VRC such t h a t VPN ( n -ax is) a l igns- , -

    su ch t ha t DOP is pa r a l lel t o t he Z-ax is

    Tr anslat e and sca le i n t o pa ra l le l - p r o j ect i onVV

    VRP)T(RSHTSN arararar

  • 7/29/2019 3d Viewing Trans

    9/51

    St ep 2 i n n o r m al izi n g t r a n sf o r m at i on s:

    Ro t a t e VRC such t h a t VPN ( n -ax is) a l ign sw i t h Z- ax i s a l so , u w i t h X an d v w i t h Y

    v

    VUP

    max, maxVP

    VRP

    u

    VPNm n, m n

    n

  • 7/29/2019 3d Viewing Trans

    10/51

    Ex pr essions fo r St ep 2 m us t be de r i v ed .

    I m p l em en t u si n g t h e co n cep t o f co m b i n edt r an sf o r m at i o n ( r o t a t i on ) .

    Tak e R =

    0)sin()cos(0

    1000

    0)cos()sin(0

    Ro w s ar e u n i t ve ct o r s, w h e n r o t a t ed b y Rx ,

    w a g n w e an ax s r esp ec v e y .

    ar e r o t a t ed b y Rx , t h ey f o r m t h e co lu m n

  • 7/29/2019 3d Viewing Trans

    11/51

    0001Rx =

    0)sin()cos(0

    1000

    Row Vectors: [ 1 0 0 ]

    Z

    [ 0 sin() cos() ]Column Vectors {con side r Rx ( -) ,

    n t s case :[ 1 0 0 ]T

    cos -s n [ 0 sin() cos() ]T

  • 7/29/2019 3d Viewing Trans

    12/51

    Con s ider a gen era lYscenar io o f com b in ed

    r o t at i on s an d u se t h eP3p r oper t y de r i ved basedo n t h e o r t h o g on a l i t y

    P2

    P

    o e m a r x .Y

    Pn

    Z

    3Befo reT rans fo rma t ion

    XP1 Pn

    P

    Af te r

    Z

  • 7/29/2019 3d Viewing Trans

    13/51

    Let t h e e f fec t i ve r o t a t i on m at r ix b e

    a com b ina t i on

    xxx

    rrr Yo f t h r ee r o w s as: rrr 3 P2Pw h e r e , X

    T 1 2

    z 1z 2z 3z

    P PR = r r r =

    P P

    n

    T 1 2 1 3P P X P P= =x x x x1 2 1 3

    P P X P P3

    Pn

    T

    = =

    XP1

    y 1y 2y 3y z x Z 2

  • 7/29/2019 3d Viewing Trans

    14/51

    Y Y

    3

    P2P P3

    X X

    n

    n

    Z P2

    Th u s t h e r o t a t i o n m at r i x o f st ep 2 i n

    ,f o r m u lat ed a s:

    0rrr 3x2x1x

    0rrr 3y2y1y

    0rrr 3z2z1z

  • 7/29/2019 3d Viewing Trans

    15/51

    St ep 2 i n n o r m al izi n g t r a n sf o r m at i on s:

    Ro t a t e VRC such t h a t VPN ( n -ax is) a l ign sw i t h Z- ax i s a l so , u w i t h X an d v w i t h Y

    v

    VUP

    max, maxVP

    VRP

    u

    VPNm n, m n

    n

  • 7/29/2019 3d Viewing Trans

    16/51

    z

    ;VPN

    R w h e r e

    RP x ;RVUP

    RRRand

    f o r pa ra l l e l p ro j ect i on ( W CSVV - > PPCVV) , i s:

    VRP)T(RSHTSNparparparpar

  • 7/29/2019 3d Viewing Trans

    17/51

    Th e ove r a l l co m b in ed t r a n sf o r m at i on m at r i xo r p ar a e p r o ect on - > , s:

    parparparparw h e r e ,

    001 parshx ;xpar opshx

    0100

    par

    parSHz

    do 1000 parz

    s ydop

    DOP DOP

    -z

    VPN VPNSide v iew o f

    -z

  • 7/29/2019 3d Viewing Trans

    18/51

    Th e ove r a l l co m b in ed t r a n sf o r m at i on m at r i xo r p ar a e p r o ect on - > , s:

    parparparpar

    ;minmaxminmax FP

    vvuuTpar

    122minmaxminmax BPPvvuu

    par

  • 7/29/2019 3d Viewing Trans

    19/51

    transformation matrixfor perspective projection

    v

    VRPVP

    uVPN

    n

  • 7/29/2019 3d Viewing Trans

    20/51

    Canon ica l v i ew vo lum e fo r perspec t i ve p ro jec t i on i s de f in ed by s ix p lanes:

    X = - Z; Y = Z; Z = - 1 .

    = ; = - ; = - m in ;

    X o r Y

    1FP

    - Z- 1

    - 1

    BP

  • 7/29/2019 3d Viewing Trans

    21/51

    Ste s for im lementin normalizin

    transformation matrix for

    r an s a e e o o r g n

    V V -w i t h Z- ax i s ( a lso , u w i t h X- an d v w i t h Y- ax i s)

    r an s a e su c a o r s a eo r i g in

    Sh e ar su ch t h a t cen t er l in e o f v i ew vo lu m e( VVCL) becom es z -ax is

    Sca le su ch t h a t VV becom es t h e canon ica l

  • 7/29/2019 3d Viewing Trans

    22/51

    Scenar io o f t h e cr oss-sect ion o f t he VVa t er r st t r ee t r an s or m at on s.

    X o r Y

    CW

    - Z

    VPN

    VRPTRPRPTSHSNarerer

    ()(

  • 7/29/2019 3d Viewing Trans

    23/51

    Com ar ison t h e ov er a l l com b in edt r a n sf o r m at i on m at r i ces f or :

    PARALLEL PROJECTI ON:

    VRP)T(RSHTSN parparparpar PERSPECTI VE PROJECTI ON:

    VRP)T(RPRP)T(SHSN parperper

  • 7/29/2019 3d Viewing Trans

    24/51

    App ly3 - D w o r ldcoo rd ina te

    Cl ip ag ain stcanon ica l

    n o r m a z n gt r a n s f o r m a t i o n

    o u t p u tr i m i t i v e s

    ViewV o l u m e

    Pro jec tTr a n sf o r m i n t o

    v iew or t in

    Pro jec t ion2D d ev icecoo rd ina tes2D d ev icecoo rd ina tes

    fo r d i sp lay

  • 7/29/2019 3d Viewing Trans

    25/51

    dd

    dd

    z

    p

    z

    en er a ze

    f o r m u l a

    dz

    d10

    z

    y

    p

    z

    yo p er sp ec v ep r o j ect io n m at r i x :

    Zd

    Zd

    Z00 ppp

    gen

    1

    Z1

    00

    p

    zzPP

    P(xp, yp, Zp)L

    P(X,Y,Z)(dx, dy, dz)

    (0, 0, Zp)

  • 7/29/2019 3d Viewing Trans

    26/51

    Coor dinat e S st em s and Mat r ic es

    Per s ect iv ePara l le l

    3 - D m o d el in g Mode l ing

    coo rd ina tes

    ViewOr ien ta t i on

    o rCoord ina tesR.T(-VRP)

    - m a r x.

    Cont

  • 7/29/2019 3d Viewing Trans

    27/51

    View ViewMa in

    ew

    re fe rence

    m a t r i x m a t r i xs

    Cl ip , t r ans fo r m

    in t o 2D scr een

    or m a zep r o je c t i o n

    coo rd ina tes

    MCVV3DVP

    ev cecoord ina tes

    M . Sp er . SH p ar . T( - PRP)

    S . T . SH

  • 7/29/2019 3d Viewing Trans

    28/51

    w here af t er cl ipp i ng , use

    MCVV3DVP =

    .)Z,Y,T(X vminvminvmin

    ZZ

    YYXX

    Svminvmaxvminvmax 22

    , ,.

  • 7/29/2019 3d Viewing Trans

    29/51

    The 3D View ing Pipe l ine

    Ob j ect s a re m odeled i n ob j ect ( m odel i ng )

    space.

    Tr ansfo r m a t ions ar e app l ied t o t he ob j ect s

    t o p o si t i o n t h e m i n w o r l d sp ace.

    View pa ram et ers ar e speci f i ed t o de f i nee v ew v o u m e o e w or , a p r o ec on

    p lane , and t he v iew po r t on t he scr een .

  • 7/29/2019 3d Viewing Trans

    30/51

    ec s ar e c p p e o s ew v o u m e.

    e r esu s ar e p r o ec e on o ep r o j e ct i o n p lan e ( w in d o w ) an d.

    en o ec s ar e en r em ov e .

    Th e ob j ect s a re scan con ver t ed and

    t hen shaded i f n ecessary .

    Fl h t f t h 3D Vi i Pi l i

  • 7/29/2019 3d Viewing Trans

    31/51

    Flow c har t of t he 3D V iew in Pi e l ine

    Objec t

    Ob jec t

    , ,T rans la te

    W o r l dSpaceW o r l d

    S aceSpeci f y View ,l l N r m l

    App ly No rm a li zi ng

    I l l u m i n a t i o n ,Backface

    Clip

    Space

  • 7/29/2019 3d Viewing Trans

    32/51

    Ey e I m a g e

    Trans fo rma t ionRemoveHidden

    Space Space

    u r aces

    Shade,

    ap oV i e w p o r t /

    Dev ice

    screenoor n at es

  • 7/29/2019 3d Viewing Trans

    33/51

    he Com put erraphic s Pipe l ine

  • 7/29/2019 3d Viewing Trans

    34/51

    The Cam era Model

  • 7/29/2019 3d Viewing Trans

    35/51

    The Cam era Model

    W e speci f y ou r i n i t i a l cam er a m odel by.

    1 . A scen e con sist in o f o l on l e lem en t s

    each r ep resen t ed by t he i r v e r t i ces;

    . p o n a r ep r esen s e cam er ap o si t i on : C = [ Cx , Cy , Cz] ;

    3 . A p o in t t h a t r e p r esen t s t h e cen t er - o fa t t en t i on o f t h e cam er a ( i .e . w h er e t h e

    cam er a is l oo k i n g) : A = [ A x , A y , A z] ;. e - o - v ew an g e, ,r ep r esen n g e

    an g le su b t en d e d at t h e ap ex o f t h e v i ew in g

    p y .

    The speci f i ca t ion o f nea r

  • 7/29/2019 3d Viewing Trans

    36/51

    The speci f i ca t ion o f nea ran ar ou n n g p an es.

    Th ese p l anes con s ider edp er p en cu ar o e

    d i r e ct i on - o f - v i ew ve ct o r

    n an d f f r o m t h e,

    respec t i ve ly .FarPla

    eC

    Th e View i n P r am id

  • 7/29/2019 3d Viewing Trans

    37/51

    Th e View i n P r am id

    v iew ing space

    Far

    vPlan

    Th e im age spacev o l u m e :

    1wv,u,1

    Side v iew o f t he v iew ing space

  • 7/29/2019 3d Viewing Trans

    38/51

    Side v iew o f t he v iew ing space

    Fa

    rPla

    earPlane

    ne

    f

    Der ivat ion of t h e v iew in t r ansfor m at i on

  • 7/29/2019 3d Viewing Trans

    39/51

    Der ivat ion of t h e v iew in t r ansfor m at i onm at r ix , i n t e rm s of c amera pa ram ete rs :

    d.u d.v d.u d.v d.w(u,v,w) ( , , d) ( , , )

    w w w w wThus

    (u, v, w, 1) (d.u, d.v, d.w, w)

    P( u , v , w )u o r v

    u v w

    PP

    O ( COP) - w

    Express as transformation:

  • 7/29/2019 3d Viewing Trans

    40/51

    Express as transformation:

    001000d0

    d1001d00 d

    000d

    wd.wd.vd.u00d0

    1wvu

    0000

    Tr a n sf o r m at i on o f t h e f in i t e ( t r u n cat ed )

  • 7/29/2019 3d Viewing Trans

    41/51

    Tr a n sf o r m at i on o f t h e f in i t e ( t r u n cat ed )v iew in g p y r am id t o t h e

    cu be ( CVV) , - 1 < u , v , w < 1 .Th e im age space

    Let us f i r s t ana l yze w -ax i s on l y . 1wv,u,1 Use t e t r an s o r m at on m at r x :

    su ch t h a t ,

    ;P

    , , - , ,

    an d- -

    , , , ,

    So l ve f o r a ram et er s a and b u sin t h eabove equ a t ion s:

  • 7/29/2019 3d Viewing Trans

    42/51

    ab o ve t w o eq u a t i o n s:

    .

    nTh e n

    :

    .b

  • 7/29/2019 3d Viewing Trans

    43/51

    Hence t he 0001t r a n sf o r m at i on i s:

    0010

    nfP

    0

    2f.n00

    a a ou u an v - ax s r an s o r m a on si n t h e py r a m i d ?

    u an d v - a x i s t r a n sf o r m at i on s

  • 7/29/2019 3d Viewing Trans

    44/51

    i n t h e p y r am id

    u o r v

    n . tan

    / 2.

    O COP - w 0 , 0 , - n 0 , 0 , - f

  • 7/29/2019 3d Viewing Trans

    45/51

    Tr a n sf o r m at i on s f o r t h e t w o p o i n t s

    a re as fo l l ow s:

    ( 0 , n . t an ( / 2 ) , - n ) ( 0 , f . t an ( / 2 ) , - f )

    / 2O ( COP) - w ( 0 , 0 , - n ) ( 0 , 0 , - f )

  • 7/29/2019 3d Viewing Trans

    46/51

    0010

    Desi r ed no r m a l i zed 3 - D

    co o r d in at es f o r b o t h t h e

    1

    nf

    n00P

    po in t s : [ 0 , 1 , + / - 1 , 1 ] .

    0nf

    .n00

    .1f/2)f.tan(0 P

    f2nfnf

    f/2)f.tan(0

    ff/2)f.tan(0

    Th u s m o d i f y Pt o b e:

    000)2/cot(

    t

  • 7/29/2019 3d Viewing Trans

    47/51

    nf

    cot

    '

    nf

    0nf

    .00

    '2nfnf

    ..

    n

    nfnf

    nn

    110

  • 7/29/2019 3d Viewing Trans

    48/51

    I t s in v e r se h as t h e f or m :

    000tan )2/(

    00tan0 )2/(

    2fn

    000P 1

    nf

    100n

    The V iew ing Trans for m at ion Mat r i x

    .df

  • 7/29/2019 3d Viewing Trans

    49/51

    000)2/(d.cot

    .df

    2n)d(f 00)2/(d.cot0 n

    0000 nf

    0010or

    00d0

    000d

    P

    00cot(0

    000)cot(

    )2/

    2/

    0000 d

    100

    0000

    1d00

    1

    nf

    n00P

    00d0

    000d

    0nf

    .00

    ...

    0000

    1d00

    or

    us ing t he r egu la r ex p r ession o f Pd

  • 7/29/2019 3d Viewing Trans

    50/51

    00)2/(cot0

    1

    2fn-n)d(f00

    0000

    0010or

    00d0

    000d

    P

    00cot(0

    000)cot(

    )2/

    2/

    0000 d

    100

    0000

    1d00

    1

    nf

    n00P

    00d0

    000d

    0nf

    .00

    ...

    0000

    1d00

  • 7/29/2019 3d Viewing Trans

    51/51

    End of Lectures on

    Pro ection Transformationsand

    ew ng pe ne