Sample Applications: Distance

DistanceAlignedBoxes: Robust computation of distance between aligned boxes in any dimension.
DistanceAlignedBoxOrientedBox: Robust computation of distance between an aligned box and an oriented box in dimension 3.
DistanceLine2Box2: Compute distance between a 2D box and a line, ray or segment.
DistanceOrientedBoxConeFrustum: Robust computation of distance between an oriented box and a cone frustum in dimension 3.
DistanceOrientedBoxes: Robust computation of distance between oriented boxes in dimension 3.
DistancePointConvexPolyhedron: Robust computation of distance between a point and a convex polyhedron in dimension 3.
DistancePointHyperellipsoid: Robust computation of distance between a point and an ellipse (2D) or ellipsoid (3D) or hyperellipsoid (any dimension).
DistanceRectangleBox: Robust computation of distance between a rectangle and an aligned or oriented box in dimension 3.
DistanceSegments3: Robust computation of distance between line segments in any dimension (CPU and GPU).
DistanceTriangleBox: Robust computation of distance between a triangle and an aligned or oriented box in dimension 3.

DistanceAlignedBoxes. Robust computation of distance between aligned boxes in any dimension. The algorithm is based on convex quadratic programming (CQP) and a formulation as a linear complementarity problem (LCP). Various configurations are shown next.

DistanceAlignedBoxes0 DistanceAlignedBoxes1 DistanceAlignedBoxes2

DistanceAlignedBoxOrientedBox. Robust computation of distance between an aligned box and an oriented box in dimension 3. The algorithm is based on convex quadratic programming (CQP) and a formulation as a linear complementarity problem (LCP). Various configurations are shown next.

DistanceAlignedBoxOrientedBox0 DistanceAlignedBoxOrientedBox1 DistanceAlignedBoxOrientedBox2

DistanceLine2Box2. Compute distance between a 2D box and a line, ray or segment. The default query is for line-box. You have to modify preprocessor definitions in the header file in order to compute ray-box or segment-box distances. Various configurations are shown next. You can rotate the line using 'r' or 'R' key. You can translate the line using 'x', 'X', 'y' or 'Y' keys. The closest box point is drawn in green. The closest line point is drawn in red. If the closest points are the same, green is drawn.

DistanceLine2Box2_0 DistanceLine2Box2_1 DistanceLine2Box2_2

DistanceOrientedBoxConeFrustum. Robust computation of distance between an oriented box and a cone frustum in dimension 3. The algorithm is based on convex quadratic programming (CQP), a formulation as a linear complementarity problem (LCP) and minimization using successive parabolic interpolation. The image shows the initial display of various objects. The box mesh contains 8 vertices and 12 triangles. The cone mesh is created as an inscribed convex polyhedron. The triangles of the minimum-height disk form a regular polygon having a user-specified number of vertices. The triangles of the maximum-height disk form a regular polygon with more vertices than the minimum-height disk. The number of vertices is chosen internally to make the arc lengths between two consecutive vertices approximately the same for both regular polygons. The cone wall is triangulated connecting vertices between both regular polygons. Two small spheres are shown. These are centered at the closest points corresponding to the box-cone distance. A line segment is drawn to connect the two points.

DistanceOrientedBoxConeFrustum0


The image shows a different view of the box and cone, this time in wireframe mode. The pair of closest points for the box and cone are still shown as small spheres connected by a line segment. The quadrilateral cross section of the cone is drawn as a solid object inside the cone. This quadrilateral corresponds to angle $\phi = 0$. The closest points between the box and the quadrilateral are also drawn as small spheres and connected by a line segment. In this configuration, a box corner is closest both to the quadrilateral and to the cone, but the distance to the quadrilateral is necessarily larger than that to the cone.

DistanceOrientedBoxConeFrustum1


The image shows yet a different view of the box and cone. However, the quadrilateral cross section is different from that of the previous two figures. The quadrilateral selection is obtained by rotation, pressing the `+' key or `-' key. The displayed quadrilateral is not the one that attains the box-cone distance, but it is close.

DistanceOrientedBoxConeFrustum2


The image shows the same view as the previous one, but the quadrilateral was rotated to become the one that attains the box-cone distance.

DistanceOrientedBoxConeFrustum3

DistanceOrientedBoxes. Robust computation of distance between oriented boxes in dimension 3. The algorithm is based on convex quadratic programming (CQP) and a formulation as a linear complementarity problem (LCP). Various configurations are shown next. The right-most configuration shows the two boxes overlapping. The distance is zero, but the convex polyhedron of intersection is not computed.

DistanceOrientedBoxes0 DistanceOrientedBoxes1 DistanceOrientedBoxes2

DistancePointConvexPolyhedron. Robust computation of distance between a point and a convex polyhedron in dimension 3. The algorithm is based on convex quadratic programming (CQP) and a formulation as a linear complementarity problem (LCP). Various configurations are shown next. The point is drawn as the center of the green sphere. The left configuration has a face point as closest point. The middle configuration has an edge point as closest point. The right configuration has a vertex as closest point.

DistancePointConvexPolyhedron0 DistancePointConvexPolyhedron1 DistancePointConvexPolyhedron2

DistancePointHyperellipsoid. Robust computation of distance between a point and an ellipse (2D) or ellipsoid (3D) or hyperellipsoid (any dimension). This is a simple test program to verify the distances.

DistanceRectangleBox. Robust computation of distance between a rectangle and an aligned box or an oriented box in dimension 3. The algorithm is based on convex quadratic programming (CQP) and a formulation as a linear complementarity problem (LCP). Two configurations are shown next.

DistanceRectangleBox0 DistanceRectangleBox1

DistanceSegments3. Robust computation of distance between line segments in any dimension (CPU and GPU). The sample has accuracy and performance tests, both for the CPU and GPU. The performance test involves all-pairs distance computations for a large number of pairs of segments in 3D.

DistanceTriangleBox. Robust computation of distance between a triangle and an aligned box or an oriented box in dimension 3. The algorithm is based on convex quadratic programming (CQP) and a formulation as a linear complementarity problem (LCP). Two configurations are shown next.

DistanceTriangleBox0 DistanceTriangleBox1