36
Projections and clipping in 3D

projections - engineering drawing

Embed Size (px)

DESCRIPTION

engineering drawing ......

Citation preview

Page 1: projections - engineering drawing

Projections and clipping in 3D

Page 2: projections - engineering drawing

Viewing and projection

Objects in WC are projected on to the view plane, which is defined perpendicular to the viewing direction along the zv-axis. The two main types of projection in Computer Graphics are:

• parallel projection

• perspective projection

Page 3: projections - engineering drawing

Projection illustrations

• Parallel projection– All projection lines are

crossing the view plane in parallel; preserve relative proportions

• Perspective projection– Projection lines are

crossing the view plane and converge in a projection reference point (PRP)

Page 4: projections - engineering drawing

Overview of projections

Page 5: projections - engineering drawing

Parallel projection

Two different types are used:

• Orthographic (axonometric,isometric)– most common– projection perpendicular to view plane

• Oblique (cabinet and cavalier)– projection not perpendicular to view plane– less common

Page 6: projections - engineering drawing

Orthographic projection

Assume view plane at zvp (perpendicular to the zv-axis) and (xv,yv,zv) an arbitrary point in VC

Then xp = xv

yp = yv

zp = zvp (zv is kept for depth purposes only)

Page 7: projections - engineering drawing

Oblique projection

When the projection path is not perpendicular to the view plane.

A vector direction is defining the projection lines

Can improve the view of an object

Page 8: projections - engineering drawing

Oblique projection, cont’d

An oblique parallel projection is often specified with two angles, (0-90°) och (0-360°), as shown below

Page 9: projections - engineering drawing

Oblique formula (from fig.)Assume (x,y,z) any point in VC (cp. xv,yv,zv)

cos =(xp-x)/L => xp=x+L.cos sin =(yp-y)/L => yp=y+L. sin Also tan =(zvp-z)/L, thus L=(zvp-z)/tan = =L1(zvp-z),

where L1=cot Hence

xp = x + L1(zvp - z).cos yp = y + L1(zvp - z).sin

Observe: if orthographic projection, then L1=0

Page 10: projections - engineering drawing

Cavalier and Cabinet

When

• tan = 1 then the projection is called Cavalier ( = 45°)

• tan = 2 then the projection is called Cabinet ( ≈ 63°)

usually takes the value 30° or 45°

Page 11: projections - engineering drawing

Cavalier, example

Page 12: projections - engineering drawing

Perspective projection

Page 13: projections - engineering drawing

A general approach xp = x.zprp − zvp

zprp − z + xprp.

zvp − zzprp − z

yp = y.zprp − zvp

zprp − z + yprp

. zvp − zzprp − z

Page 14: projections - engineering drawing

Special cases

Various restrictions are often used, such as:• PRP on the zv-axis (used in the next

approach) => xprp=yprp=0• PRP in the VC origin => xprp=yprp=zprp=0• view plane in the xvyv-plane => zvp=0• view plane in the xvyv-plane and PRP on the

zv-axis =>xprp=yprp=zvp=0

Page 15: projections - engineering drawing

Special case: PRP on the zv-axis

Similarity properties give:

xp

x =

zprp − zvp

zprp − z => xp = x. dp

zprp − z

yp

y =

zprp − zvp

zprp − z => yp = y. dp

zprp − z

Page 16: projections - engineering drawing

Window and clipping in 3D

Page 17: projections - engineering drawing

Window in 3D => View Volume

A rectangular window on the view plane corresponds to a view volume of type:

• infinite parallelepiped (parallel projection)

• ”half-infinite” pyramid with apex at PRP (perspective projection)

Page 18: projections - engineering drawing

View volumes

Page 19: projections - engineering drawing

Finite view volumes

To get a finite volume (one or) two extra zv-boundary planes, parallel to the view plane, are added: the front (near) plane and the back (far) plane resulting in:

• a rectangular parallelepiped (parallel projection)

