src/main/java/de/javagl/geom/OrientedBoundingBoxes.java
/**
     * Computes the corners of the minimum oriented bounding box of the
     * given set of points
     * 
     * @param points The input points
     * @return The corners of the minimum oriented bounding box
     */
Computes the corners of the minimum oriented bounding box of the
given set of points

@param points The input points
@return The corners of the minimum oriented bounding box
Computes the corners of the minimum oriented bounding box of the given set of points @param points The input points @return The corners of the minimum oriented bounding box
public static List<Point2D> computeMinimumOrientedBoundingBoxCorners(
        List<? extends Point2D> points)
    {
        List<Point2D> convexHullPoints = ConvexHull.compute(points);
        int alignmentPointIndex = 
            computeAlignmentPointIndex(convexHullPoints);
        int nextIndex = (alignmentPointIndex+1)%convexHullPoints.size();
        Point2D p0 = convexHullPoints.get(alignmentPointIndex);
        Point2D p1 = convexHullPoints.get(nextIndex);
        AffineTransform at = computeAlignmentTransform(p0, p1);
        List<Point2D> transformedPoints = Points.transform(at, points);
        Rectangle2D r = Points.computeBounds(transformedPoints);
        List<Point2D> alignedCorners = new ArrayList<Point2D>();
        alignedCorners.add(new Point2D.Double(r.getMinX(), r.getMinY()));
        alignedCorners.add(new Point2D.Double(r.getMaxX(), r.getMinY()));
        alignedCorners.add(new Point2D.Double(r.getMaxX(), r.getMaxY()));
        alignedCorners.add(new Point2D.Double(r.getMinX(), r.getMaxY()));
        AffineTransform iat = computeInverseAlignmentTransform(p0, p1);
        List<Point2D> corners = Points.transform(iat, alignedCorners);
        return corners;
    }
public static List < Point2D > computeMinimumOrientedBoundingBoxCorners ( List < ? extends Point2D > points ) { List < Point2D > convexHullPoints = ConvexHull . compute ( points ) ; int alignmentPointIndex = computeAlignmentPointIndex ( convexHullPoints ) ; int nextIndex = ( alignmentPointIndex + 1 ) % convexHullPoints . size ( ) ; Point2D p0 = convexHullPoints . get ( alignmentPointIndex ) ; Point2D p1 = convexHullPoints . get ( nextIndex ) ; AffineTransform at = computeAlignmentTransform ( p0 , p1 ) ; List < Point2D > transformedPoints = Points . transform ( at , points ) ; Rectangle2D r = Points . computeBounds ( transformedPoints ) ; List < Point2D > alignedCorners = new ArrayList < Point2D > ( ) ; alignedCorners . add ( new Point2D . Double ( r . getMinX ( ) , r . getMinY ( ) ) ) ; alignedCorners . add ( new Point2D . Double ( r . getMaxX ( ) , r . getMinY ( ) ) ) ; alignedCorners . add ( new Point2D . Double ( r . getMaxX ( ) , r . getMaxY ( ) ) ) ; alignedCorners . add ( new Point2D . Double ( r . getMinX ( ) , r . getMaxY ( ) ) ) ; AffineTransform iat = computeInverseAlignmentTransform ( p0 , p1 ) ; List < Point2D > corners = Points . transform ( iat , alignedCorners ) ; return corners ; }
Computes the corners of the minimum oriented bounding box of the
 given set of points
Computes the corners of the minimum oriented bounding box of the given set of points
// Compute the points that describe the edge of the convex
 // hull that coincides with one edge of the minimum 
 // oriented bounding box
 // Compute the corners of the minimum oriented bounding
 // box when the edge is aligned with the x-axis
 // Transform the corners back into the original space
