3D geometries have vertex Z ordinates defined. 3D Polygons are assumed to lie in a single plane (which is enforced if not actually the case). 3D LineStrings and Points may have any configuration.
The distance computation also finds a pair of points in the input geometries which have the minimum distance between them. If a point lies in the interior of a line segment, the coordinate computed is a close approximation to the exact point for X and Y ordinates. Z ordinate is not interpolated.
The algorithms used are straightforward O(n^2) comparisons. This worst-case performance could be improved on by using Voronoi techniques or spatial indexes.