**3D clipping:-**

The window, which served as clipping boundary in two-dimensional space In three dimensional space the concept can be extended to a clipping volume or view volume. The two common three dimensional clipping volume are a rectangular parallelepiped, i.e. a box, used for parallel or axonometric projection, and a truncated pyramidal volume used for perspective projections. Fig.(27) shows these volumes. These **volumes are six sided with sides**: **left, right, top, bottom, hither (near), and yon (far).**

The two-dimensional concept of region codes can be extended to three dimensions by considering six sides and 6-bit code instead of four sides and 4-bit code. Like two-dimension, we assign the bit positions in the region code from right to left as

**Bit 1 = 1**, if the end point is to the left of the volume.

**Bit 2 = 1**, if the end point is to the right of the volume.

**Bit 3 = 1**, if the end point is the below the volume.

**Bit 4 = 1**, if the end point is above the volume.

**Bit 5 = 1**, if the end point is in front of the volume.

**Bit 6 = 1**, if the end Point is behind the volume.

Otherwise, the bit is set to zero. As an example, a region code of 101000 identifies a point as above and behind the view volume, and the region code 000000 indicates a point within the view volume.

A line segment can be immediately identified as completely within the view volume if both endpoints have a region code of 000000. If either endpoint of a line segment does not have a region code of 000000, we perform the logical AND operation on the two endpoint codes. If the result of this AND operation is nonzero then both endpoints are outside the view volume and line segment is completely invisible, On the other hand. if the result of AND operation is zero then line segment may be partially visible. In this case, it is necessary to determine this intersection of the line and the clipping volume.

We have seen that determining the end point codes for a rectangular parallelepiped clipping volume is a straight forward extension of the two dimensional algorithm.

However the perspective clipping volume shown in Fig. 28(b) requires some additional processing. A shown in the Fig. 28(a), the line connecting the center of projection and the center of the perspective clipping volume coincides with the z-axis in a right handed co-ordinate system.

Fig. (28) shows a top view of the perspective clipping volume. The equation of the line which represents the right hand plane in this view can be given as

This equation of right hand plane can be used to determine whether a point is to the right, on or to the left of the plane i.e., outside the volume, on the right hand plane, or inside the volume. Substituting the x and y coordinates of a point P into x – z α1 – α2 gives the following results.

```
fR = x – z α1 – α2 > 0 if P is to the right of the right plane.
= 0 if P is on the right plane.
< 0 if P is to the left of the right plane.
```

Similarly, we can derive. the test functions for left, top, bottom. hither and yon planes. Table 1. show the test functions.