Projection-Computer Graphics

Embed Size (px)

Citation preview

  • 7/27/2019 Projection-Computer Graphics

    1/60

    Projection

  • 7/27/2019 Projection-Computer Graphics

    2/60

    Projection

  • 7/27/2019 Projection-Computer Graphics

    3/60

    Projection

    Conceptual model of 3D viewing process

  • 7/27/2019 Projection-Computer Graphics

    4/60

    In general, project ionstransform points in a coordinatesystem of dimension n into points in a coordinate system of

    dimension less than n.

    We shall limit ourselves to the projection from 3D to 2D.

    We will deal with planar geometr ic p ro ject ionswhere:

    The projection is onto a plane rather than a curved surface

    The projectors are straight lines rather than curves

    Projection

  • 7/27/2019 Projection-Computer Graphics

    5/60

    key terms Projection from 3D to 2D is defined by straightprojection rays

    (pro jectors) emanating from the 'center of project ion', passing

    through each point of the object, and intersecting the 'project ion

    plane' to form a projection.

    Projection

  • 7/27/2019 Projection-Computer Graphics

    6/60

    Planer Geometric Projection

    2 types of projections perspective andparallel.

    Key factor is the center of p roject ion.

    if distance to center of projection is finite : perspective

    if infinite : parallel

    A

    B

    A'

    B'

    Center of

    projection

    Projectors

    Projection

    plane

    Perspective projection

    A

    BA'

    B'

    Center of

    projection

    at infinity

    Projectors

    Projection

    plane

    Direction

    of

    projection

    Parallel projection

  • 7/27/2019 Projection-Computer Graphics

    7/60

    Perspective v Parallel

    Perspective: visual effect is similar to human

    visual system...

    has 'perspective foreshortening'

    size of object varies inversely withdistance from the center of

    projection.

    Parallel lines do not in general

    project to parallel lines

    angles only remain intact for

    faces parallel to projection plane.

  • 7/27/2019 Projection-Computer Graphics

    8/60

    Parallel: less realistic view because of no

    foreshortening

    however, parallel lines remain

    parallel. angles only remain intact for faces

    parallel to projection plane.

    Perspective v Parallel

  • 7/27/2019 Projection-Computer Graphics

    9/60

    Perspective projection- anomalies

    Perspective foreshorteningThe farther an object isfrom COP the smaller it appears

    A

    BA'

    B'

    Center of

    projection

    Projectors

    Projection

    plane

    C

    D

    C'

    D'

    Perspective foreshortening

  • 7/27/2019 Projection-Computer Graphics

    10/60

    Vanishing Points:Any set of parallel lines not parallel to the viewplane appear to meet at some point.

    There are an infinite number of these, 1 for each of the infinite

    amount of directions line can be oriented

    x

    y

    z

    z-axis vanishing point

    Vanishing point

    Perspective projection- anomalies

  • 7/27/2019 Projection-Computer Graphics

    11/60

    Perspective projection- anomalies

    View Confusion :Objects behind the center of projection areprojected upside down and backward onto the view-plane

    Topologica l distor t ion:A line segment joining a point which lies in

    front of the viewer to a point in back of the viewer is projected to a

    broken line of infinite extent.

    P1

    P3

    P'3

    C

    Y

    X

    Z

    P2

    P'1P'2

    View Plane

    Plane containing

    Center of Projection (C)

  • 7/27/2019 Projection-Computer Graphics

    12/60

    Vanishing Point

    Vanishing Point

    COP

    View Plane

  • 7/27/2019 Projection-Computer Graphics

    13/60

    Vanishing Point

    If a set of lines are parallel to one of the three axes, the vanishing point is called an axis vanishing

    point (Principal Vanishing Point).

    There are at most 3 such points, corresponding to the number of axes cut by the projection

    plane

    One-point:

    One principle axis cut by projection plane

    One axis vanishing point

    Two-point:

    Two principle axes cut by projection plane

    Two axis vanishing points

    Three-point:

    Three principle axes cut by projection plane

    Three axis vanishing points

  • 7/27/2019 Projection-Computer Graphics

    14/60

  • 7/27/2019 Projection-Computer Graphics

    15/60

    One point perspective projection of a cube X and Y parallel lines do not converge

    Vanishing Point

  • 7/27/2019 Projection-Computer Graphics

    16/60

    Vanishing Point

  • 7/27/2019 Projection-Computer Graphics

    17/60

    Two-point perspective

    projection:

    This is often used inarchitectural, engineering and

    industrial design drawings.

    Three-point is used less

    frequently as it adds little extrarealism to that offered by two-

    point perspective projection.

    Vanishing Point

  • 7/27/2019 Projection-Computer Graphics

    18/60

    Vanishing Point

    VPL VPRH

    VP1 VP2

    VP3

  • 7/27/2019 Projection-Computer Graphics

    19/60

    Projective Transformation

    y

    x

    z

    view direction

    center of

    projection

    plane of

    projection

    d

    Settings for perspective projection

  • 7/27/2019 Projection-Computer Graphics

    20/60

    y

    P(y,z)y

    z

    P'(yp,z

    p)

    d-z

    plane ofprojection

    1,,,1,,, ddz

    y

    dz

    xzyx

    dz

    dz

    yy

    d

    y

    z

    yp

    p

    Projective Transformation

  • 7/27/2019 Projection-Computer Graphics

    21/60

    1

    /

    /

    1????

    ????

    ????

    ????

    ddz

    ydz

    x

    z

    y

    x

    d

    zz

    y

    x

    z

    y

    x

    1????

    ????

    ????

    ????

    d

    zz

    yx

    z

    y

    x

    d10

    100

    0100

    0010

    0001

    1

    d

    dz

    ydz

    x

    d

    zz

    yx

    divisioneperspectiv

    Projective Transformation

  • 7/27/2019 Projection-Computer Graphics

    22/60

    Parallel projection

    2 principle types: orthographicand

    oblique.

    Orthographic : direction of projection =

    normal to the projectionplane.

    Oblique : direction of projection !=

    normal to the projectionplane.

    n

    n

  • 7/27/2019 Projection-Computer Graphics

    23/60

    Orthographic (or orthogonal) projections:

    front elevation, top-elevation and side-elevation.

    all have projection plane perpendicular to a principleaxes.

    Useful because angle and distance measurements canbe made...

    However, As only one face of an object is shown, it can

    be hard to create a mental image of the object, evenwhen several view are available

    Orthographic projection

  • 7/27/2019 Projection-Computer Graphics

    24/60

    Orthographic projection

  • 7/27/2019 Projection-Computer Graphics

    25/60

    Orthogonal Projection Matrix

    1

    0

    11000

    0000

    0010

    0001

    y

    x

    z

    y

    x

    y

    x

    zview direction

    plane of

    projection

    direction of

    projection

  • 7/27/2019 Projection-Computer Graphics

    26/60

    Axonometric projection

    Axonometr ic Project ionsuse projection planes that arenot normal to a principal axis.On the basis ofprojection

    planenormalN = (dx , dy, dz) subclasses are:

    o Isometr ic: | dx | =| dy | =| dz |i.e. Nmakes equal angles withall principal axes.

    o Dimetr ic: | dx | =| dy |

    o Trimetr ic:| dx | != | dy | != | dz |

  • 7/27/2019 Projection-Computer Graphics

    27/60

    Axonometric vs Perspective

    Axonometric projection shows several faces of an objectat once like perspective projection.

    But the foreshortening is uniform rather than being

    related to the distance from the COP.

    y

    z

    x

    Projection Plane

    Isometric proj

  • 7/27/2019 Projection-Computer Graphics

    28/60

    Oblique parallel projection

    Oblique parallel projections Objects can be visualized better then with

    orthographic projections

    Can measure distances, but not angles* Can only measure angles for faces of objectsparallel to the plane

    2 common oblique parallel projections:

    Cavalierand Cabinet

  • 7/27/2019 Projection-Computer Graphics

    29/60

    Oblique parallel projection

    n

    Projection Plane Normal

    Projector

    Projection Plane

    x

    y

    z

  • 7/27/2019 Projection-Computer Graphics

    30/60

    Cavalier:

    The direction of the projection makes a 45 degree

    angle with the projection plane.

    There is no foreshortening

    Oblique parallel projection

  • 7/27/2019 Projection-Computer Graphics

    31/60

    Oblique parallel projection

    Cabinet:

    The direction of the projection makes a 63.4 degree

    angle with the projection plane. This results in

    foreshortening of the z axis, and provides a more

    realistic view

  • 7/27/2019 Projection-Computer Graphics

    32/60

    Oblique parallel projection

    Cavalier, cabinet and orthogonal projectionscan all be specified in terms of(, )or(, )since

    tan() = 1/

    P=(0, 0, 1)

    P ( cos(), sin(),0)

    cos()

    sin()

  • 7/27/2019 Projection-Computer Graphics

    33/60

    Oblique parallel projection

    l=1 b = 45 Cavalier projection a = 0 - 360

    l=0.5 b = 63.4 Cabinet projection a = 0 360

    l=0 b = 90 Orthogonal projection a = 0 360

  • 7/27/2019 Projection-Computer Graphics

    34/60

    Oblique parallel projection

    PP = ( cos(), sin(),-1) = DOP

    Proj(P) = ( cos(), sin(),0)

    Generally

    multiply by z and allow for (non-zero) x and yx = x + z lcos a

    y = y + z lsin a

    1

    .

    1000

    0000

    0sin100cos01

    1

    0 z

    yx

    yx

    alal

    x

    y

    a),( yx

    l

    ),( pp yx

    al

    al

    sin

    cos

    yy

    xx

    p

    p

  • 7/27/2019 Projection-Computer Graphics

    35/60

    Generalized Projection Matrix

    x or y

    Center of Projection

    (COP)

    z

    P = (x, y, z)

    Pp

    = (xp, y

    p, z

    p)

    (dx, d

    y, d

    z)

    (0, 0, zp)

    Q

    Plane of Projection

    zyxp

    p

    dddQzCOP

    tCOPPtCOPP

    ,,,0,0

    10,

    zpzp

    yy

    xx

    QdzztQdzz

    QdytQdy

    QdxtQdx

    zyxP

    ,,

  • 7/27/2019 Projection-Computer Graphics

    36/60

    Generalized Projection Matrix

    zpzpp

    zpzpp

    QdzzQdzzt

    QdzztQdzz

    11

    1

    1

    1

    2

    z

    p

    z

    zpp

    z

    p

    z

    p

    z

    p

    pp

    z

    p

    z

    yp

    z

    y

    p

    z

    p

    z

    xp

    z

    x

    p

    Qd

    zz

    Qd

    Qdzz

    Qd

    zz

    Qd

    zz

    Qd

    zz

    zz

    Qd

    zz

    ddz

    ddzy

    y

    Qd

    zz

    ddz

    ddzx

    x

  • 7/27/2019 Projection-Computer Graphics

    37/60

    Generalized Projection Matrix

    11

    00

    00

    10

    01

    2

    z

    p

    z

    p

    z

    p

    z

    p

    z

    yp

    z

    y

    z

    xp

    z

    x

    gen

    Qd

    z

    Qd

    zQd

    z

    Qd

    z

    d

    dz

    d

    d

    d

    dz

    d

    d

    M

    1

    1

    1

    2

    z

    p

    p

    z

    p

    z

    p

    p

    z

    p

    z

    yp

    z

    y

    p

    z

    p

    z

    xp

    z

    x

    p

    Qd

    zz

    zQd

    z

    Qd

    zz

    z

    Qd

    zz

    d

    d

    zd

    d

    zyy

    Qd

    zz

    ddz

    ddzx

    x

  • 7/27/2019 Projection-Computer Graphics

    38/60

    Generalized Projection Matrix

    01

    00

    0100

    0010

    0001

    1,0,0,,

    d

    Mperddd

    dQdz

    zyx

    p

    11

    00

    00

    10

    01

    2

    z

    p

    z

    p

    z

    p

    z

    p

    z

    y

    p

    z

    y

    z

    xp

    z

    x

    gen

    Qd

    z

    Qd

    zQdz

    Qdz

    d

    dz

    d

    dddz

    dd

    M

  • 7/27/2019 Projection-Computer Graphics

    39/60

    Generalized Projection Matrix

    1000

    0000

    00100001

    1,0,0,,0

    par

    dddQz

    Mzyxp

    11

    00

    00

    10

    01

    2

    z

    p

    z

    p

    z

    p

    z

    p

    z

    y

    p

    z

    y

    z

    xp

    z

    x

    gen

    Qd

    z

    Qd

    zQdz

    Qdz

    d

    dz

    d

    dddz

    dd

    M

  • 7/27/2019 Projection-Computer Graphics

    40/60

    Taxonomy of Projection

  • 7/27/2019 Projection-Computer Graphics

    41/60

    OpenGLs Perspective Specification

    w

    h

    y

    x

    z

    near

    far

    aspect = w / h

    y field-of-view / fovyaspect ratio

    near and far clipping planesviewing frustum

    gluPerspective(fovy, aspect, near, far)

    glFrustum(left, right, bottom, top, near, far)

    P i i h D h

  • 7/27/2019 Projection-Computer Graphics

    42/60

    Perspective without Depth

    dzz

    yx

    z

    y

    x

    d 101

    00

    0100

    00100001

    1

    d

    dz

    y

    dz

    x

    d

    zz

    y

    x

    divisioneperspectiv

    The depth information is

    lost as the last two

    components are same But dept information of the

    projected points is essential

    for hidden surface removal

    and other purposes like

    blending, shading etc.

    P ti ith t D th

  • 7/27/2019 Projection-Computer Graphics

    43/60

    Perspective without Depth

    1

    101

    0000

    0010

    0001

    z

    zd dz

    y

    dz

    x

    d

    zz

    y

    x

    z

    y

    x

    d

    divisioneperspectiv

    bababa

    zddz ba

    For < 0, z is a monotonically increasing function of depth.

  • 7/27/2019 Projection-Computer Graphics

    44/60

    C i l Vi V l

  • 7/27/2019 Projection-Computer Graphics

    45/60

    Canonical View Volume

    There is a reversal of the z- coordinates, in the sense that before

    the transformation, points further from the viewer have smaller z-

    coordinates

    y

    z

    z=-far

    z=-near

    +1

    -1+1 -1

    y

    zviewer

    z=-1 (near)z=1 (far)

    P ti M t i

  • 7/27/2019 Projection-Computer Graphics

    46/60

    Perspective Matrix

    The matrix to performperspective transformation:

    1

    )/()(

    )/(

    )/(

    10100

    00

    000

    000

    zz

    zy

    zx

    z

    z

    y

    x

    z

    y

    x

    ba

    ba

    ba

    P ti M t i

  • 7/27/2019 Projection-Computer Graphics

    47/60

    Perspective Matrix

    w

    h/2

    y

    xz

    a = w / hz = -near

    z = -far

    zc

    z

    c

    azzyx

    c

    azyax

    y

    x

    h

    wa

    c

    zy

    y

    zc

    ,,,,

    2cot

    P ti M t i

  • 7/27/2019 Projection-Computer Graphics

    48/60

    Perspective Matrix

    1,1,1,,

    1,1,1,,

    1,1,1,,

    1,1,1,,

    nc

    n

    c

    an

    nc

    n

    c

    an

    nc

    n

    c

    an

    n

    c

    n

    c

    an

    1,1,1,,

    1,1,1,,

    1,1,1,,

    1,1,1,,

    fc

    f

    c

    af

    fc

    f

    c

    af

    fc

    f

    c

    af

    f

    c

    f

    c

    af

    w

    h/2

    y

    xz

    a = w / h z = -near

    z = -far

    P ti M t i

  • 7/27/2019 Projection-Computer Graphics

    49/60

    Perspective Matrix

    1

    1

    1

    1

    n

    nc

    nc

    an

    ba

    nn

    c

    a

    c

    ba

    11

    1

    1

    10100

    00

    000

    000

    1,1,1,,

    nc

    nc

    an

    ncn

    can

    ba

    11

    1

    1

    1n

    nc

    c

    a

    ba

    P ti M t i

  • 7/27/2019 Projection-Computer Graphics

    50/60

    Perspective Matrix

    11

    1

    1

    10100

    00

    000

    000

    1,1,1,,

    fc

    fc

    af

    fc

    f

    c

    af

    ba

    1

    1

    1

    1

    1

    f

    fc

    c

    a

    ba

    1

    1

    1

    1

    f

    fc

    fc

    af

    ba

    fn

    fn

    fn

    nf

    nn

    ff

    2b

    a

    ba

    ba

    P ti M t i

  • 7/27/2019 Projection-Computer Graphics

    51/60

    Perspective Matrix

    The matrix to performperspective transformation:

    0100

    2

    00

    000000

    fn

    fn

    fn

    nfc

    a

    c

    Ta onom of projection

  • 7/27/2019 Projection-Computer Graphics

    52/60

    Taxonomy of projection

    Generalized Projection

  • 7/27/2019 Projection-Computer Graphics

    53/60

    Generalized Projection

    Using the origin as the center of projection, derive the perspective

    transformation onto the plane passing through the point R0(x0, y0, z0)

    and having the normal vector N = n1I + n2J + n3K.

    x

    y

    z

    P(x, y, z)

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

    N = n1I + n2J + n3K

    R0=x0 ,y0, z0

    O

    Generalized Projection

  • 7/27/2019 Projection-Computer Graphics

    54/60

    Generalized Projection

    znynxn

    d

    321

    0

    a

    x

    y

    z

    P(x, y, z)

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

    N = n1I + n2J + n3K

    R0=x0 ,y0, z0

    O

    P'O = PO

    x' = x, y' = y, z ' = z

    N. R0P' = 0

    n1x ' + n2y ' + n3z '

    =n1x0 + n2y0 + n3z0 = d0

    0

    000

    000

    000

    321

    0

    0

    0

    nnn

    d

    d

    d

    Per

    Generalized Projection

  • 7/27/2019 Projection-Computer Graphics

    55/60

    Generalized Projection

    Derive the general perspective transformation onto a plane with reference

    point R0 and normal vector N and using C(a,b,c) as the center of projection.

    x

    y

    z

    P(x, y, z)

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

    N = n1I + n2J + n3K

    R0=x0 ,y0, z0

    C

    Generalized Projection

  • 7/27/2019 Projection-Computer Graphics

    56/60

    Generalized Projection

    )()()( 321 cznbynaxnd

    a

    P'C = PCx' = (x-a) + a

    n1x' + n2y' + n3z = d0

    d = (n1x0 + n2y0 + n3z0) (n1a + n2b + n3c)

    = d0 d

    1

    x

    y

    z

    P(x, y,

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

    N = n1I + n2J + n3K

    R0=x0 ,y0, z0

    C

    Generalized Projection

  • 7/27/2019 Projection-Computer Graphics

    57/60

    Generalized Projection

    Follow the steps Translate so that C lies at the origin

    Per

    Translate back

    1321

    0321

    0321

    0321

    dnnn

    cdcndcncn

    bdbnbndbn

    adananand

    Generalized Projection

  • 7/27/2019 Projection-Computer Graphics

    58/60

    Generalized Projection

    Find (a) the vanishing points for a given perspectivetransformation in the direction given by a vector U (b)principal vanishing point.

    Family of parallel lines having the direction U(u1,u2,u3)

    can be written in parametric form as x = u1t+p, y = u2t+q, z = u3t+r

    here (p, q, r) is any point on the line

    Let, proj(x,y,z,1) = (x, y, z, h) x'= (d+an1)(u1t+p) + an2(u2t+q) + an3(u3t+r) ad0 y' = bn1(u1t+p) + (d+bn2)(u2t+q) + bn3(u3t+r) bd0 z' = cn1(u1t+p) + cn2(u2t+q) + (d+cn3)(u3t+r) cd0 h = n1(u1t+p) + n2(u2t+q) + n3(u3t+r) d1

    Generalized Projection

  • 7/27/2019 Projection-Computer Graphics

    59/60

    Generalized Projection

    The vanishing point (xv,y

    v, z

    v) is obtained when t=

    xu = (x/h) at t=

    = a + (du1/k)

    yu = b + (du2/k)

    zu = c + (du3/k)

    k = N.U = n1u1 + n2u2 + n3u3

    If k=0 then ?

    Principal vanishing point when

    U = I xu = a + d / n1, yu = b, zu = c,

    U = J

    U = k

    Ref

  • 7/27/2019 Projection-Computer Graphics

    60/60

    Ref.

    FV: p. 229-237, 253-258

    Sch: prob. 7.1 7.15

    Perspective Proj.pdf