Skip to content

Commit

Permalink
Add vertical intersection to Rectangle
Browse files Browse the repository at this point in the history
  • Loading branch information
gabriel-piles committed Dec 17, 2024
1 parent 5d14938 commit f031059
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "pdf-document-layout-analysis"
version = "2024.12.10.1"
version = "2024.12.17.1"
description = "This tool is for PDF document layout analysis"
license = { file = "LICENSE" }
authors = [{ name = "HURIDOCS" }]
Expand Down
10 changes: 10 additions & 0 deletions src/pdf_features/Rectangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ def get_intersection_percentage(self, rectangle: "Rectangle") -> float:

return 100 * (x2 - x1) * (y2 - y1) / self.area()

def get_vertical_intersection(self, rectangle: "Rectangle") -> float:
top = max(self.top, rectangle.top)
bottom = min(self.bottom, rectangle.bottom)

if bottom <= top:
return 0

return bottom - top


def area(self):
return self.width * self.height

Expand Down

0 comments on commit f031059

Please sign in to comment.