public final class PGS_PointSet extends Object
Modifier and Type | Method and Description |
---|---|
static List<List<processing.core.PVector>> |
cluster(Collection<processing.core.PVector> points,
int groups)
Clusters points into N groups, using k-means clustering.
|
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.
|
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,
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
the
distanceTolerance of each other. |
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 processing.core.PVector |
weightedMedian(Collection<processing.core.PVector> points)
Finds the geometric median point of a set of weighted sample points.
|
public static List<processing.core.PVector> prunePointsWithinDistance(List<processing.core.PVector> points, double distanceTolerance)
distanceTolerance
of each other.
This method can be used to convert a random point set into a blue-noise-like (poisson) point set.
points
- list of points to filterdistanceTolerance
- a point that is within this distance of a previously
included point is not included in the outputpublic static List<processing.core.PVector> hilbertSort(List<processing.core.PVector> points)
points
- list of points to sort. a list requires at least 24 points to
be sorted.public static List<List<processing.core.PVector>> cluster(Collection<processing.core.PVector> points, int groups)
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.
points
- list of points to clustergroups
- desired number of clustered groupscluster(Collection, int, long)
public static List<List<processing.core.PVector>> cluster(Collection<processing.core.PVector> points, int groups, long seed)
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.
points
- list of points to clustergroups
- desired number of clustered groupsseed
- random seedcluster(Collection, int)
public static processing.core.PVector weightedMedian(Collection<processing.core.PVector> 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).
points
- list of points, where the z coordinate is point weightpublic static List<processing.core.PVector> random(double xMin, double yMin, double xMax, double yMax, int n)
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 generateseeded random()
public static List<processing.core.PVector> random(double xMin, double yMin, double xMax, double yMax, int n, long seed)
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
generatornon-seeded random()
public static List<processing.core.PVector> gaussian(double centerX, double centerY, double sd, int n)
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 generateseeded gaussian()
public static List<processing.core.PVector> gaussian(double centerX, double centerY, double sd, int n, long seed)
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
generatornon-seeded gaussian()
public static List<processing.core.PVector> squareGrid(double xMin, double yMin, double xMax, double yMax, double pointDistance)
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumpublic static List<processing.core.PVector> hexGrid(double xMin, double yMin, double xMax, double yMax, int n)
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 generatehexGrid() where
inter-point distance is specified
public static List<processing.core.PVector> hexGrid(double xMin, double yMin, double xMax, double yMax, double pointDistance)
xMin
- x-coordinate of boundary minimumyMin
- y-coordinate of boundary minimumxMax
- x-coordinate of boundary maximumyMax
- y-coordinate of boundary maximumpointDistance
- inter-point distancehexGrid() where number of
points is specified
public static List<processing.core.PVector> hexagon(double centerX, double centerY, int length, double distance)
centerX
- x coordinate of the hexagon center pointcenterY
- y coordinate of the hexagon center pointlength
- layers/no. of points on each hexagon sidepublic static List<processing.core.PVector> ring(double centerX, double centerY, double innerRadius, double outerRadius, double maxAngle, int n)
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 generateseeded ring()
public static List<processing.core.PVector> ring(double centerX, double centerY, double innerRadius, double outerRadius, double maxAngle, int n, long seed)
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 generatornon-seeded ring()
public static List<processing.core.PVector> poisson(double xMin, double yMin, double xMax, double yMax, double minDist)
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.
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 pointsseeded poisson()
public static List<processing.core.PVector> poisson(double xMin, double yMin, double xMax, double yMax, double minDist, long 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.
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
generatornon-seeded poisson()
public static List<processing.core.PVector> poissonN(double xMin, double yMin, double xMax, double yMax, int n, long 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.
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
generatorpublic static List<processing.core.PVector> phyllotaxis(double centerX, double centerY, int n, double radius)
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)public static List<processing.core.PVector> phyllotaxis(double centerX, double centerY, int n, double radius, double theta)
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 placementpublic static List<processing.core.PVector> plasticLDS(double xMin, double yMin, double xMax, double yMax, int n)
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.
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 generatepublic static List<processing.core.PVector> plasticJitteredLDS(double xMin, double yMin, double xMax, double yMax, int n)
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.
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 generateseeded
irrationalJitteredLDS()
public static List<processing.core.PVector> plasticJitteredLDS(double xMin, double yMin, double xMax, double yMax, int n, long seed)
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.
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
generatornon-seeded
irrationalJitteredLDS()
public static List<processing.core.PVector> haltonLDS(double xMin, double yMin, double xMax, double yMax, int n)
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.
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 generatepublic static List<processing.core.PVector> hammersleyLDS(double xMin, double yMin, double xMax, double yMax, int n)
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.
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 generatepublic static List<processing.core.PVector> nRooksLDS(double xMin, double yMin, double xMax, double yMax, int n)
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.
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 generatenRooksLDS(double, double, double, double, int, long)
public static List<processing.core.PVector> nRooksLDS(double xMin, double yMin, double xMax, double yMax, int n, long seed)
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.
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
generatornRooksLDS(double, double, double, double, int)
public static List<processing.core.PVector> sobolLDS(double xMin, double yMin, double xMax, double yMax, int n)
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.
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 generatepublic static processing.core.PShape minimumSpanningTree(List<processing.core.PVector> 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.
points
- the set of points over which to compute the EMSTCopyright © 2023. All rights reserved.