ABSTRACT

In all but the last section of this chapter, I present a few algorithms for computingdistances between points, linear components (lines, rays, segments), triangles, rectangles, and boxes. Linear components are parameterized by P + tD, where D is a unit-length vector. The parameter is constrained to t ∈ (−∞, ∞) for a line, to t ∈ [0, ∞) for a ray, and to t ∈ [−e, e] for a segment. The algorithms are set up to compute squared distance to avoid a potentially expensive square root function call, but if the cost is not of concern to you, your implementation can very well compute distance itself.