feat: 测试覆盖扩展 + 文档更新

This commit is contained in:
茂之钳
2026-07-23 12:36:39 +00:00
parent 41a8992332
commit f2203c7255
42 changed files with 3448 additions and 106 deletions
+21
View File
@@ -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_;
};