我正在尝试使用C#实现Bentley-Ottmann算法,该算法在此处有描述。 特别地,在扫描线状态结构中为Segment类实现IComparable<T>时遇到了问题。下面是段类的列表:
public class SweepLineSegment : IComparable<SweepLineSegment>
{
public int Edge { get; set; }
public PointF LeftmostVertexPoint { get; set; }
public PointF RightmostVertexPoint { get; set; }
public SweepLineSegment Above { get; set; }
public SweepLineSegment Below { get; set;}
public int CompareTo(SweepLineSegment other)
{
?????
}
}
我不太清楚在将两个线段添加到扫描线状态结构中时应该如何进行比较。
注:扫描线算法是计算机科学中的一种算法,可以用于解决许多几何问题。