feat: 测试覆盖扩展 + 文档更新
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
#pragma once
|
||||
#include "vde/core/point.h"
|
||||
#include "vde/core/aabb.h"
|
||||
#include <vector>
|
||||
#include <array>
|
||||
|
||||
namespace vde::core {
|
||||
|
||||
@@ -19,12 +21,31 @@ public:
|
||||
/// Absolute area
|
||||
[[nodiscard]] double area() const { return std::abs(signed_area()); }
|
||||
|
||||
/// Perimeter (sum of edge lengths)
|
||||
[[nodiscard]] double perimeter() const;
|
||||
|
||||
/// Area-weighted centroid
|
||||
[[nodiscard]] Point2D centroid() const;
|
||||
|
||||
/// Axis-aligned bounding box (2D, stored in AABB3D with z=0)
|
||||
[[nodiscard]] AABB<double> bounding_box() const;
|
||||
|
||||
/// Point-in-polygon test (ray casting)
|
||||
[[nodiscard]] bool contains(const Point2D& p) const;
|
||||
|
||||
/// Is the polygon counter-clockwise?
|
||||
[[nodiscard]] bool is_ccw() const { return signed_area() > 0; }
|
||||
|
||||
/// Douglas-Peucker simplification. Returns a new simplified polygon.
|
||||
[[nodiscard]] Polygon2D simplify(double tolerance) const;
|
||||
|
||||
/// Ear-clipping triangulation. Returns triangles as triples of vertex indices.
|
||||
/// Assumes a simple polygon (no self-intersections). CCW ordering required.
|
||||
[[nodiscard]] std::vector<std::array<int, 3>> triangulate() const;
|
||||
|
||||
/// Andrew's monotone chain convex hull of a point set.
|
||||
static Polygon2D convex_hull_2d(const std::vector<Point2D>& points);
|
||||
|
||||
private:
|
||||
std::vector<Point2D> vertices_;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user