createdSortedEdges method

List<Edge> createdSortedEdges(
  1. List<PointD> vertices
)

Implementation

List<Edge> createdSortedEdges(List<PointD> vertices) {
  // Create sorted edges table
  List<Edge> edges = [];
  for (int i = 0; i < vertices.length - 1; i++) {
    PointD p1 = vertices[i];
    PointD p2 = vertices[i + 1];
    if (p1.y != p2.y) {
      double yMin = min(p1.y, p2.y);
      edges.add(Edge(
        yMin: yMin,
        yMax: max(p1.y, p2.y),
        x: yMin == p1.y ? p1.x : p2.x,
        slope: (p2.x - p1.x) / (p2.y - p1.y),
      ));
    }
  }
  edges.sort(edgeSorter);
  return edges;
}