Class CircleDistributionCircleLine
Helper class for distributing points evenly on a circle. Uses a modified version of Lloyd's algorithm. The random number generator used by the algorithm is reset on every call so that the results are deterministic.
Inheritance
Namespace: AS2.Visuals
Assembly: .dll
Syntax
public static class CircleDistributionCircleLine
Fields
| Edit this page View SourcenewPoints
Declaration
private static List<float> newPoints
Field Value
Type | Description |
---|---|
List<float> |
points
Declaration
private static List<float> points
Field Value
Type | Description |
---|---|
List<float> |
rng
Declaration
private static RandomNumberGenerator rng
Field Value
Type | Description |
---|---|
RandomNumberGenerator |
rng_seed
Declaration
private const int rng_seed = 42
Field Value
Type | Description |
---|---|
int |
Methods
| Edit this page View SourceDistributePointsOnCircle(List<float>, float, float, float)
Spreads the given points on a circle such that they have a minimum distance to each other while staying close to their original position. Uses a modified version of Lloyd's algorithm.
Declaration
public static bool DistributePointsOnCircle(List<float> inputOutputDegreeList, float minDistanceBetweenPoints, float interationMovementTowardsCenterPercentage = 0.1, float maxMovementPerInteraction = 360)
Parameters
Type | Name | Description |
---|---|---|
List<float> | inputOutputDegreeList | A list of angles describing the points. The final result will be stored in this list as well. |
float | minDistanceBetweenPoints | The minimum angular distance between any two points that should be achieved. |
float | interationMovementTowardsCenterPercentage | Factor controlling how far a point should move away from its closest neighbor in one interaction. Smaller values are generally more stable but may require more iterations. |
float | maxMovementPerInteraction | The maximum angular distance a point can move in one interaction. |
Returns
Type | Description |
---|---|
bool |
|
NormalizeDegree0To360(float)
Shifts the given angle to the range between 0 and 360 degrees.
Declaration
private static float NormalizeDegree0To360(float degree)
Parameters
Type | Name | Description |
---|---|---|
float | degree | The angle to be normalized in degrees. |
Returns
Type | Description |
---|---|
float | The angle described by |
RelativeDistanceBetweenPoints(float, float)
Computes the negative counter-clockwise angle from
point2
to point1
.
Declaration
private static float RelativeDistanceBetweenPoints(float point1, float point2)
Parameters
Type | Name | Description |
---|---|---|
float | point1 | The angle of the first point. |
float | point2 | The angle of the second point. |
Returns
Type | Description |
---|---|
float | The counter-clockwise angle from |
RelativeDistanceBetweenPoints_Clockwise(float, float)
Computes the clockwise distance from point1
to point2
.
Declaration
private static float RelativeDistanceBetweenPoints_Clockwise(float point1, float point2)
Parameters
Type | Name | Description |
---|---|---|
float | point1 | The angle of the first point. |
float | point2 | The angle of the second point. |
Returns
Type | Description |
---|---|
float | The clockwise angle from |
RelativeDistanceBetweenPoints_CounterClockwise(float, float)
Computes the counter-clockwise distance from point1
to point2
.
Declaration
private static float RelativeDistanceBetweenPoints_CounterClockwise(float point1, float point2)
Parameters
Type | Name | Description |
---|---|---|
float | point1 | The angle of the first point. |
float | point2 | The angle of the second point. |
Returns
Type | Description |
---|---|
float | The counter-clockwise angle from |