How this calculation works
An axis-aligned bounding rectangle is easy to compute but can enclose much more empty area than a rotated one. This calculator first finds the convex hull, then tests every hull-edge orientation. At each angle it projects the hull onto perpendicular axes and constructs the tight enclosing rectangle. The minimum-area rectangle of a planar convex polygon has a side aligned with a hull edge, so this finite orientation search covers the supported optimum rather than sampling angles arbitrarily. Returned corners are mapped back to the original coordinate system.
For each convex-hull edge orientation, project all hull vertices onto orthogonal axes; minimize (max u−min u)(max v−min v).A worked example
The four diamond points (0,1),(1,0),(0,−1),(−1,0) have an axis-aligned bounding box of area four. Rotating the enclosure axes by 45 degrees produces a square of side sqrt(2), area two and perimeter 4sqrt(2). Adding the interior point (0,0) does not change that enclosure. Equivalent optimal rectangles can differ by which side is called width or by a 90-degree angle shift; their geometric corner set and area describe the same result.
Good to know
1–200 unordered finite points on the bounded six-decimal input grid. Hull orientation uses high-precision decimal predicates; projections, angles and lengths are numerical. Duplicate and interior points do not change the hull. Equal-area optima use a deterministic first orientation, so angle/width labels are not unique. A point or segment has zero area; segment perimeter is reported as its endpoint distance. No 3D box, minimum-perimeter objective or PCA approximation is substituted.
Reference: CGAL — optimal planar rectangles and hull-edge orientations (opens in a new tab) ↗
The convex hull retains every constraint that can touch the rectangle
Any rectangle containing every input point also contains their convex hull, because a rectangle is convex. Conversely, containing the hull contains all original points. Interior observations can therefore be removed from the enclosure search without losing a boundary constraint. Duplicate coordinates are also irrelevant to the geometric set, though they might matter in a separate statistical analysis. The calculator makes an enclosure, not a fitted distribution of the points.
For a fixed orientation, minimum and maximum projections determine the tight interval along each axis. Multiplying their widths gives its area, and combining the interval endpoints gives four corners. Testing each hull edge is complete for the minimum-area polygon enclosure. This implementation performs the finite projection search directly instead of claiming a linear-time rotating-calipers optimization that its bounded routine does not implement.
Minimum area is a geometric objective with nonunique representations
A rectangle rotated by 90 degrees can swap width and height without changing its corner set. Symmetric inputs can have several equivalent orientations, and an input with equal-area candidate enclosures may have different optimal corner sets. The page returns one supported optimum and states the angle of its selected first axis. Comparing only the displayed angle to another tool can create a false disagreement; compare containment and area as well.
Principal-component axes optimize a variance criterion and need not minimize enclosing area. Likewise, the smallest axis-aligned rectangle is constrained to fixed axes and is a different problem. The Convex hull calculator from unordered points returns the tight polygonal envelope, while this page constrains that envelope to four perpendicular sides. Collinear points and a single point remain valid degenerate inputs, but their zero-area output should not be interpreted as a positive-volume box.
A few questions, answered
Why can width and height be reversed in another answer?
The same rectangle can be represented with axes swapped and the angle shifted by 90 degrees. Compare its corner set and area rather than one axis label.
Does adding more interior points change the rectangle?
No. Only the convex hull constrains the enclosure. A new point outside that hull can change the optimum.