GitXplorerGitXplorer
b

RotatingCalipers

public
24 stars
1 forks
0 issues

Commits

List of commits on branch master.
Verified
6096d4e17da2c28151af4032afdee8abfbb90a2d

Update README.md

bbkiers committed 5 years ago
Unverified
6ce2e047f53835b50e59e8ab055ebb6ad9cc6d0c

Added mod 360 to assignment currentAngle

bbkiers committed 6 years ago
Unverified
7812b9816dc94292a7725b85508ee59efb2ea8b1

Update README.md

bbkiers committed 12 years ago
Unverified
7039db07b8125c4bbde3754abd5ac4ea19fd7125

Update README.md

bbkiers committed 12 years ago
Unverified
6968d115f22c06be3bf0188dd04899dc460286b7

Update README.md

bbkiers committed 12 years ago
Unverified
b0f2d14aeb8eb32f77d537ee914b1b54c51cc1d4

Update README.md

bbkiers committed 12 years ago

README

The README file for this repository.

RotatingCalipers

A Java implementation of the Rotating Calipers algorithm to find the minimum bounding rectangle of a set of points.

How to use it

The implementation is pretty straight forward: everything resides in a single class (RotatingCalipers). Simply copy the class in your project, and invoke one of the following methods:

get all bounding rectangles

getAllBoundingRectangles(int[] xs, int[] ys) : List<Point2D.Double[]>
getAllBoundingRectangles(List<Point> points) : List<Point2D.Double[]>

get the minimum bounding rectangle

getMinimumBoundingRectangle(int[] xs, int[] ys) : Point2D.Double[]
getMinimumBoundingRectangle(List<Point> points) : Point2D.Double[]

get the area of a rectangle

getArea(Point2D.Double[] rectangle) : double

Example

-

int[] xs = {-300, 200, 100, -400};
int[] ys = {-150, 200, -100, 0};

Point2D.Double[] minimum = RotatingCalipers.getMinimumBoundingRectangle(xs, ys);

int number = 1;

for(Point2D.Double corner : minimum) {
    System.out.printf("corner[%d] (%.1f, %.1f)%n", number++, corner.x, corner.y);
}

System.out.printf("%narea: %.1f", RotatingCalipers.getArea(minimum));

which will print:

corner[1] (280.0, -40.0)
corner[2] (200.0, 200.0)
corner[3] (-400.0, -0.0)
corner[4] (-320.0, -240.0)

area: 160000.0