Package org.apache.lucene.geo

# Class Tessellator

java.lang.Object
org.apache.lucene.geo.Tessellator

public final class Tessellator extends Object
Computes a triangular mesh tessellation for a given polygon.

This is inspired by mapbox's earcut algorithm (https://github.com/mapbox/earcut) which is a modification to FIST (https://www.cosy.sbg.ac.at/~held/projects/triang/triang.html) written by Martin Held, and ear clipping (https://www.geometrictools.com/Documentation/TriangulationByEarClipping.pdf) written by David Eberly.

Notes:

- Requires valid polygons:
  - No self intersections
  - Holes may only touch at one vertex
  - Polygon must have an area (e.g., no "line" boxes)
  - sensitive to overflow (e.g, subatomic values such as E-200 can cause unexpected behavior)

The code is a modified version of the javascript implementation provided by MapBox under the following license:

ISC License

Copyright (c) 2016, Mapbox

Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH' REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

NOTE: This API is for internal purposes only and might change in incompatible ways in the next release.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static interface`
`Tessellator.Monitor`
Implementation of this interface will receive calls with internal data at each step of the triangulation algorithm.
`protected static class`
`Tessellator.Node`
Circular Doubly-linked list used for polygon coordinates
`static final class`
`Tessellator.Triangle`
Triangle in the tessellated mesh

## Method Summary

Modifier and Type
Method
Description
`static final boolean`
`linesIntersect(double aX0, double aY0, double aX1, double aY1, double bX0, double bY0, double bX1, double bY1)`
Determines whether two line segments intersect.
`static boolean`
`pointInTriangle(double x, double y, double ax, double ay, double bx, double by, double cx, double cy)`
compute whether the given x, y point is in a triangle; uses the winding order method
`static List<Tessellator.Triangle>`
`tessellate(Polygon polygon, boolean checkSelfIntersections)`
`static List<Tessellator.Triangle>`
`tessellate(Polygon polygon, boolean checkSelfIntersections, Tessellator.Monitor monitor)`
`static List<Tessellator.Triangle>`
`tessellate(XYPolygon polygon, boolean checkSelfIntersections)`
`static List<Tessellator.Triangle>`
`tessellate(XYPolygon polygon, boolean checkSelfIntersections, Tessellator.Monitor monitor)`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Method Details

### tessellate

public static List<Tessellator.Triangle> tessellate(Polygon polygon, boolean checkSelfIntersections)

### tessellate

public static List<Tessellator.Triangle> tessellate(Polygon polygon, boolean checkSelfIntersections, Tessellator.Monitor monitor)

### tessellate

public static List<Tessellator.Triangle> tessellate(XYPolygon polygon, boolean checkSelfIntersections)

### tessellate

public static List<Tessellator.Triangle> tessellate(XYPolygon polygon, boolean checkSelfIntersections, Tessellator.Monitor monitor)

### linesIntersect

public static final boolean linesIntersect(double aX0, double aY0, double aX1, double aY1, double bX0, double bY0, double bX1, double bY1)
Determines whether two line segments intersect. *

### pointInTriangle

public static boolean pointInTriangle(double x, double y, double ax, double ay, double bx, double by, double cx, double cy)
compute whether the given x, y point is in a triangle; uses the winding order method