Distance between a point and a 3D figure

159 Views Asked by At

If I have some basic 3D shapes like rectangular prisms, cylinders and spheres (whose positions, orientations and dimensions are fully known), what is the simplest way of finding the shortest distance from any given point (x,y,z) to each of these shapes? Spheres are easy since orientation is irrelevant and it just involves finding the Euclidean distance between the point and the centre of the sphere, but what about cylinders and rectangular prisms in arbitrary orientations (as defined by roll, pitch, yaw angles)? I'd also like to know if the point is inside or outside the given shape.