|
|
Given a rectangle X = B + s * E0 + t * E1 and a point P we determine the projection P' of P onto the plane of the rectangle P' = B + s * E0 + t * E1 with s = (P - B) * E0 / E0^2 t = (P - B) * E1 / E1^2 Determining the correct region and closest point is a simple matter of analysing s and t. If both s and t are in [0, 1] then the closest point to P lies inside the recangle and the distance is |P - B - s * E0 - t * E0| with s and t as above. If one of the two, either s or t, are in [0, 1] and the other one is either < 0 or > 1, then the closest point to P is the projection of P to the corresponding edge of the rectangle. For example, for s < 0 and t in [0, 1] we would get as distance |P - B - t * E0|, again with t as above. If both s and t are outside the interval [0, 1] then the corresponding corner point of the rectangle is the closest point.
|
Copyright © by Martin Ecker |