Maths.PseudoRandom
Central utilities for creating random engines and random collections.
Methods
CirclesOnDiscFibonacci
#Create a circle packing on the interior of a disc.
Parameters:
| disc (Circle) | Disc to populate. |
| count (int) | Number of circles. |
| token (CancellationToken) | Cancellation token. |
CirclesOnDiscHexagonal
#Create a hexagonal pattern of circles with radius 1 around the origin.
Parameters:
| disc (Circle) | |
| count (int) | |
| token (CancellationToken) |
CirclesOnDiscOctagonal
#Create an octogonal pattern of circles with varying radii around the origin.
Parameters:
| disc (Circle) | |
| count (int) | |
| token (CancellationToken) |
CirclesOnDiscSquare
#Create a hexagonal pattern of circles with radius 1 around the origin.
Parameters:
| disc (Circle) | |
| count (int) | |
| token (CancellationToken) |
CirclesOnDiscStacked
#Create a circle packing on the interior of a disc.
Parameters:
| disc (Circle) | Disc to populate. |
| count (int) | Number of circles. |
| token (CancellationToken) | Cancellation token. |
CirclesOnSphericalPoints
#Place circles on point coordinates assumed to lie on a sphere with origin at (0,0,0).
Parameters:
| x (double[]) | Point X coordinates. |
| y (double[]) | Point Y coordinates. |
| z (double[]) | Point A coordinates. |
| token (CancellationToken) | Cancellation token. |
| initialRadius (double = Infinity) | Initial radius to beat. |
Returns: Array of non-intersecting circles.
CreateRandomEngine
#Create a new instance of a specific generator.
Parameters:
| algorithm (Maths.Engine) | Engine to use. The System engine cannot be instantiated this way. |
| seed (int) | Seed value. |
Returns: Non-threadsafe random number generator.
DilatePointsWithinBox
#Dilates the specified array of 3D points outward from a given origin so that all points remain within the defined box dimensions, and retains only the specified number of points closest to the origin after dilation.
Remarks: If the number of points in the array is less than or equal to the specified count, the method does not modify the array. The order of points in the resulting array may differ from the original order.
Parameters:
| points (ref Point3d[]) | A reference to an array of Point3d structures representing the points to be dilated. The array is modified in place to contain only the closest points after dilation. |
| count (int) | The number of points to retain after dilation. Must be less than or equal to the length of the points array. |
| length (Interval) | An Interval that defines the allowable range for the x-coordinates of the box within which the points will be dilated. |
| width (Interval) | An Interval that defines the allowable range for the y-coordinates of the box within which the points will be dilated. |
| height (Interval) | An Interval that defines the allowable range for the z-coordinates of the box within which the points will be dilated. |
| origin (Point3d) | The origin point from which the dilation is performed. Points are scaled outward from this location. |
DilatePointsWithinRectangle
#Spatially inflate an array of points until all but N are outside an axis aligned rectangle.
Parameters:
| points (ref Point2d[]) | Points to scale. |
| count (int) | Number of points to retain. |
| width (Interval) | Width of axis aligned rectangle. |
| height (Interval) | Height of axis aligned rectangle. |
| origin (Point2d) | Scaling origin point. If the origin does not lie within the rectangle, the results cannot be trusted. |
DilatePointsWithinRectangle
#Spatially inflate an array of points until all but N are outside an axis aligned rectangle.
DilatePointsWithinRectangle
#Spatially inflate an array of points until all but N are outside an axis aligned rectangle.
Parameters:
| points (ref Point3d[]) | Points to scale. |
| count (int) | Number of points to retain. |
| width (Interval) | Width of axis aligned rectangle. |
| height (Interval) | Height of axis aligned rectangle. |
| origin (Point3d) | Scaling origin point. If the origin does not lie within the rectangle, the results cannot be trusted. |
DilatePointsWithinSphere
#Dilates a specified number of points within a defined spherical region, scaling their positions relative to a center point.
Remarks: The method performs a partial sort to efficiently determine which points are closest to the center before applying the dilation. It modifies the input array to contain only the dilated points.
Parameters:
| points (ref Point3d[]) | An array of Point3d structures representing the points to be dilated. The method modifies this array to contain only the dilated points. |
| count (int) | The number of points to retain after dilation. Must be less than or equal to the length of the points array. |
| centre (Point3d) | The center point of the sphere around which the dilation occurs. |
| radius (double) | The radius of the sphere within which points will be dilated. Must be a positive value. |
FibonacciHalfSphere
#Generates the coordinates of a Fibonacci point sampling on the upper half of the unit sphere.
FibonacciUnitDisc
#Generates the coordinates of a Fibonacci point sampling on the unit disc.
FibonacciUnitSphere
#Generates the coordinates of a Fibonacci point sampling on the unit sphere.
FibonacciUnitSquare
#Generates the coordinates of a Fibonacci point sampling on the unit square.
FormatEngineAlgorithm
#Create a human-centric string which describes a certain random algorithm.
Parameters:
| algorithm (Maths.Engine) |
ParseEngineAlgorithm
#Try and parse a random engine by name.
Parameters:
| text (string) | |
| engine (out Maths.Engine) |
Poisson2D
#Create a two-dimensional Poisson sampling with a variable separation radius. This algorithm relies on slow spatial lookup of neighbouring coordinates since no assumptions can be made regarding the minimum allowed spacing across the entire field. As a result this method probably will not yield the same distribution as the Poisson2D method which takes a constant radius value.
Parameters:
| engine (Random) | Random engine. |
| setup (Maths.PseudoRandom.PoissonSetup) | Properties for poisson distribution. |
| density (Func<Point2d, double>) | Minimum allowed distance between samples. This function will be sampled and obeyed locally. It is entirely possible that a point pair exists in the final distribution closer together than one of the points local radius constraint. |
Returns: An array of two-dimensional coordinates within the (min, max) region.
Poisson2D
#Create a two-dimensional Poisson sampling with a constant separation radius.
Parameters:
| engine (Random) | Random engine. |
| setup (Maths.PseudoRandom.PoissonSetup) | Properties for poisson distribution. |
Returns: An array of two-dimensional coordinates within the (min, max) region, no two of which are closer than the specified radius.
Populate1D
#Randomly populate a one-dimensional interval. This method works by randomly dividing the longest remaining interval into two until a fixed number of values has been found.
Parameters:
| engine (Random) | Random engine to use. |
| min (double) | Lower limit. |
| max (double) | Upper limit. |
| count (int) | Number of values to create. |
| spread (double) | Spreading factor (0, 1). Zero equals splitting exactly in the middle, one equals splitting within the full domain. |
Returns: An array of numbers between min and max.
RandomIntegers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
| lowerInclusive (int) | Lower inclusive limit. |
| upperExclusive (int) | Upper exclusive limit. |
Returns: Infinite collection of random integers.
RandomIntegers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
Returns: Infinite collection of random integers.
RandomIntegers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
| count (int) | Amount of random numbers to generate. |
| lowerInclusive (int) | Lower inclusive limit. |
| upperExclusive (int) | Upper exclusive limit. |
Returns: Infinite collection of random integers.
RandomIntegers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
| count (int) | Amount of random numbers to generate. |
Returns: Infinite collection of random integers.
RandomNumbers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
| count (int) | Amount of random numbers to generate. |
| lower (double) | Lower limit. |
| upper (double) | Upper limit. |
Returns: Infinite collection of random integers.
RandomNumbers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
| count (int) | Amount of random numbers to generate. |
Returns: Infinite collection of random integers.
RandomNumbers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
| lower (double) | Lower limit. |
| upper (double) | Upper limit. |
Returns: Infinite collection of random integers.
RandomNumbers
#Generate an enumeration of random, non-negative integers.
Parameters:
| engine (Maths.Engine) | Engine to use. |
| seed (int) | Initial seed value. |
Returns: Infinite collection of random integers.
VanDerCorputUnitCube
#Create a Van Der Corput distribution within the unit cube.
VanDerCorputUnitSquare
#Generates the coordinates of a van der Corput Quasi random point set on the unit square. The distances between adjacent points are more similar than using a strict pseudo-random distribution, not quite as good as a Poisson distribution but very fast. The x coordinates increase steadily from zero to (n-1)/n, whereas the associated y coordinates are spread out using a quasi-mote-carlo pattern.