32 lines
1.1 KiB
C#
32 lines
1.1 KiB
C#
namespace CandyboxPlugin.Voronoi
|
|
{
|
|
public class VoronoiPoint
|
|
{
|
|
/// <summary>
|
|
/// Used only for generating a unique ID for each instance of this class that gets generated
|
|
/// </summary>
|
|
private static int _counter;
|
|
|
|
/// <summary>
|
|
/// Used for identifying an instance of a class; can be useful in troubleshooting when geometry goes weird
|
|
/// (e.g. when trying to identify when Triangle objects are being created with the same Point object twice)
|
|
/// </summary>
|
|
private readonly int _instanceId = _counter++;
|
|
|
|
public double X { get; }
|
|
public double Y { get; }
|
|
public HashSet<Triangle> AdjacentTriangles { get; } = new HashSet<Triangle>();
|
|
|
|
public VoronoiPoint(double x, double y)
|
|
{
|
|
X = x;
|
|
Y = y;
|
|
}
|
|
|
|
public override string ToString()
|
|
{
|
|
// Simple way of seeing what's going on in the debugger when investigating weirdness
|
|
return $"{nameof(VoronoiPoint)} {_instanceId} {X:0.##}@{Y:0.##}";
|
|
}
|
|
}
|
|
} |