How can I calculate the minimum distance between a point on the perimeter of a disk in 3d space and a point above the disk?
For example, there is a disk in 3d space with center [0,0,0]. It has radius 3 and lies flat on the x,y plane. If there is a particle above the disk at [5,5,5], how do I calculate the minimum distance from this particle to a point on the perimeter of the disk?
Here is my attempt so far:
vec1 = vector between disk center and particle vec1 = [(5 - 0), (5 - 0), (5 - 0)] vec1 = [5,5,5] unitvec1 = unit vector in direction of vec1 unitvec1 = vec1/norm(vec1) unitvec1 = [0.5774, 0.5774, 0.5774] vec2 = vector between disk center and point on the perimeter closest to the particle vec2 = disk radius * unitvec1, and make z element = 0 vec2 = 3 * [0.5774, 0.5774, 0] vec2 = [1.7321, 1.7321, 0] vec3 = vector between particle and point on the perimeter closest to the particle vec3 = vec1 - vec2 vec3 = [3.2679, 3.2679, 5.0000] So the min distance is norm(vec3) = 6.8087
But this method doesn't always work. If I try it with disk center [0,0,0], particle location [0,0,6], and disk radius 9, it gives the minimum distance to be 6. this can't be correct, because the distance between the center of the disk and the particle will be 6, so the distance to the perimeter must be larger.
What am I doing wrong, and how should I actually calculate this?
note: I am using pseudo code, not an actual programing language