Class StochasticLawsonsWalk
- java.lang.Object
-
- org.tinfour.standard.StochasticLawsonsWalk
-
public class StochasticLawsonsWalk extends Object
Methods and definitions to perform a stochastic Lawson's walk. The walk uses randomization to prevent getting trapped in infinite loops in the case of imperfections in Delaunay triangulations.A good review of walk algorithms for point location is provided by Soukal, R.; Málková, Kolingerová (2012) "Walking algorithms for point location in TIN models", Computational Geoscience 16:853-869.
The randomization in this class uses a custom implementation of the XORShift Random Number Generator which was discovered by George Marsaglia in 2003. This method is faster than the java.util.Random class. While it is slower than Java's ThreadLocalRandom, that Java class has the disadvantage that there is no way to set the seed value for the random sequence. For debugging and development purposes, the Tinfour team requires that the behavior of the code be reproduced every time it is run. The sequence produced by ThreadLocalRandom is always different. The exact form used here is taken from http://www.javamex.com/tutorials/random_numbers/xorshift.shtml#.WEC2g7IrJQL The technique used here were studied extensively by Sebastiano Vigna see An experimental exploration of Marsaglia's xorshift generators, scrambled at http://vigna.di.unimi.it/ftp/papers/xorshift.pdf
-
-
Constructor Summary
Constructors Constructor Description StochasticLawsonsWalk()Constructs an instance with a nominal point spacing of 1.StochasticLawsonsWalk(double nominalPointSpacing)Construct an instance based on the specified nominal point spacing.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description QuadEdgefindAnEdgeFromEnclosingTriangle(QuadEdge startingEdge, double x, double y)Search the mesh beginning at the specified edge position to find the triangle that contains the specified coordinates.voidprintDiagnostics(PrintStream ps)Print diagnostic information about the walk behavior to output stream.voidreset()Reset the random seed for the stochastic functions to zero.
-
-
-
Constructor Detail
-
StochasticLawsonsWalk
public StochasticLawsonsWalk(double nominalPointSpacing)
Construct an instance based on the specified nominal point spacing.- Parameters:
nominalPointSpacing- a value greater than zero giving an indication of the magnitude of the distances between vertices.
-
StochasticLawsonsWalk
public StochasticLawsonsWalk()
Constructs an instance with a nominal point spacing of 1.
-
-
Method Detail
-
findAnEdgeFromEnclosingTriangle
public QuadEdge findAnEdgeFromEnclosingTriangle(QuadEdge startingEdge, double x, double y)
Search the mesh beginning at the specified edge position to find the triangle that contains the specified coordinates.The algorithm requires the initial edge to be an interior-side edge of the TIN. If necessary, the initial edge is replaced with its dual in order to ensure that this condition is met before beginning the walk.
- Parameters:
startingEdge- the edge giving both the starting point of the search and storing the ultimate destination.x- the x coordinate of interesty- the y coordinate of interest- Returns:
- an edge (not necessarily the closest one) of a triangle that contains the specified coordinates, or the nearest exterior-side edge if the point lies outside the convex hull of the TIN.
-
printDiagnostics
public void printDiagnostics(PrintStream ps)
Print diagnostic information about the walk behavior to output stream.- Parameters:
ps- a valid print stream.
-
reset
public void reset()
Reset the random seed for the stochastic functions to zero.
-
-