What is the fastest way to calculate the minimum distance in python?

283 Views Asked by At

I am writing a code about handling geometry.

With some equations, surfaces are defined and if surfaces surround the space, then they form a cell.

Surface could be any shape, but it's usually plane, cylinder, sphere, cone or torus.

In a cell, a point moves toward any directions. In this situation, I want to know the minimum distance toward given direction from the point.

What I'm doing now is to check the cell where a point belongs and calculate the all minimum distances toward the surfaces which make up the cell(since cell is decided, I can figure out which surfaces it has) and choose the minimum one.

It's not a big problem when I am having only plane, cylinder or sphere surfaces since it's easy to calculate the distance. However, when the surfaces are made up of cone, torus, or more complicated geometry, then it becomes really hard to calculate the distance to that surface.

Is there any easy method to implement?