/**
   * Efficiently combines two Disjoint Polygons. Returns false if not disjoint.
   *
   * @param polygon1 ConvexPolygon2d
   * @param polygon2 ConvexPolygon2d
   * @param combinedPolygonToPack ConvexPolygon2d polygon in which we put the convex hull containing
   *     polygon1 and polygon2.
   * @param connectingEdge1ToPack LineSegment2d first connecting edge between polygon1 and polygon2.
   * @param connectingEdge2Topack LineSegment2d second connecting edge between polygon1 and
   *     polygon2.
   * @return true if succeeded, false if failed
   */
  public static boolean combineDisjointPolygons(
      ConvexPolygon2d polygon1,
      ConvexPolygon2d polygon2,
      ConvexPolygon2d combinedPolygonToPack,
      LineSegment2d connectingEdge1ToPack,
      LineSegment2d connectingEdge2Topack) {

    int[][] verticesIndices = new int[2][2];
    boolean success = findConnectingEdgesVerticesIndexes(polygon1, polygon2, verticesIndices);
    if (!success) return false;

    combinedPolygonToPack.clear();
    polygon1.addVerticesInClockwiseOrderInPolygon(
        verticesIndices[0][1], verticesIndices[0][0], combinedPolygonToPack);
    polygon2.addVerticesInClockwiseOrderInPolygon(
        verticesIndices[1][0], verticesIndices[1][1], combinedPolygonToPack);
    combinedPolygonToPack.update();

    packConnectingEdges(
        polygon1, polygon2, connectingEdge1ToPack, connectingEdge2Topack, verticesIndices);

    return true;
  }