org.jhotdraw.geom
Class ConvexHull

java.lang.Object
  extended by org.jhotdraw.geom.ConvexHull

public class ConvexHull
extends java.lang.Object

Provides utility methods for computing the convex hull from a set of points.

Version:
$Id: ConvexHull.java 727 2011-01-09 13:23:59Z rawcoder $
Author:
Werner Randelshofer

Constructor Summary
ConvexHull()
           
 
Method Summary
static java.util.List<java.awt.Point> getConvexHull(java.util.List<java.awt.Point> points)
          Computes the convex hull from a set of points.
static java.awt.Point[] getConvexHull(java.awt.Point[] points)
          Computes the convex hull from a set of points.
static java.util.List<java.awt.geom.Point2D.Double> getConvexHull2D(java.util.List<java.awt.geom.Point2D.Double> points)
          Computes the convex hull from a set of points.
static java.awt.geom.Point2D.Double[] getConvexHull2D(java.awt.geom.Point2D.Double[] points)
          Computes the convex hull from a set of points.
static Polygon2D.Double getConvexHullPath2D(java.util.List<java.awt.geom.Point2D.Double> points)
          Computes the convex hull from a set of points.
static Polygon2D.Double getConvexHullPath2D(java.awt.Shape shape)
          Computes the convex hull from a shape.
static java.awt.Polygon getConvexHullPolygon(java.util.List<java.awt.Point> points)
          Computes the convex hull from a set of points.
static boolean isRightTurn(java.awt.Point p1, java.awt.Point p2, java.awt.Point p3)
          Returns true, if the three given points make a right turn.
static boolean isRightTurn2D(java.awt.geom.Point2D.Double p1, java.awt.geom.Point2D.Double p2, java.awt.geom.Point2D.Double p3)
          Returns true, if the three given points make a right turn.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConvexHull

public ConvexHull()
Method Detail

getConvexHullPolygon

public static java.awt.Polygon getConvexHullPolygon(java.util.List<java.awt.Point> points)
Computes the convex hull from a set of points.

Parameters:
points -
Returns:
convex hull of the points as a polygon object.

getConvexHullPath2D

public static Polygon2D.Double getConvexHullPath2D(java.util.List<java.awt.geom.Point2D.Double> points)
Computes the convex hull from a set of points.

Parameters:
points -
Returns:
convex hull of the points as a Polygon2D object.

getConvexHullPath2D

public static Polygon2D.Double getConvexHullPath2D(java.awt.Shape shape)
Computes the convex hull from a shape.

Parameters:
shape - an arbitray shape
Returns:
convex hull of the points as a Polygon2D object.

getConvexHull

public static java.util.List<java.awt.Point> getConvexHull(java.util.List<java.awt.Point> points)
Computes the convex hull from a set of points.

Parameters:
points -
Returns:
convex hull of the points

getConvexHull2D

public static java.util.List<java.awt.geom.Point2D.Double> getConvexHull2D(java.util.List<java.awt.geom.Point2D.Double> points)
Computes the convex hull from a set of points.

Parameters:
points -
Returns:
convex hull of the points

getConvexHull

public static java.awt.Point[] getConvexHull(java.awt.Point[] points)
Computes the convex hull from a set of points.

Parameters:
points -
Returns:
convex hull of the points

isRightTurn

public static boolean isRightTurn(java.awt.Point p1,
                                  java.awt.Point p2,
                                  java.awt.Point p3)
Returns true, if the three given points make a right turn.

Parameters:
p1 - first point
p2 - second point
p3 - third point
Returns:
true if right turn.

getConvexHull2D

public static java.awt.geom.Point2D.Double[] getConvexHull2D(java.awt.geom.Point2D.Double[] points)
Computes the convex hull from a set of points.

Parameters:
points -
Returns:
convex hull of the points

isRightTurn2D

public static boolean isRightTurn2D(java.awt.geom.Point2D.Double p1,
                                    java.awt.geom.Point2D.Double p2,
                                    java.awt.geom.Point2D.Double p3)
Returns true, if the three given points make a right turn.

Parameters:
p1 - first point
p2 - second point
p3 - third point
Returns:
true if right turn.