8ae4b86e08
新增: - include/vde/foundation/exact_predicates_gmp.h: GMP 精确谓词 - orient_2d/3d, in_circle 完全精确(mpq_class 有理数) - 零舍入误差,任意精度 - include/vde/foundation/predicates.h: 统一谓词接口 - Predicates<T> 编译期选择后端 - VDE_USE_GMP=ON → GMP, OFF → 自适应 double - 便捷函数: orient(), in_circle() - cmake/FindGMP.cmake: GMP 查找模块 - CMake: -DVDE_USE_GMP=ON 启用 GMP 精确模式 - AdaptiveDouble 包装器: 统一后端接口 使用: cmake -DVDE_USE_GMP=ON .. # 完全精确模式
38 lines
1.3 KiB
C++
38 lines
1.3 KiB
C++
#pragma once
|
|
#include "vde/foundation/math_types.h"
|
|
|
|
namespace vde::foundation::exact {
|
|
|
|
enum class Orientation { Clockwise, CounterClockwise, Collinear };
|
|
enum class CircleTest { Inside, On, Outside };
|
|
|
|
/// Adaptive-precision 2D orientation test (Shewchuk)
|
|
Orientation orient_2d(const Point2D& a, const Point2D& b, const Point2D& c);
|
|
|
|
/// Adaptive-precision 3D orientation test
|
|
Orientation orient_3d(const Point3D& a, const Point3D& b,
|
|
const Point3D& c, const Point3D& d);
|
|
|
|
/// Adaptive-precision in-circle test
|
|
CircleTest in_circle(const Point2D& a, const Point2D& b,
|
|
const Point2D& c, const Point2D& d);
|
|
|
|
} // namespace vde::foundation::exact
|
|
|
|
/// Adaptive double-precision predicates (default backend)
|
|
namespace vde::foundation {
|
|
struct AdaptiveDouble {
|
|
static exact::Orientation orient_2d(const Point2D& a, const Point2D& b, const Point2D& c) {
|
|
return exact::orient_2d(a, b, c);
|
|
}
|
|
static exact::Orientation orient_3d(const Point3D& a, const Point3D& b,
|
|
const Point3D& c, const Point3D& d) {
|
|
return exact::orient_3d(a, b, c, d);
|
|
}
|
|
static exact::CircleTest in_circle(const Point2D& a, const Point2D& b,
|
|
const Point2D& c, const Point2D& d) {
|
|
return exact::in_circle(a, b, c, d);
|
|
}
|
|
};
|
|
} // namespace vde::foundation
|