#pragma once #include "vde/foundation/math_types.h" #include "vde/foundation/tolerance.h" #include /** * @defgroup core 核心几何模块 * * 核心模块提供 VDE 引擎的几何操作 API: * - 基础几何体(AABB、直线、射线、线段、平面、三角形、多边形) * - 几何计算(距离、最近点、凸包、变换) * - 点云配准(ICP) * - Voronoi 图 * * @{ */ namespace vde::core { /** * @brief 通用 N 维点类型(重新导出,便于 core 模块使用) * * @tparam T 标量类型 * @tparam Dim 维度 */ template using Point = foundation::Point; /// 双精度二维点(重新导出) using Point2D = foundation::Point2D; /// 双精度三维点(重新导出) using Point3D = foundation::Point3D; /// 单精度二维点(重新导出) using Point2f = foundation::Point2f; /// 单精度三维点(重新导出) using Point3f = foundation::Point3f; /** * @brief 通用 N 维向量类型(重新导出) * * @tparam T 标量类型 * @tparam Dim 维度 */ template using Vector = foundation::Vector; /// 双精度二维向量(重新导出) using Vector2D = foundation::Vector2D; /// 双精度三维向量(重新导出) using Vector3D = foundation::Vector3D; // ═══════════════════════════════════════════════ // VDE-491: as_array / from_array 自由函数 // // Point3D / Vector3D 是 Eigen::Matrix 的别名, // 不能添加成员函数。改用 inline 自由函数提供与 std::array // 的互操作,便于序列化、C 接口绑定和跨语言互操作。 // // 注意:Point2D 和 Vector2D 是同一类型(均 = Eigen::Matrix), // Point3D 和 Vector3D 同理。因此 as_array/from_array 对两者通用。 // ═══════════════════════════════════════════════ /// 将 Point2D/Vector2D 转换为 std::array [[nodiscard]] inline std::array as_array(const Point2D& p) { return {p.x(), p.y()}; } /// 将 std::array 转换为 Point2D/Vector2D [[nodiscard]] inline Point2D from_array(const std::array& a) { return Point2D(a[0], a[1]); } /// 将 Point3D/Vector3D 转换为 std::array [[nodiscard]] inline std::array as_array(const Point3D& p) { return {p.x(), p.y(), p.z()}; } /// 将 std::array 转换为 Point3D/Vector3D [[nodiscard]] inline Point3D from_array(const std::array& a) { return Point3D(a[0], a[1], a[2]); } } // namespace vde::core /** @} */ // end of core group