de.unihalle.informatik.MiToBo.core.datatypes
Class Polygon2D_Cgal

java.lang.Object
  extended by de.unihalle.informatik.MiToBo.core.datatypes.Polygon2D_Cgal

public class Polygon2D_Cgal
extends java.lang.Object

Java Native Interface wrapper class for 2D polygons to include CGAL library methods.

Author:
moeller

Constructor Summary
Polygon2D_Cgal()
           
 
Method Summary
 boolean cgal_isClockwiseOriented(double[] xs, double[] ys)
           
 boolean cgal_isConvex(double[] xs, double[] ys)
           
 boolean cgal_isCounterclockwiseOriented(double[] xs, double[] ys)
           
 boolean cgal_isSimple(double[] xs, double[] ys)
          Checks if a polygon is simple.
 double[] cgal_makePolySimple(double[] xs, double[] ys)
          Simplifies the given polygon.
 int cgal_orientation(double[] xs, double[] ys, double[] pt)
           
 double cgal_signedArea(double[] xs, double[] ys)
          Calculates the signed area of a polygon.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Polygon2D_Cgal

public Polygon2D_Cgal()
Method Detail

cgal_isClockwiseOriented

public boolean cgal_isClockwiseOriented(double[] xs,
                                        double[] ys)
Parameters:
xs - List of point x coordinates.
ys - List of point y coordinates.
Returns:
True, if polygon is oriented clockwise.

cgal_isConvex

public boolean cgal_isConvex(double[] xs,
                             double[] ys)
Parameters:
xs - List of point x coordinates.
ys - List of point y coordinates.
Returns:
True, if polygon is convex.

cgal_isCounterclockwiseOriented

public boolean cgal_isCounterclockwiseOriented(double[] xs,
                                               double[] ys)
Parameters:
xs - List of point x coordinates.
ys - List of point y coordinates.
Returns:
True, if polygon is oriented counter-clockwise.

cgal_isSimple

public boolean cgal_isSimple(double[] xs,
                             double[] ys)
Checks if a polygon is simple.

Parameters:
xs - List of point x coordinates.
ys - List of point y coordinates.
Returns:
True, if polygon is simple.

cgal_makePolySimple

public double[] cgal_makePolySimple(double[] xs,
                                    double[] ys)
Simplifies the given polygon.

Parameters:
xs - List of point x coordinates.
ys - List of point y coordinates.
Returns:
New polygon points (first x coords, then y coords).

cgal_orientation

public int cgal_orientation(double[] xs,
                            double[] ys,
                            double[] pt)
Parameters:
xs - List of point x coordinates.
ys - List of point y coordinates.
pt - Point to check.
Returns:
-1, if point lies on negative side, 1, if on positive side, and 0 if on boundary

cgal_signedArea

public double cgal_signedArea(double[] xs,
                              double[] ys)
Calculates the signed area of a polygon.

The sign is positive for counter-clockwise polygons, negative for clockwise polygons. If the polygon is not simple, the area is not well defined

Parameters:
xs - List of point x coordinates.
ys - List of point y coordinates.
Returns:
Signed value of polygon area.