code: private static final double getCappedOffset(final Point2D p0, final Point2D p2, final Point2D p4, final double offset)
      {
          final double radius = Math.min(p2.sub(p0).getLength(), p2.sub(p4).getLength()) / 2;// it must be half, as there may be another radius on the other side, and they should not cross over.
  
          return ((offset > radius) ? radius : offset);
      }
docs: this will check if the radius needs capping, and return a smaller value if it does