Two Dimensional Viewing

Viewing Pipeline

 

Window – world coordinate area for display

Viewport – area on display device to which window is mapped

 

Window – what is viewed

Viewport – where it is displayed

 

Viewing Transformations – mapping part of a world coordinate scene to device coordinates

aka – Window-Viewport Mapping

 

2D Viewing-Transformation Pipeline

Viewing Coordinate Reference Frame

Procedure:

  1. Set up viewing-coordinate origin at some world position Po(xo,yo)
  2. Set up orientation of reference frame

e.g. could set up view-up vector

can compute component of u = (ux, uy) & v = (vx,vy)

  1. obtain matrix for converting world coordinates to viewing coordinates

                                                              i.      translate viewing origin to world origin

                                                            ii.      rotate to align two coordiate reference frame

 

Window-to-Viewport Coordinate Transformation

  • Device transformations using:
    • Xwl, Xwh, Ywl, Ywh
    • Xvl, Xvh, Yvl, Yvh

 

  • Use Transformation:

1.      Set up windowvl

2.      Translate window

3.      Scale to normalize

4.      Scale to viewport

5.      Translate to Viewport

 

 

 

 

 

 

 

 

What are the final formulas?

Xv = [(Xvh - Xvl)/(Xwh - Xwl)] (X - Xwl) + Xvl

Yv = [(Yvh - Yvl) / (Ywh - Ywl)] (Yw - Ywl) + Yvl

Window-Viewport Mapping

 

 

 

 

 

 

 

 

 

 

Xwh

Xwl

Ywh

Ywl

Xwh-Xwl

Ywh-Ywl

 

7.5

2.5

9

2.5

5

6.5

 

 

 

 

 

 

 

 

Xvh

Xvl

Yvh

Yvl

Xvh-Xvl

Yvh-Yvl

 

900

400

700

400

500

300

 

 

 

 

 

 

 

 

No.

x

y

X-Viewport

Y-Viewport

 

 

1

1.0

4.0

250.000

469.231

 

 

2

4.0

10.0

550.000

746.154

 

 

3

8.0

8.0

950.000

653.846

 

 

4

8.0

4.0

950.000

469.231

 

 

1

1.0

4.0

250.000

469.231

 

 

 

 

 

 

 

 

 

Window Coordinates

Viewport Coordinates

 

 

x

y

 

x

y

 

 

2.5

2.5

 

400

400

Window/Viewport

2.5

9

 

400

700

Outline

 

7.5

9

 

900

700

 

 

7.5

2.5

 

900

400

 

 

2.5

2.5

 

400

400

 

 

 

 

 

 

 

 

 

1.0

4.0

 

250

469

Data Points

4.0

10.0

 

550

746

 

 

8.0

8.0

 

950

654

 

 

8.0

4.0

 

950

469

 

 

1.0

4.0

 

250

469

 

 

 

          

Clipping Operations

Clipping Algorithms -> procedure that identifies portions of picture either inside or outside specified regions

 

Clip Window -> region against which an object is clipped

 

Applications of Clipping:

  • Extracting part of defined scene for viewing
  • Identifying visible surfaces in 3D Views
  • Anti-aliasing line segments or object boundaries
  • Creating objects using solid modelling procedures
  • Drawing and painting operations

 

·        Clipping operations eliminate everything outside window

·        Two Approaches:

  1. Clip word coordinates -> only contents of window interior mapped to device coordinates
  2. Map all world coordinates to device coordinates -> then clip against viewport boundaries

·        Raster systems -> clipping part of scan conversion

 

Point Clipping

Rectangular clipping window…

Point P(x,y) saved for display IF

Xwl <= x <= Xwh

Ywl <= y <= Ywh

Line Clipping

 

 

Line Clipping Procedure:

1.      Test line segment to determine if it resides completely inside clipping window

2.      Test to see if it is completely outside

3.      It we are unable to tell, perform intersection tests

 

Inside-Outside Test

·        Check both endpoints -> if both P1 and P2 are within boundaries – line is saved

·        If both endpoints outside – drop line segment

·        Remaining may require calculation of multiple intersections

Sutherland-Cohen Line Clipping

·        Every line endpoint is assigned a 4 bit Region code.

·        The bit is set depending on the location of the endpoint with respect to that window component as shown below:

Bit 1: Left of window

Bit 2: Right of window

Bit 3: Below window

Bit 4: Above window

 

Example:

P1 -> 0001, P 2 -> 1000

P3 -> 0001, P4 -> 0100

P5 -> 0000, P6 -> 0010

P7 -> 0001, P8 -> 0001

Determine the bit code by testing the endpoints with window as follows:

o       If x is less than Xwl then set bit 1

o       If x is greater than Xwh then set bit 2

o       If y is less than Ywl then set bit 3

o       If y is greater than Ywh then set bit 4

 

§         Possible Algorithm

o       Calculate difference between endpoint coordinates and clipping boundary

o       Use sign bit of difference to set region code

x – Xwl            bit 1

Xwh – x           bit 2

y – Ywl            bit 3

Ywh – y           bit 4

o       Determine Visibility

·        Any line whose endpoints have region codes of 0000 is visible

o       Any lines that have 1 at same bit position for each endpoint are outside

·        Use AND operation as test

1001

0101

0001

·        If result is not zero – line is completely outside

o       All other lines must be tested against boundaries -> one at a time

 

§         Procedure:

 

o       Begin with P1 and lower boundary and check against left, right, and bottom boundaries

o       Find intersection point P1’ with bottom boundary and replace P1 with P1’

