public final class Tessellator extends Object
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:
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.
Modifier and Type | Class and Description |
---|---|
protected static class |
Tessellator.Node
Circular Doubly-linked list used for polygon coordinates
|
static class |
Tessellator.Triangle
Triangle in the tessellated mesh
|
Modifier and Type | Method and Description |
---|---|
static 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 |
pointInPolygon(List<Tessellator.Triangle> tessellation,
double lat,
double lon)
Brute force compute if a point is in the polygon by traversing entire triangulation
todo: speed this up using either binary tree or prefix coding (filtering by bounding box of triangle)
|
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) |
static List<Tessellator.Triangle> |
tessellate(XYPolygon polygon) |
public static final List<Tessellator.Triangle> tessellate(Polygon polygon)
public static final List<Tessellator.Triangle> tessellate(XYPolygon polygon)
public static final boolean linesIntersect(double aX0, double aY0, double aX1, double aY1, double bX0, double bY0, double bX1, double bY1)
public static boolean pointInTriangle(double x, double y, double ax, double ay, double bx, double by, double cx, double cy)
public static final boolean pointInPolygon(List<Tessellator.Triangle> tessellation, double lat, double lon)
Copyright © 2000-2021 Apache Software Foundation. All Rights Reserved.