I have to create paths for tubes, pipes and conduits connecting two points in an automated way.
For example, I want to create a path for a tube between the two red endpoints in this screenshot (yes, it's a loo):
The path between these two points must satisfy some constraints, among which:
1. The distance between the path and any other object in any direction must be greater than a certain threshold
2. The path should not be unnecessarily long or be "too winding"
3. It will probably have to allow the incorporation of a "minimum radius of curvature".
I can think of two ways to approach this problem (but there are probably also other approaches):
Method A. Move an object from the start point to the end point using some kind of object avoidance, like raycasting
Method B. Use some sort of the least expensive path analysis. This would likely involve discretizing 3D space into quadrants and assigning a cost to each quadrant based on its distance from other objects.
Currently, I have implemented a version of Method A, as you can see in the gif below:
While this solution produces something usable, I'm not sure it's the best approach. At least in my implementation, the minimum distance to other objects is not guaranteed, because the object may, for example (not illustrated in this example) follow a path in a hole and not find any exit.
What other approaches are there? For example, is there a specific approach to method B mentioned above? How could we discretize space into separate quadrants?