In this demonstration, the vehicles use containment (or generalized obstacle avoidance) to stay off the areas marked in gray. This behavior is related to obstacle avoidance of "chunk-like" obstacles (which can be approximated by their bounding spheres). However this behavior can deal with arbitrary shapes and allows the vehicle to navigate close to the obstacle's surface, and specifically the case where the vehicle is contained within the surface, as shown here.
The vehicles test the space ahead of them with probe points, indicated by white lines. (In this demonstration, when none of the probes touch an obstacle, the vehicle will wander to keep it from aligning with the "lanes".) When a probe point touches an obstacle, it is projected (indicated by a black line) to the nearest point on the surface of the obstacle (red dot) and the normal to the surface at that point is determined (red line). Steering is determined by taking the component of this surface normal which is perpendicular to the vehicle's forward direction. The vehicle's velocity is indicated by a magenta vector, and its steering force is indicated by a blue vector.
The two vehicle use different strategies for determining probe points. The green vehicle uses a fixed set of three probes (one directly ahead, and two slightly ahead and to either side). The cyan vehicle uses a single point whose position is randomly distributed along an elliptical arc. Note that the green vehicle more dependably avoids the obstacles, but must typically do three times as much work per simulation step. In a convex enclosure, a single fixed probe point is sufficient, otherwise (as here) more points are required for good results. The two vehicles are unaware of each other.
Communication between vehicles and obstacle is handled by a generic surface protocol: the vehicle asks the obstacle if a given probe point is inside the surface, and if so asks for the nearest point on the surface and the normal at that point. As a result, the steering behavior needs no knowledge of the surface's shape.