﻿ Geometric Tools: Source - Mathematics - Containment

## Mathematics: Containment

 Containment queries for circles and spheres. Containment queries for ellipses. The ContEllipse2 class uses a minimization algorithm in 5 dimensions to determine, center, orientation, and extents. The ContEllipse2MinCR class is a minimization algorithm in 2 dimensions, where the center and orientation of the ellipse are specified. Containment queries for ellipsoids. The ContEllipsoid3 class uses a minimization algorithm in 9 dimensions to determine, center, orientation, and extents. The ContEllipsoid3MinCR class is a minimization algorithm in 3 dimensions, where the center and orientation of the ellipsoid are specified. Containment queries for aligned or oriented boxes in 2D or 3D. The query ``` template bool GetContainer(int numPoints, Vector2 const* points, OrientedBox2& box); ``` computes the rectangle using the mean of the points as the center and the eigenvectors of the covariance matrix of the points as the rectangle axis directions. It generates an oriented rectangle that contains the points but is not generally the minimum-area rectangle containing the points. The minimum-area rectangle is more complicated to compute (robustly); see the PDF mentioned in the following list and the associated source code for computing the minimum-area rectangle. The query ``` template bool GetContainer(int numPoints, Vector3 const* points, OrientedBox3& box); ``` computes the box using the mean of the points as the center and the eigenvectors of the covariance matrix of the points as the box axis directions. It generates an oriented box that contains the points but is not generally the minimum-volume box containing the points. The minimum-volume box is more complicated to compute (robustly) and uses the 2D minimum-area rectangle algorithm for subproblems that occur. Source code for the minimum-volume box query is available. We are currently writing the PDF document that describes the algorithm and will post is when finished. The minimum-area rectangle code performance was greatly improved (nearly twice as fast as the previous version). The minimum-volume box code will be modified as well to obtain a performance increase. Containment queries for cylinders, capsules or lozenges. Point-in-cone query for cones in any dimension 2 or larger. Point-in-polygon and point-in-polyhedron queries. Inscribed and circumscribed circles in 2D or 3D. Inscribed and circumscribed spheres in 3D. Containment of a 2D arc by a 2D aligned box.