Two Dimensional Viewing |
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
Procedure:
e.g.
could set up view-up vector
can
compute component of u = (ux, uy)
& v = (vx,vy)
i.
translate
viewing origin to world origin
ii.
rotate
to align two coordiate reference frame
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 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:
·
Clipping
operations eliminate everything outside window
·
Two
Approaches:
·
Raster
systems -> clipping part of scan conversion
Rectangular clipping window…
Point P(x,y) saved for display IF
Ywl
<= y <= Ywh
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
·
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
·
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
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
§
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
|
Perspective
Wireframe => Surface Rendering => Light, Texture, etc.
3D Viewing
|
Coordinate
positions transformed to viewplane with parallel
lines
Coordinate
positions transformed to viewplane with converging
lines
Orthographic
Projection:
xp = x
yp = y
Oblique Projection
…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 |
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 |
|
|||||
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 |
|
43 |
53.0 |
Moderate Wide Angle |
24 |
84.0 |
Wide Angle |
18 |
94.0 |
a –
parallelepiped b
– frustum
Window dimensions specify
field of view