computeHorizon method

ConvexHull computeHorizon(
  1. dynamic eyePoint,
  2. dynamic crossEdge,
  3. Face2 face,
  4. dynamic horizon,
)

Implementation

ConvexHull computeHorizon(eyePoint, crossEdge, Face2 face, horizon) {
  // moves face's vertices to the 'unassigned' vertex list

  deleteFace2Vertices(face, null);

  face.mark = deleted;

  HalfEdge? edge;

  if (crossEdge == null) {
    edge = crossEdge = face.getEdge(0);
  } else {
    // start from the next edge since 'crossEdge' was already analyzed
    // (actually 'crossEdge.twin' was the edge who called this method recursively)

    edge = crossEdge.next;
  }

  do {
    final twinEdge = edge?.twin;
    final oppositeFace2 = twinEdge!.face;

    if (oppositeFace2.mark == visible) {
      if (oppositeFace2.distanceToPoint(eyePoint) > tolerance) {
        // the opposite face can see the vertex, so proceed with next edge

        computeHorizon(eyePoint, twinEdge, oppositeFace2, horizon);
      } else {
        // the opposite face can't see the vertex, so this edge is part of the horizon

        horizon.add(edge);
      }
    }

    edge = edge?.next;
  } while (edge != crossEdge);

  return this;
}