• a pyramidal frustum (perspective projection)

Page 20: projections - engineering drawing

Finite view volumes

Page 21: projections - engineering drawing

”Camera” propertiesThe two new planes are mainly used as far and

near clipping planes to eliminate objects close to and far from PRP (cp. the camera)

Other camera similarities:• PRP close to the view plane => ”wide angle”

lens• PRP far from the view plane => ”tele photo” lensMatrix representations for both parallel and per-

spective projections are possible (see text book)

Page 22: projections - engineering drawing

3D Clipping

A 3D algorithm for clipping identifies and saves those surface parts that are within the view volume

Extended 2D algorithms are well suited also in 3D; instead of clipping against straight boundary edges, clipping in 3D is against boundary planes, i.e. testing lines/surfaces against plane equations

Page 23: projections - engineering drawing

Clipping planes

Testing a point against the front and back clipping planes are easy; only the z-coordinate has to be checked

Testing against the other view volume sides are more complex when perspective projection (pyramid), but still easy when parallel projection, since the clipping sides are then parallel to the x- and y-axes

Page 24: projections - engineering drawing

Clipping when perspective projection

Before clipping, convert the view volume, a pyramidal frustum, to a rectangular parallelepiped (see next figure)

Clipping can then be performed as in the case of parallel projection, which means much less processing

From now on, all view volumes are assumed to be rectangular parallelepipeds (either including the special transformation or not)

Page 25: projections - engineering drawing

The perspective transformation

The perspective transformation will transform the object A to A’ so that the parallel projection of A’ will be identical to the perspective projection of A

Page 26: projections - engineering drawing

Normalized coordinates

A possible (and usual!) further transformation is to a unit cube; a normalized coordinate system (NC) is then introduced, with either 0≤x,y,z≤1 or -1≤x,y,z≤1

Since screen coordinates are often specified in a left-handed reference system, also normalized coordinates are often specified in a left-handed system, which means, for instance, viewing in the positive z-direction

Page 27: projections - engineering drawing

Left-handed screen coordinates

Page 28: projections - engineering drawing

Parallel projection view volume to normalized view volume

Page 29: projections - engineering drawing

Perspective projection view volume to normalized view volume

Page 30: projections - engineering drawing

Advantages with the parallelepiped/unit cube

• all view volumes have a standard shape and corresponds to common output devices

• simplified and standardized clipping

• depth determinations are simplified when it comes to Visible Surface Detection

Page 31: projections - engineering drawing

Clipping in more detail

Both the 2D algorithms, Cohen-Sutherland’s for line clipping and Sutherland-Hodgeman’s for polygon clipping, can easily be modified to 3D clipping.

One of the main differences is that clipping has to be performed against boundary planes instead of boundary edges

Another is that clipping in 3D generally needs to be done in homogeneous coordinates

Page 32: projections - engineering drawing

Clipping details,cont’d

With matrix representation of the viewing and projection transformations, the matrix M below represent the concatenation of all various transformations from world coordinates to normalized, homogeneous projection coordinates with h taking any real value!

⎜⎜⎜⎜

xh

yh

zh

h ⎠

⎟⎟⎟⎟ = M.

⎜⎜⎜⎜

xyz1 ⎠

⎟⎟⎟⎟

Page 33: projections - engineering drawing

Line clipping

Page 34: projections - engineering drawing

Polygon clipping

Graphics packages typically deal only with objects made up by polygons

Clipping an object is then broken down in clipping polygon surfaces

First, some bounding surface is testedThen, vertex lists as in 2D but now processed by

6 clippers!Additional surfaces need to ”close” cut objects

along the view volume boundaryConcave objects are often split

Page 35: projections - engineering drawing

Example, object clipping

Page 36: projections - engineering drawing

Viewing pipeline

After the clipping routines have been applied to the normalized view volume, the remaining tasks are:

• Visibility determination

• Surface rendering

• Transformation to the viewport (device)