Files
ViewDesignEngine/include/vde/mesh/geodesic.h
T
茂之钳 4c9ee4f760
CI / Build & Test (push) Failing after 29s
CI / Release Build (push) Failing after 38s
docs: doxygen annotations for curves + mesh + sketch
2026-07-24 11:04:04 +00:00

41 lines
1.4 KiB
C++

#pragma once
#include "vde/mesh/halfedge_mesh.h"
#include <vector>
namespace vde::mesh {
using core::Point2D;
using core::Point3D;
using core::Vector3D;
/**
* @brief 热方法(Heat Method)计算测地距离
*
* 基于 Crane et al. 2013 的算法,通过求解三个线性系统高效计算
* 曲面上任意点到源点集的测地距离(Geodesic Distance)。
*
* 算法三步:
* 1. 热扩散:求解 (I - t·L)·u = u₀,其中 u₀ 在源点为 1 其余为 0
* 2. 梯度归一化:X = -∇u / |∇u|
* 3. 泊松重建:L·φ = div(X),得到测地距离 φ
*
* 相比精确测地线算法(如 MMP),热方法更快(~线性时间)且易于实现,
* 但精度受时间步长 t 和网格分辨率影响。
*
* @param mesh 输入三角网格
* @param sources 源顶点索引列表(距离为 0 的顶点)
* @param t 时间步长,< 0 时自动设为平均边长平方
* @return 每顶点到最近源点的测地距离
*
* @note 要求网格为连通流形;时间步长 t 越小精度越高但数值越不稳定
* @code{.cpp}
* auto dist = geodesic_distance(mesh, {0, 10, 20});
* // dist[i] = 顶点 i 到 {0,10,20} 中最近顶点的测地距离
* @endcode
* @ingroup mesh
*/
std::vector<double> geodesic_distance(const HalfedgeMesh& mesh,
const std::vector<int>& sources,
double t = -1.0);
} // namespace vde::mesh