Steering Behaviors - Obstacle Avoidance

In addition to .heading(), PVector has .dot() and .angleBetween(). If you have the centers of the two shapes and the tangent point then you could get the angleBetween of those two vectors to get the turning angle.

Interesting.

  • If the vehicle angle to the obstacle is 90-270 degrees then it is always good, no turning needed.
  • If the angle is exactly 0 it is always bad, and the vehicle could turn left or right arbitrarily.
  • Anything in-between 0-90 (or 270-0) will be bad IF the angle is less than the tangent line to the circle:

…but that tangent is constantly changing as the vehicle approaches, so then questions like how big / close / fast could come into play.

Is the goal to have different turning speeds for different situations, or are the number of degrees turned per frame fixed (i.e. keep turning away at a constant angular momentum until you are clear or crash)?


For a related past discussion about shadows, see: Simulating shadow - Processing 2.x and 3.x Forum

2 Likes