Skip to content

Commit

Permalink
MultiPolygonにarea()とperimeter()を追加(#1185)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogame3334 committed Jan 17, 2024
1 parent 99e3a4a commit a9e41f9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Siv3D/include/Siv3D/MultiPolygon.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,12 @@ namespace s3d

MultiPolygon& scaleAt(Vec2 pos, Vec2 s);

[[nodiscard]]
double area() const noexcept;

[[nodiscard]]
double perimeter() const noexcept;

[[nodiscard]]
RectF computeBoundingRect() const noexcept;

Expand Down
20 changes: 20 additions & 0 deletions Siv3D/src/Siv3D/MultiPolygon/SivMultiPolygon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,26 @@ namespace s3d
return *this;
}

double MultiPolygon::area() const noexcept
{
double total = 0;
for (const auto& polygon : *this)
{
total += polygon.area();
}
return total;
}

double MultiPolygon::perimeter() const noexcept
{
double total = 0;
for (const auto& polygon : *this)
{
total += polygon.perimeter();
}
return total;
}

RectF MultiPolygon::computeBoundingRect() const noexcept
{
if (isEmpty())
Expand Down

0 comments on commit a9e41f9

Please sign in to comment.