Class PGS_PointSet
- Since:
- 1.2.0
- Author:
- Michael Carleton
-
Method Summary
Modifier and TypeMethodDescriptionstatic List<processing.core.PVector>
applyRandomWeights
(List<processing.core.PVector> points, double minWeight, double maxWeight) Applies random weights within a specified range to a list of points.static List<processing.core.PVector>
applyRandomWeights
(List<processing.core.PVector> points, double minWeight, double maxWeight, long seed) Applies random weights within a specified range to a list of points.cluster
(Collection<processing.core.PVector> points, int groups) Clusters points into N groups, using k-means clustering.cluster
(Collection<processing.core.PVector> points, int groups, long seed) Clusters points into N groups, using k-means clustering.static processing.core.PShape
findShortestTour
(List<processing.core.PVector> points) Computes an approximate Traveling Salesman path for the set of points provided.static List<processing.core.PVector>
gaussian
(double centerX, double centerY, double sd, int n) Generates a set of random points having a gaussian/normal distribution.static List<processing.core.PVector>
gaussian
(double centerX, double centerY, double sd, int n, long seed) Generates a set of random points having a gaussian/normal distribution, using the specified seed.static List<processing.core.PVector>
haltonLDS
(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on a Halton sequence.static List<processing.core.PVector>
hammersleyLDS
(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on a Hammersley sequence.static List<processing.core.PVector>
hexagon
(double centerX, double centerY, int length, double distance) Generates a hexagonal grid of points arranged in a hexagon pattern.static List<processing.core.PVector>
hexGrid
(double xMin, double yMin, double xMax, double yMax, double pointDistance) Generates a hexagon grid of points that lie within a bounding rectangle.static List<processing.core.PVector>
hexGrid
(double xMin, double yMin, double xMax, double yMax, int n) Generates a hexagon grid/lattice of points that lie within a bounding rectangle.static List<processing.core.PVector>
hilbertSort
(List<processing.core.PVector> points) Sorts a list of points according to the Hilbert space-filling curve to ensure a high-degree of spatial locality in the sequence of points.static processing.core.PShape
minimumSpanningTree
(List<processing.core.PVector> points) Computes the Euclidean minimum spanning tree (EMST) of a set of points.static List<processing.core.PVector>
nRooksLDS
(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of random stratified points (bounded by a rectangle) based on the "N-Rooks" sampling pattern.static List<processing.core.PVector>
nRooksLDS
(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a set of random stratified points (bounded by a rectangle) based on the "N-Rooks" sampling pattern.static List<processing.core.PVector>
phyllotaxis
(double centerX, double centerY, int n, double radius) Generates a set of points arranged in a phyllotaxis pattern (an arrangement similar to the florets in the head of a sunflower), using the golden ratio (the most irrational number) to position points with the least possible aliasing (which is arguably the "best" arrangement).static List<processing.core.PVector>
phyllotaxis
(double centerX, double centerY, int n, double radius, double theta) Generates a set of points arranged in a phyllotaxis pattern (an arrangement similar to the florets in the head of a sunflower), using a user-defined theta.static List<processing.core.PVector>
plasticJitteredLDS
(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on an irrational number.static List<processing.core.PVector>
plasticJitteredLDS
(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on an irrational number.static List<processing.core.PVector>
plasticLDS
(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on an irrational number (the plastic constant).static List<processing.core.PVector>
poisson
(double xMin, double yMin, double xMax, double yMax, double minDist) Generates a set of random points (constrained within a rectangular region) via Poisson Disk Sampling.static List<processing.core.PVector>
poisson
(double xMin, double yMin, double xMax, double yMax, double minDist, long seed) Generates a set of random points (constrained within a rectangular region) via Poisson Disk Sampling, using the specified seed.static List<processing.core.PVector>
poissonN
(double xMin, double yMin, double xMax, double yMax, int n) Generates a poisson point set having N points constrained within a rectangular region using a random seed.static List<processing.core.PVector>
poissonN
(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a poisson point set having N points constrained within a rectangular region.static List<processing.core.PVector>
prunePointsWithinDistance
(List<processing.core.PVector> points, double distanceTolerance) Returns a filtered copy of the input, containing no points that are within thedistanceTolerance
of each other.static List<processing.core.PVector>
pruneSparsePoints
(Collection<processing.core.PVector> points, double distanceTolerance) Prunes a list of points by removing points that are considered not sufficiently dense.static List<processing.core.PVector>
random
(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of random (uniform) points that lie within a bounding rectangle.static List<processing.core.PVector>
random
(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a set of random (uniform) points that lie within a bounding rectangle, using the specified seed.static List<processing.core.PVector>
ring
(double centerX, double centerY, double innerRadius, double outerRadius, double maxAngle, int n) Generates a set of n points that are randomly distributed on a ring (annulus).static List<processing.core.PVector>
ring
(double centerX, double centerY, double innerRadius, double outerRadius, double maxAngle, int n, long seed) Generates a set of points that are randomly distributed on a ring (annulus).static List<processing.core.PVector>
sobolLDS
(double xMin, double yMin, double xMax, double yMax, int n) Generates a 2D set of deterministic stratified points (bounded by a rectangle) from the Sobol low discrepancy sequence (LDS).static List<processing.core.PVector>
squareGrid
(double xMin, double yMin, double xMax, double yMax, double pointDistance) Generates a square grid/lattice of points that lie within a bounding rectangle.static List<processing.core.PVector>
thomasClusters
(double xMin, double yMin, double xMax, double yMax, double parentsDensity, double meanChildPoints, double childSpread, long seed) Generates random points having clustered properties using the Thomas Point Process.static processing.core.PVector
weightedMedian
(Collection<processing.core.PVector> points) Finds the geometric median point of a set of weighted sample points.
-
Method Details
-
prunePointsWithinDistance
public static List<processing.core.PVector> prunePointsWithinDistance(List<processing.core.PVector> points, double distanceTolerance) Returns a filtered copy of the input, containing no points that are within thedistanceTolerance
of each other.This method can be used to convert a random point set into a blue-noise-like (poisson) point set.
- Parameters:
points
- list of points to filterdistanceTolerance
- a point that is within this distance of a previously included point is not included in the output- Returns:
-
pruneSparsePoints
public static List<processing.core.PVector> pruneSparsePoints(Collection<processing.core.PVector> points, double distanceTolerance) Prunes a list of points by removing points that are considered not sufficiently dense.A point's density is assessed based on its distance to its nearest neighbor; if the nearest neighbor of a point is farther away than the specified distance tolerance, the point is considered sparse and removed. In other words, only points that have at least one neighbor within the distance tolerance are kept.
- Parameters:
points
- A List ofPVector
points to be analysed and pruned.distanceTolerance
- The maximum allowable distance for a point to be considered dense. Points with their nearest neighbor distance greater than the distance tolerance are pruned.- Returns:
- A List of
PVector
points where each point has at least one neighbor within the distance tolerance, i.e., the list of points after sparse points have been removed. - Since:
- 2.0
-
hilbertSort
Sorts a list of points according to the Hilbert space-filling curve to ensure a high-degree of spatial locality in the sequence of points.- Parameters:
points
- list of points to sort. a list requires at least 24 points to be sorted.- Returns:
- a sorted copy of the input list, having a different order according to points' Hilbert ranking of their (x, y) coordinate
- Since:
- 1.3.0
-
cluster
public static List<List<processing.core.PVector>> cluster(Collection<processing.core.PVector> points, int groups) Clusters points into N groups, using k-means clustering.K-means finds the N cluster centers and assigns points to the nearest cluster center, such that the squared (euclidean) distances from the cluster are minimised.
- Parameters:
points
- list of points to clustergroups
- desired number of clustered groups- Returns:
- list of groups, where each group is a list of PVectors
- Since:
- 1.4.0
- See Also:
-
cluster
public static List<List<processing.core.PVector>> cluster(Collection<processing.core.PVector> points, int groups, long seed) Clusters points into N groups, using k-means clustering.K-means finds the N cluster centers and assigns points to the nearest cluster center, such that the squared (euclidean) distances from the cluster are minimised.
- Parameters:
points
- list of points to clustergroups
- desired number of clustered groupsseed
- random seed- Returns:
- list of groups, where each group is a list of PVectors
- Since:
- 1.4.0
- See Also:
-
weightedMedian
Finds the geometric median point of a set of weighted sample points.The median point is the point that minimises the sum of (weighted) distances to the sample points.
Points are expressed as PVectors; the z coordinate is used as the weight for each point. Weights must be positive. If every point has a weight of 0 (z=0), the function returns the median as if each point had an equal non-zero weight (set to 1).
- Parameters:
points
- list of points, where the z coordinate is point weight- Returns:
- 2D median point
- Since:
- 1.4.0
-
random
public static List<processing.core.PVector> random(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of random (uniform) points that lie within a bounding rectangle.- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
- See Also:
-
random
public static List<processing.core.PVector> random(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a set of random (uniform) points that lie within a bounding rectangle, using the specified seed.- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generateseed
- number used to initialize the underlying pseudorandom number generator- Returns:
- See Also:
-
gaussian
public static List<processing.core.PVector> gaussian(double centerX, double centerY, double sd, int n) Generates a set of random points having a gaussian/normal distribution. The point set is centered around the given center, given by mean coordinates.- Parameters:
centerX
- x coordinate of the center/mean of the point setcenterY
- x coordinate of the center/mean of the point setsd
- standard deviation, which specifies how much the values can vary from the mean. 68% of point samples have a value within one standard deviation of the mean; three standard deviations account for 99.7% of the sample populationn
- number of points to generate- See Also:
-
gaussian
public static List<processing.core.PVector> gaussian(double centerX, double centerY, double sd, int n, long seed) Generates a set of random points having a gaussian/normal distribution, using the specified seed. The point set is centered around the given center, given by mean coordinates.- Parameters:
centerX
- x coordinate of the center/mean of the point setcenterY
- x coordinate of the center/mean of the point setsd
- standard deviation, which specifies how much the values can vary from the mean. 68% of point samples have a value within one standard deviation of the mean; three standard deviations account for 99.7% of the sample populationn
- number of points to generateseed
- number used to initialize the underlying pseudorandom number generator- Returns:
- See Also:
-
squareGrid
public static List<processing.core.PVector> squareGrid(double xMin, double yMin, double xMax, double yMax, double pointDistance) Generates a square grid/lattice of points that lie within a bounding rectangle.- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximum- Returns:
-
hexGrid
public static List<processing.core.PVector> hexGrid(double xMin, double yMin, double xMax, double yMax, int n) Generates a hexagon grid/lattice of points that lie within a bounding rectangle.- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
- See Also:
-
hexGrid
public static List<processing.core.PVector> hexGrid(double xMin, double yMin, double xMax, double yMax, double pointDistance) Generates a hexagon grid of points that lie within a bounding rectangle.- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumpointDistance
- inter-point distance- Returns:
- See Also:
-
hexagon
public static List<processing.core.PVector> hexagon(double centerX, double centerY, int length, double distance) Generates a hexagonal grid of points arranged in a hexagon pattern.- Parameters:
centerX
- x coordinate of the hexagon center pointcenterY
- y coordinate of the hexagon center pointlength
- layers/no. of points on each hexagon sidedistance
- inter-point distance
-
ring
public static List<processing.core.PVector> ring(double centerX, double centerY, double innerRadius, double outerRadius, double maxAngle, int n) Generates a set of n points that are randomly distributed on a ring (annulus).- Parameters:
centerX
- x coordinate of the center/mean of the ringcenterY
- x coordinate of the center/mean of the ringinnerRadius
- radius of the ring's holeouterRadius
- outer radius of the ringmaxAngle
- sweep angle of the ring (in radians). Can be negativen
- the number of random points to generate- Returns:
- a list of PVector objects representing the (x, y) coordinates of the random points
- See Also:
-
ring
public static List<processing.core.PVector> ring(double centerX, double centerY, double innerRadius, double outerRadius, double maxAngle, int n, long seed) Generates a set of points that are randomly distributed on a ring (annulus).- Parameters:
centerX
- x coordinate of the center/mean of the ringcenterY
- x coordinate of the center/mean of the ringinnerRadius
- radius of the ring's holeouterRadius
- outer radius of the ringmaxAngle
- angle of the ring (in radians). Can be negativen
- the number of random points to generateseed
- number used to initialize the underlying pseudorandom number generator- Returns:
- a list of PVector objects representing the (x, y) coordinates of the random points
- See Also:
-
poisson
public static List<processing.core.PVector> poisson(double xMin, double yMin, double xMax, double yMax, double minDist) Generates a set of random points (constrained within a rectangular region) via Poisson Disk Sampling.Poisson-disc sampling produces points that are tightly-packed, but no closer to each other than a specified minimum distance, resulting in a more natural and desirable pattern for many applications. This distribution is also described as blue noise.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumminDist
- minimum euclidean distance between any two points- Returns:
- See Also:
-
poisson
public static List<processing.core.PVector> poisson(double xMin, double yMin, double xMax, double yMax, double minDist, long seed) Generates a set of random points (constrained within a rectangular region) via Poisson Disk Sampling, using the specified seed.Poisson-disc sampling produces points that are tightly-packed, but no closer to each other than a specified minimum distance, resulting in a more natural and desirable pattern for many applications. This distribution is also described as blue noise.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumminDist
- minimum euclidean distance between any two pointsseed
- number used to initialize the underlying pseudorandom number generator- Returns:
- See Also:
-
poissonN
public static List<processing.core.PVector> poissonN(double xMin, double yMin, double xMax, double yMax, int n) Generates a poisson point set having N points constrained within a rectangular region using a random seed.Poisson-disc sampling produces points that are tightly-packed, but no closer to each other than a specified minimum distance, resulting in a more natural and desirable pattern for many applications. This distribution is also described as blue noise.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- target size of poisson point set- Returns:
- See Also:
-
poissonN
public static List<processing.core.PVector> poissonN(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a poisson point set having N points constrained within a rectangular region.Poisson-disc sampling produces points that are tightly-packed, but no closer to each other than a specified minimum distance, resulting in a more natural and desirable pattern for many applications. This distribution is also described as blue noise.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- target size of poisson point setseed
- number used to initialize the underlying pseudorandom number generator- Returns:
-
thomasClusters
public static List<processing.core.PVector> thomasClusters(double xMin, double yMin, double xMax, double yMax, double parentsDensity, double meanChildPoints, double childSpread, long seed) Generates random points having clustered properties using the Thomas Point Process.Each cluster consists of child points normally distributed around a parent point.
- Parameters:
xMin
- the minimum x-coordinate of the boundary.yMin
- the minimum y-coordinate of the boundary.xMax
- the maximum x-coordinate of the boundary.yMax
- the maximum y-coordinate of the boundary.parentsDensity
- the density of parent points per unit area (scaled by a factor of 75x75 units).meanChildPoints
- the average number of child points generated per parent point (the actual values are gaussian distributed).childSpread
- the first standard deviation of the distance between each parent point and its children.seed
- number used to initialise the underlying pseudorandom number generator.- Returns:
- a list of PVector objects representing the (x, y) coordinates of the Thomas cluster points
- Since:
- 2.0
-
phyllotaxis
public static List<processing.core.PVector> phyllotaxis(double centerX, double centerY, int n, double radius) Generates a set of points arranged in a phyllotaxis pattern (an arrangement similar to the florets in the head of a sunflower), using the golden ratio (the most irrational number) to position points with the least possible aliasing (which is arguably the "best" arrangement).- Parameters:
centerX
- x coordinate of the center of the point setcenterY
- y coordinate of the center of the point setn
- number of points to generateradius
- radius of circular phyllotaxis extent (max distance of a point from the center position)- Returns:
-
phyllotaxis
public static List<processing.core.PVector> phyllotaxis(double centerX, double centerY, int n, double radius, double theta) Generates a set of points arranged in a phyllotaxis pattern (an arrangement similar to the florets in the head of a sunflower), using a user-defined theta.- Parameters:
centerX
- x coordinate of the center of the point setcenterY
- y coordinate of the center of the point setn
- number of points to generateradius
- radius of circular phyllotaxis extent (max distance of a point from the center position)theta
- angle (in radians) to turn after each point placement- Returns:
-
plasticLDS
public static List<processing.core.PVector> plasticLDS(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on an irrational number (the plastic constant).The plastic LDS has been shown to have superior low discrepancy properties amongst the quasirandom sequences, and is therefore recommended.
Low discrepancy sequences are deterministic (not randomized) number sequences that are low discrepancy - meaning the points tend not to clump together and leave holes; the resulting point set is more evenly spaced than a simple random distribution but less regular than lattices.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
-
plasticJitteredLDS
public static List<processing.core.PVector> plasticJitteredLDS(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on an irrational number. In this method, a random jitter is added to points to give the point set blue-noise-like properties.Low discrepancy sequences are deterministic (not randomized) number sequences that are low discrepancy - meaning the points tend not to clump together and leave holes; the resulting point set is more evenly spaced than a simple random distribution but less regular than lattices.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
- See Also:
-
plasticJitteredLDS
public static List<processing.core.PVector> plasticJitteredLDS(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on an irrational number. In this method, a random jitter is added to points to give the point set blue-noise-like properties.Low discrepancy sequences are deterministic (not randomized) number sequences that are low discrepancy - meaning the points tend not to clump together and leave holes; the resulting point set is more evenly spaced than a simple random distribution but less regular than lattices.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generateseed
- number used to initialize the underlying pseudorandom number generator- Returns:
- See Also:
-
haltonLDS
public static List<processing.core.PVector> haltonLDS(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on a Halton sequence.Low discrepancy sequences are deterministic (not randomized) number sequences that are low discrepancy - meaning the points tend not to clump together and leave holes; the resulting point set is more evenly spaced than a simple random distribution but less regular than lattices.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
-
hammersleyLDS
public static List<processing.core.PVector> hammersleyLDS(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of deterministic stratified points (bounded by a rectangle) from a low discrepancy sequence (LDS) based on a Hammersley sequence.The Hammersley sequence in 2D is just the 1d Van Der Corput sequence on one axis, and regular sampling on the other axis.
Low discrepancy sequences are deterministic (not randomized) number sequences that are low discrepancy - meaning the points tend not to clump together and leave holes; the resulting point set is more evenly spaced than a simple random distribution but less regular than lattices.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
-
nRooksLDS
public static List<processing.core.PVector> nRooksLDS(double xMin, double yMin, double xMax, double yMax, int n) Generates a set of random stratified points (bounded by a rectangle) based on the "N-Rooks" sampling pattern.N-Rooks is a sampling pattern where you treat the boundary as if it were a chess board. Every sampling position is a rook that could move horizontally or vertically, and should be placed such that none of these rooks could capture/"see" any of the other rooks. In other words, every column has a single sample point in it, and every row has a single sample point in it.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
- See Also:
-
nRooksLDS
public static List<processing.core.PVector> nRooksLDS(double xMin, double yMin, double xMax, double yMax, int n, long seed) Generates a set of random stratified points (bounded by a rectangle) based on the "N-Rooks" sampling pattern.N-Rooks is a sampling pattern where you treat the boundary as if it were a chess board. Every sampling position is a rook that could move horizontally or vertically, and should be placed such that none of these rooks could capture/"see" any of the other rooks. In other words, every column has a single sample point in it, and every row has a single sample point in it.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generateseed
- number used to initialize the underlying pseudorandom number generator- Returns:
- See Also:
-
sobolLDS
public static List<processing.core.PVector> sobolLDS(double xMin, double yMin, double xMax, double yMax, int n) Generates a 2D set of deterministic stratified points (bounded by a rectangle) from the Sobol low discrepancy sequence (LDS).A Sobol sequence is a low-discrepancy sequence with the property that for all values of N,its subsequence (x1, ... xN) has a low discrepancy. It can be used to generate pseudo-randompoints in a space S, which are equi-distributed.
- Parameters:
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumn
- number of points to generate- Returns:
- Since:
- 1.4.0
-
minimumSpanningTree
Computes the Euclidean minimum spanning tree (EMST) of a set of points.The EMST is a system of line segments, having only the given points as their endpoints, whose union includes all of the points in a connected set, and which has the minimum possible total length of any such system.
- Parameters:
points
- the set of points over which to compute the EMST- Returns:
- a LINES PShape
- Since:
- 1.3.0
-
findShortestTour
Computes an approximate Traveling Salesman path for the set of points provided. Utilises a heuristic based TSP solver, starting with the farthest insertion method followed by 2-opt heuristic improvements for tour optimization.Note: The algorithm's runtime grows rapidly as the number of points increases. Large datasets (>1000) may result in long computation times and should be used with caution.
Note
concaveHullBFS()
produces a similar result (somewhat longer tours) but is much more performant.- Parameters:
points
- the list of points for which to compute the approximate shortest tour- Returns:
- A closed polygon whose perimeter traces the shortest possible route that visits each point exactly once (and returns to the path's starting point).
- Since:
- 2.0
-
applyRandomWeights
public static List<processing.core.PVector> applyRandomWeights(List<processing.core.PVector> points, double minWeight, double maxWeight) Applies random weights within a specified range to a list of points. The weights are assigned to the z-coordinate of each point using a random number generator with a random seed.- Parameters:
points
- The list of points to which random weights will be applied. Each point's x and y coordinates remain unchanged while the z coordinate is set to the random weight.minWeight
- The minimum weight value (inclusive) that can be assigned to a pointmaxWeight
- The maximum weight value (exclusive) that can be assigned to a point- Returns:
- A new list of points where each point is a copy of the input point with a random weight assigned to its z-coordinate
- Since:
- 2.0
-
applyRandomWeights
public static List<processing.core.PVector> applyRandomWeights(List<processing.core.PVector> points, double minWeight, double maxWeight, long seed) Applies random weights within a specified range to a list of points. The weights are assigned to the z-coordinate of each point using a random number generator with a given fixed seed.- Parameters:
points
- The list of points to which random weights will be applied. Each point's x and y coordinates remain unchanged while the z coordinate is set to the random weight.minWeight
- The minimum weight value (inclusive) that can be assigned to a pointmaxWeight
- The maximum weight value (exclusive) that can be assigned to a pointseed
- seed for the underlying random number generator- Returns:
- A new list of points where each point is a copy of the input point with a random weight assigned to its z-coordinate
- Since:
- 2.0
-