# Path for a tube between two points including constraints

I need to create paths for tubes, pipes, and ducts connecting two points in an automated fashion.

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 needs to satisfy a couple of constraints, among which are:

1. The distance between the path and any other objects in any direction must be above a certain threshold

2. The path should not be unnecessarily long or be "too curvy"

3. It will probably need to allow for the incorporation of a "minimum bend radius".

I can think of two ways to approach this problem (but there are probably other approaches as well):

Method A. Move an object from the start point to the end point using some sort of object avoidance, such as raycasting

Method B. Use some kind of least-cost-path analysis. This would probably involve discretizing 3-D space into quadrants, and assigining a cost to each quadrant based on its distance to other objects.

Currently, I have implemented a version of method A, as you can see in below gif:

While this solution does produce something usable, I am not sure it is the best approach. At least in my implementation, minimum distance to other objects is not guaranteed, as the object can, for example (not pictured in this example) follow a path into a hole and not find a way out.

What other approaches are there? For example, is there a specific approach to Method B mentioned above? How would one discretize space into seperate quadrants?

• It would probably be useful to try and formalize your constraints. If you have a space of admissible functions, it will help you better understand the problem, and you could perhaps apply some general minimization algorithms on the parameters of the space or even perhaps techniques of variational calculus. – BadZen Feb 11 at 15:45