One approach may be to use a rope or several ropes, where the rope consists of several points connected linearly. You can initialize points at random places in space, but the first point is the starting position of A , and the last point is the ending position of A.
Initially, the rope will be a very bad route. To optimize, move the dots along the energy gradient. In your case, the energy function is very simple, i.e. The total length of the rope.
This is not a new idea, but is used in computer vision to detect the boundaries of objects, although the energy functions are much more complicated. However, take a look at the “snake” to give you an idea of how to move each point, given its two neighbors: http://en.wikipedia.org/wiki/Snake_(computer_vision )
In your case, however, a simple indication of the direction for each point from the force exerted by its neighbors will be very good.
Your problem is a limited problem when you consider a collision. I would really go with the @paddy idea here to use a convex hull or even just a scope for each object. In the latter case, do not move the point to a place where its distance to B is less than the radius A plus radius B plus the fudge factor, given that you do not have an infinite number of points.
An acceptable solution requires that the largest distance between any neighbors be less than the threshold, otherwise the connecting line between the two points will intersect with the obstacle.
s.bandara
source share