using System.Numerics;
using System.Collections.Immutable;
namespace NaturalNeighbor
{
///
/// Represents a cell from Voronoi diagram
///
public class VoronoiFacet
{
///
/// Constructs a new facet instance
///
/// Node id
/// Node location on XY pane
/// Perimieter of the voronoi cell forming a convex polygon. Points are arranged counterclockwise
public VoronoiFacet(NodeId id, Vector2 center, ImmutableArray vertices)
{
Id = id;
Center = center;
Vertices = vertices;
}
///
/// Constructs an empty facet
///
///
///
public VoronoiFacet(NodeId id, Vector2 center)
{
Id = id;
Center = center;
Vertices = ImmutableArray.Empty;
}
///
/// Area of the polygon formed by the vertices
///
public double Area => Internal.Utils.ComputePolygonArea2(Vertices) * 0.5;
///
/// True if facet is outide of a voronoy diagram boundaries
///
public bool IsVirtual => Vertices.IsDefaultOrEmpty;
///
/// ID of the node representing the center coordinate
///
public NodeId Id { get; }
///
/// Node position on XY plane
///
public Vector2 Center { get; }
///
/// Vertices of the polygon forming the facet perimeter sorted counterclockwise
///
public ImmutableArray Vertices { get; }
}
}