lxfschr/Quelea

Implement Wander Force

Closed this issue · 0 comments

image

Figure 8: wander
Wander is a type of random steering. One easy implementation would be to generate a random steering force each frame, but this produces rather uninteresting motion. It is “twitchy” and produces no sustained turns. A more interesting approach is to retain steering direction state and make small random displacements to it each frame. Thus at one frame the character may be turning up and to the right, and on the next frame will still be turning in almost the same direction. The steering force takes a “random walk” from one direction to another. This idea can be implemented several ways, but one that has produced good results is to constrain the steering force to the surface of a sphere located slightly ahead of the character. To produce the steering force for the next frame: a random displacement is added to the previous value, and the sum is constrained again to the sphere’s surface. The sphere’s radius (the large circle in Figure 8) determines the maximum wandering “strength” and the magnitude of the random displacement (the small circle in Figure 8) determines the wander “rate.” Another way to implement wander would be to use coherent Perlin noise [Perlin 85] to generate the steering direction.
Related to wander is explore (where the goal is to exhaustively cover a region of space) and forage (combining wandering with resource seeking). See [Beer 90] and [Tu 96] for more details.

From http://www.red3d.com/cwr/steer/gdc99/

Wander steering behavior
In this demonstration, the green vehicle wanders through its world, wrapping around the window boundaries. Wandering is a type of random steering which has some long term order: the steering direction on one frame is related to the steering direction on the next frame. This produces more interesting motion than, for example, simply generating a random steering direction each frame.
This steering behavior maintains state, the "wander direction" which is represented here as a red dot. At each time step a random offset is added to the wander direction. The modified wander direction is constrained to lie on the black circle. (For 3d steering the circles are replaced by spheres.) The black circle has unit radius and its center is located sqrt(2) units along the vehicle's forward axis, it is shown enlarged in this diagram. This model of wandering is parameterized in terms of:
• strength ranging from 0 (no turning) to 1 (shown here) which can be thought of as moving the red dot out along the white line.
• rate which controls how fast the "wander direction" changes, ranging from 0 (no change) to 1 (fast erratic change) represented here as the radius of the white circle (shown at 0.6) indicating the maximum random offset.
The steering direction is represented by a cyan vector. The vehicle's velocity is indicated by a magenta vector, and its steering force is indicated by a blue vector.

From http://www.red3d.com/cwr/steer/Wander.html