|
|
Given an axis-aligned box with center C and extents E = (e0, e1, e2) along each axis. Let the point be written as P = C + s0*(1, 0, 0) + s1*(0, 1, 0) + s2*(0, 0, 1). Solving for the coefficients s = (s0, s1, s2) yields s = P - C. Depending on the values of s relative to the parameter space [-e0/2, e0/2] x [-e1/2, e1/2] x [-e2/2, e2/2] the closest point is either P itself, or a face point, an edge point or a vertex of the box. To determine that point, for each pair of parallel faces of the box, it must be determined which of the two faces is closest to P.
|
Copyright © by Martin Ecker |