void generateFirstRect()
    {
        int l1 = Randomiser.intBetweenEven(minLengthR, maxLengthR);
        int l2 = Randomiser.intBetweenEven((int)(l1 * minRatio), (int)(l1 * maxRatio));

        l2 = Randomiser.clampInRange(l2, minLengthR, maxLengthR);
        Vector3 center = Vector3.zero;

        Vector3[] corners = new Vector3[4];
        corners[0]  = center + (Vector3.forward * l1 / 2f) + (Vector3.left * l2 / 2f);
        corners [1] = corners [0] + Vector3.right * l2;
        corners [2] = corners [1] + Vector3.back * l1;
        corners[3]  = corners [2] + Vector3.left * l2;
        RectangleFoundation newRect = new RectangleFoundation(corners, center, l2, l1);

        rectangles.Add(newRect);
        freeEdges.AddRange(newRect.getEdges());
        freeCorners.AddRange(newRect.corners);
        allCorners.AddRange(newRect.corners);
    }
    bool addNewRectangle()
    {
        Edge     curEdge      = freeEdges[Randomiser.intBetween(0, freeEdges.Count / 2)];
        Junction junction     = new Junction(Randomiser.pointOnEdge(curEdge), curEdge.axisDirection);
        Vector3  measurePoint = junction.position + 0.2f * curEdge.axisDirection;

        if (!checkJunction(measurePoint))
        {
            return(false);
        }
        int distanceAlongEdge = Mathf.Min(
            Randomiser.measureDistance(measurePoint, GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2),
            Randomiser.measureDistance(measurePoint, -1 * GenericUtils.rotateClockwise(curEdge.axisDirection), maxLengthR / 2)
            );

        if (distanceAlongEdge * 2 < minLengthR)
        {
            return(false);
        }
        int distanceAlongAxis = Randomiser.measureDistance(measurePoint, curEdge.axisDirection, maxLengthR);

        if (distanceAlongAxis * 2 < minLengthR)
        {
            return(false);
        }
        distanceAlongAxis = Randomiser.clampInRange(distanceAlongAxis, minLengthR, (int)(distanceAlongEdge * 2));
        RectangleFoundation rect = RectangleFromJunction(junction, curEdge.axisDirection, distanceAlongEdge * 2, distanceAlongAxis);

        if (!checkRectangleConsistency(rect))
        {
            rect.delete();
            return(false);
        }
        if (!checkOverlaps(rect))
        {
            rect.delete();
            return(false);
        }
        updateLists(rect, curEdge, junction, rectangles, true, true);
        return(true);
    }
 bool checkRectangleConsistency(RectangleFoundation r)
 {
     return(r.isConsistent(minLengthR, maxLengthR, minRatio, maxRatio));
 }