Package il.ac.idc.jdt
Class DelaunayTriangulation
java.lang.Object
il.ac.idc.jdt.DelaunayTriangulation
This class represents a Delaunay Triangulation. The class was written for a large scale
triangulation (1000 - 200,000 vertices). The application main use is 3D surface (terrain)
presentation.
The class main properties are the following:
- fast point location. (O(n^0.5)), practical runtime is often very fast.
- handles degenerate cases and none general position input (ignores duplicate points).
- save invalid input: '&' load from\to text file in TSIN format.
- 3D support: including z value approximation.
- standard java (1.5 generic) iterators for the vertices and triangles.
- smart iterator to only the updated triangles - for terrain simplification
Testing (done in early 2005): Platform java 1.5.02 windows XP (SP2), AMD laptop 1.6G sempron CPU 512MB RAM. Constructing a triangulation of 100,000 vertices takes ~ 10 seconds. point location of 100,000 points on a triangulation of 100,000 vertices takes ~ 5 seconds. Note: constructing a triangulation with 200,000 vertices and more requires extending java heap size (otherwise an exception will be thrown).
Bugs: if U find a bug or U have an idea as for how to improve the code, please send me an email to: benmo@ariel.ac.il
The class main properties are the following:
- fast point location. (O(n^0.5)), practical runtime is often very fast.
- handles degenerate cases and none general position input (ignores duplicate points).
- save invalid input: '&' load from\to text file in TSIN format.
- 3D support: including z value approximation.
- standard java (1.5 generic) iterators for the vertices and triangles.
- smart iterator to only the updated triangles - for terrain simplification
Testing (done in early 2005): Platform java 1.5.02 windows XP (SP2), AMD laptop 1.6G sempron CPU 512MB RAM. Constructing a triangulation of 100,000 vertices takes ~ 10 seconds. point location of 100,000 points on a triangulation of 100,000 vertices takes ~ 5 seconds. Note: constructing a triangulation with 200,000 vertices and more requires extending java heap size (otherwise an exception will be thrown).
Bugs: if U find a bug or U have an idea as for how to improve the code, please send me an email to: benmo@ariel.ac.il
- Author:
- Boaz Ben Moshe 5/11/05
The project uses some ideas presented in the VoroGuide project, written by Klasse f?r Kreise (1996-1997), For the original applet see: http://www.pi6.fernuni-hagen.de/GeomLab/VoroGlide/ .
-
Constructor Summary
ConstructorDescriptioncreates an empty Delaunay Triangulation.DelaunayTriangulation
(Point[] ps) creates a Delaunay Triangulation from all the points.DelaunayTriangulation
(Collection<Point> points) -
Method Summary
Modifier and TypeMethodDescriptionPoint[]
calcVoronoiCell
(Triangle triangle, Point p) Calculates a Voronoi cell for a given neighborhood in this triangulation.boolean
contains
(double x, double y) boolean
void
deletePoint
(Point pointToDelete) Deletes the given point from this.finds the triangle the query point falls in, note if out-side of this triangulation a half plane triangle will be returned (see contains), the search has expected time of O(n^0.5), and it starts form a fixed triangle (this.startTriangle),finds the triangle the query point falls in, note if out-side of this triangulation a half plane triangle will be returned (see contains). the search starts from the the start trianglefindClosePoint
(Point pointToDelete) return a point from the trangulation that is close to pointToDeletefindTriangleNeighborhood
(Triangle firstTriangle, Point point) int
compute the number of vertices in the convex hull.returns an iterator to the set of all the points on the XY-convex hullreturns an iterator object involved in the last update.int
returns the changes counter for this triangulationvoid
indexData
(int xCellCount, int yCellCount) Index the triangulation using a grid indexvoid
insertPoint
(Point p) insert the point to this Delaunay Triangulation.void
insertPoints
(Collection<Point> points) return the max point of the bounding box of this triangulation {{x1,y1,z1}}return the min point of the bounding box of this triangulation {{x0,y0,z0}}void
Remove any existing spatial indexingint
size()
the number of (different) vertices in this triangulation.computes the current set (vector) of all triangles and return an iterator to them.int
returns an iterator to the set of points compusing this triangulation.double
z
(double x, double y)
-
Constructor Details
-
DelaunayTriangulation
public DelaunayTriangulation()creates an empty Delaunay Triangulation. -
DelaunayTriangulation
creates a Delaunay Triangulation from all the points. Note: duplicated points are ignored. -
DelaunayTriangulation
-
-
Method Details
-
size
public int size()the number of (different) vertices in this triangulation.- Returns:
- the number of vertices in the triangulation (duplicates are ignore - set size).
-
trianglesSize
public int trianglesSize()- Returns:
- the number of triangles in the triangulation.
Note: includes infinife faces!!.
-
getModeCounter
public int getModeCounter()returns the changes counter for this triangulation -
insertPoints
-
insertPoint
insert the point to this Delaunay Triangulation. Note: if p is null or already exist in this triangulation p is ignored.- Parameters:
p
- new vertex to be inserted the triangulation.
-
deletePoint
Deletes the given point from this.- Parameters:
pointToDelete
- The given point to delete. Implementation of the Mostafavia, Gold invalid input: '&' Dakowicz algorithm (2002). By Eyal Roth invalid input: '&' Doron Ganel (2009).
-
findClosePoint
return a point from the trangulation that is close to pointToDelete- Parameters:
pointToDelete
- the point that the user wants to delete- Returns:
- a point from the trangulation that is close to pointToDelete By Eyal Roth invalid input: '&' Doron Ganel (2009).
-
calcVoronoiCell
Calculates a Voronoi cell for a given neighborhood in this triangulation. A neighborhood is defined by a triangle and one of its corner points. By Udi Schneider- Parameters:
triangle
- a triangle in the neighborhoodp
- corner point whose surrounding neighbors will be checked- Returns:
- set of Points representing the cell polygon
-
getLastUpdatedTriangles
returns an iterator object involved in the last update.- Returns:
- iterator to all triangles involved in the last update of the triangulation NOTE: works ONLY if the are triangles (it there is only a half plane - returns an empty iterator
-
getConvexHullSize
public int getConvexHullSize()compute the number of vertices in the convex hull.
NOTE: has a 'bug-like' behavor:
in cases of colinear - not on a asix parallel rectangle, colinear points are reported- Returns:
- the number of vertices in the convex hull.
-
find
finds the triangle the query point falls in, note if out-side of this triangulation a half plane triangle will be returned (see contains), the search has expected time of O(n^0.5), and it starts form a fixed triangle (this.startTriangle),- Parameters:
p
- query point- Returns:
- the triangle that point p is in.
-
find
finds the triangle the query point falls in, note if out-side of this triangulation a half plane triangle will be returned (see contains). the search starts from the the start triangle- Parameters:
p
- query pointstart
- the triangle the search starts at.- Returns:
- the triangle that point p is in..
-
findTriangleNeighborhood
-
contains
- Parameters:
p
- query point- Returns:
- true iff p is within this triangulation (in its 2D convex hull).
-
contains
public boolean contains(double x, double y) - Parameters:
x
- - X cordination of the query pointy
- - Y cordination of the query point- Returns:
- true iff (x,y) falls inside this triangulation (in its 2D convex hull).
-
z
- Parameters:
q
- Query point- Returns:
- the q point with updated Z value (z value is as given the triangulation).
-
z
public double z(double x, double y) - Parameters:
x
- - X cordination of the query pointy
- - Y cordination of the query point- Returns:
- the q point with updated Z value (z value is as given the triangulation).
-
getBoundingBox
- Returns:
- The bounding rectange between the minimum and maximum coordinates
-
minBoundingBox
return the min point of the bounding box of this triangulation {{x0,y0,z0}} -
maxBoundingBox
return the max point of the bounding box of this triangulation {{x1,y1,z1}} -
trianglesIterator
computes the current set (vector) of all triangles and return an iterator to them.- Returns:
- an iterator to the current set of all triangles.
-
getConvexHullVerticesIterator
returns an iterator to the set of all the points on the XY-convex hull- Returns:
- iterator to the set of all the points on the XY-convex hull.
-
verticesIterator
returns an iterator to the set of points compusing this triangulation.- Returns:
- iterator to the set of points compusing this triangulation.
-
indexData
public void indexData(int xCellCount, int yCellCount) Index the triangulation using a grid index- Parameters:
xCellCount
- number of grid cells in a rowyCellCount
- number of grid cells in a column
-
removeIndex
public void removeIndex()Remove any existing spatial indexing -
getTriangulation
-