Next: Visibility of Another Fish Up: Visibility of a Point Previous: Visibility of a Point

### Occlusion Test

Fishes are generally vigorous animals that move around constantly. If at some instant the sight of one fish is blocked by another fish passing by, the occlusion will most likely be cleared soon after--since both fish are in motion. The temporary blocking of sight should not result in abrupt changes in a fish's behavior. Therefore, occlusion tests against another fish tend to be unessential. To increase computational efficiency, the artificial fish performs occlusion tests only against large static environmental objects. In the current implementation, this includes cylindrical objects. Note that, for obstacles with more complex geometric shapes, cylinders can serve as their bounding boxes.

The algorithm for testing the intersection of a ray with a cylinder is simple, especially since the axis of each cylinder is parallel to the z-axis of the world coordinate system (see Fig. ). Let the coordinates of O and P in the world coordinate system be denoted by and , respectively. Then line can be represented by the parametric equation

where , , and . Let r denote the radius and h the height of the cylinder C under consideration. Its projection onto the XY-plane is a circle A which can be represented by the parametric equation

where (a,b,0) denotes the center of A. The occlusion-test algorithm we develop can be outlined as follows (all calculations are performed in the world coordinate system):

1. Check if line intersects with circle A:

Substitute the x and y in Eq. () with those in Eq. () and solve for t. If the solutions and ( ) have real values and at least one of them is in [0,1], then do step 2; Otherwise, stop (P is not occluded by cylinder C).

2. Further check if line intersects with cylinder C:

Substitute the t in Eq. () with and to get the points of intersection. In fact, one only needs to calculate , i=1,2. If for i=1 or i=2, then point P is occluded. Otherwise, P is visible.

This algorithm is essentially an `extent testing' algorithm commonly used in determining visibility of objects in a scene [Foley et al.1990].

Next: Visibility of Another Fish Up: Visibility of a Point Previous: Visibility of a Point
 Xiaoyuan Tu January 1996