o       Do same with P2 but we find two intersections p2’ and p2’’

o       P2’ is above window but P2’’ is on window boundary

 

 

Computing line intersections

§         Need to fined (x,y) position alone a line segment

§         We know …

y = mx + b

 

m = ( y2 – y1) / ( x2 – x1 )

 

b = y1 – m x1

so

y = m x + y1 – m x1

 

y  = y1 + m ( x – x1)

 

§         substitute for x  => Xwh or Xwl to calculate y coordinate of intersection

 

also

 

x = x1 + ( y – y1) / m

 

§         substitute for y  => Ywh or Ywl to calculate x coordinate of intersection

 

§         Example:

P1 : (1, 4 ) and P2 : ( 4, 10 )

Xwh

Xwl

Ywh

Ywl

7.5

2.5

9

2.5

Answer:

Intersection with Ywh == x = 3.5

Intersection with Xwl == y = 7

So…

P1’ = ( Xwl, 7) = ( 2.5, 7 )

P2’ = ( 3.5, Ywh ) = ( 3.5, 9 )

 

3D Display Methods

Synthetic Camera Model

  • Position and orientation
  • Angle of View
  • Depth of Field

 

 

 

 

 

Projection Methods

  • Parallel

 

Perspective

 

Depth Cueing

Visible Line and Surface Identification

 

 

 

Surface Rendering

Wireframe => Surface Rendering => Light, Texture, etc.

 

 

Exploded View

Cutaway View

3D and Stereoscopic Views

 

Rendering Pipeline

 

 

Transformation Pipeline

 

 

3D Viewing

Projections

  • Parallel Projection

Coordinate positions transformed to viewplane with parallel lines

  • Perspective Projection

Coordinate positions transformed to viewplane with converging lines

 

 

Parallel Projections

 

  • Orthographic Projection => used for front, side, back, top, bottom views

 

Transformation equations for parallel projection

Orthographic Projection:

xp = x

yp = y

 

Oblique Projection

 

 

 

 

Perspective Projections – general case

 

…where ( xprp, yprp, zprp ) is the perspective reference point

 

Begin with parametric equation for line…

xp = x - (x – xprp)u

yp = y - (y – yprp)u

zp = z - (z – zprp)u

u = 0 -> 1

 

 

solve for u where zvp = zp (viewplane)

 

 

 

substitute in xp, yp equations

 

 

 

 

 

multiplying through and rearranging…

 

 

 

 

 

 

Special Case -- zvp = zp = 0

 

 

 

 

 

Example: Special Case where zvp = zp = 0

 

 

Perspective Projection

 

Xprp

Yprp

Zprp

 

 

 

 

 

0.5

0.5

-1.5

 

 

 

 

 

 

 

 

Point

x

y

z

 

x'

y'

z'

1

0.30

0.30

0.30

 

0.33

0.33

0

2

0.30

0.70

0.30

 

0.34

0.67

0

3

0.30

0.30

0.70

 

0.36

0.36

0

4

0.30

0.70

0.70

 

0.37

0.64

0

5

0.70

0.70

0.70

 

0.64

0.64

0

6

0.70

0.30

0.70

 

0.64

0.36

0

7

0.70

0.70

0.30

 

0.67

0.67

0

8

0.70

0.30

0.30

 

0.67

0.33

0

 

 

Example Too:

Surface of Revolution

 

 

 

 

 

 

x1

y1

z1

 

x2

y2

z2

0

0.750

0.250

0.000

 

0.25

0.750

0.000

60

0.375

0.250

-0.650

 

0.125

0.750

-0.217

120

-0.375

0.250

-0.650

 

-0.125

0.750

-0.217

180

-0.750

0.250

0.000

 

-0.25

0.750

0.000

240

-0.375

0.250

0.650

 

-0.125

0.750

0.217

300

0.375

0.250

0.650

 

0.125

0.750

0.217

360

0.750

0.250

0.000

 

0.25

0.750

0.000

 

 

 

 

xc

yc

zc

Perspective Projection

0.1

3

-10

X1p

Y1p

 

 

X2p

Y2p

 

0.750

0.250

 

 

0.250

0.750

 

0.387

0.059

 

 

0.123

0.700

 

-0.415

0.059

 

 

-0.132

0.700

 

-0.750

0.250

 

 

-0.250

0.750

 

-0.340

0.418

 

 

-0.118

0.798

 

0.364

0.418

 

 

0.127

0.798

 

0.750

0.250

 

 

0.250

0.750

 

12.4 View Volumes and General Projections

  • View window or projection window used to set up telephoto or wide angle scene

 

 

Focal Lengths and Angles of View

35mm Camera

Focal Length(mm)

Angle of View (Degrees)

Extreme Telephoto

800 

3.5

 

400

6.0

 

200

12.5

Moderate Telephoto

135

18.0

 

85 

29.0

 

50 

46.0

Normal 

43 

53.0

Moderate Wide Angle

24 

84.0

Wide Angle

18

94.0

 

Viewing

  • Edges of window parallel to x.y axes

a – parallelepiped                                                     b – frustum

 

 

Symmetric Perspective-Projection Frustum

 

 

 

 

 

 

 

Window dimensions specify field of view

 

 

 

 

 

 

 

  • Second equation used by graphics libraries (eg OpenGL)
  • These formulas are substituted into the perspective projection formulas above.
  • The perspective equations map the symmetric frustum into a parallelepiped view volume

 

 

 

 

Normalized Perspective Projection View Coordfinates

 

 

 

 

 

 

 

Three Dimensional Clipping

 

3D Clipping Planes for Symmetric Cube :