diff --git a/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs b/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs
index a961ff171..ecaa610b9 100644
--- a/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs
+++ b/src/UglyToad.PdfPig/DocumentLayoutAnalysis/RecursiveXYCut.cs
@@ -11,7 +11,7 @@ namespace UglyToad.PdfPig.DocumentLayoutAnalysis
/// https://en.wikipedia.org/wiki/Recursive_X-Y_cut
/// See 'Recursive X-Y Cut using Bounding Boxes of Connected Components' by Jaekyu Ha, Robert M.Haralick and Ihsin T. Phillips
///
- public class RecursiveXYCut
+ public static class RecursiveXYCut
{
///
/// Get the blocks.
diff --git a/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs b/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs
index df8e985b4..d658653a7 100644
--- a/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs
+++ b/src/UglyToad.PdfPig/Geometry/PdfRectangle.cs
@@ -30,6 +30,11 @@ public struct PdfRectangle
///
public PdfPoint BottomLeft { get; }
+ ///
+ /// Centroid point of the rectangle.
+ ///
+ public PdfPoint Centroid { get; }
+
///
/// Width of the rectangle.
///
@@ -105,15 +110,14 @@ public PdfRectangle(decimal x1, decimal y1, decimal x2, decimal y2)
BottomLeft = new PdfPoint(left, bottom);
BottomRight = new PdfPoint(right, bottom);
+
+ Centroid = new PdfPoint(left + (right - left) / 2, bottom + (top - bottom) / 2);
}
internal PdfRectangle(PdfVector topLeft, PdfVector topRight, PdfVector bottomLeft, PdfVector bottomRight)
+ : this(topLeft.ToPoint(), topRight.ToPoint(), bottomLeft.ToPoint(), bottomRight.ToPoint())
{
- TopLeft = topLeft.ToPoint();
- TopRight = topRight.ToPoint();
- BottomLeft = bottomLeft.ToPoint();
- BottomRight = bottomRight.ToPoint();
}
internal PdfRectangle(PdfPoint topLeft, PdfPoint topRight, PdfPoint bottomLeft, PdfPoint bottomRight)
@@ -123,6 +127,8 @@ internal PdfRectangle(PdfPoint topLeft, PdfPoint topRight, PdfPoint bottomLeft,
BottomLeft = bottomLeft;
BottomRight = bottomRight;
+
+ Centroid = new PdfPoint(topLeft.X + (topRight.X - topLeft.X) / 2, bottomLeft.Y + (topLeft.Y - bottomLeft.Y) / 2);
}
///