1. 曲率基本概念
曲率是幾何體不平坦程度的一種衡量。
- 曲線曲率
曲線曲率可以描述曲線的彎曲程度,在曲線方程知道的情況,且二階導存在的情況下(直角坐標系),其值為
\[K=\frac{\left | y^{''} \right | }{(1 + {y^{'}}^{2})^{\frac{3}{2} }} \]
曲率與曲率半徑成倒數關系,如下圖P點的曲率半徑為
\[r = \frac{1}{K} \]
2. 三角網格頂點的曲率
在三角網格模型中,估計頂點曲率經常被用到,可以先估計出該頂點附件的曲面方程,然后再求曲率;也可以直接按照頂點周圍的鄰接關系進行估算。這里記錄一下一些估算曲率的方法。
-
離散方法
三角網格上高斯曲率和平均曲率的計算
三角網格上高斯曲率和平均曲率的計算
相關討論
CurvaNet
TriMesh_curvature 對應論文《Estimating Curvatures and Their Derivatives on Triangle Meshes》
3. 有序離散點曲率近似
根據當前點,找出一點前后距離的點,然后估算出曲率
點擊展開部分代碼
double GetEdgeLength(size_t indx, size_t nextIndex, const std::vector<core::Vector3>& ori, std::vector<double>& edgeLengthArray)
{
if (edgeLengthArray[indx] < 0.0)
{
edgeLengthArray[indx] = (ori[indx] - ori[nextIndex]).Magnitude();
}
return edgeLengthArray[indx];
}
double ComputeNormalizedCurvature(const std::vector<core::Vector3>& ori, size_t indx, std::vector<double>& edgeLengthArray, double neighborSize = 1.8)
{
const core::Vector3& thisPt = ori[indx];
double currentDis = 0.0;
size_t currentIndex = indx;
while (currentDis < neighborSize)
{
size_t nextIndex = currentIndex - 1;
if (currentIndex <= 0) {
return 0.0; // the last
}
currentDis += GetEdgeLength(nextIndex, currentIndex, ori, edgeLengthArray);
currentIndex = nextIndex;
}
const core::Vector3& lastPt = ori[currentIndex];
currentIndex = indx;
currentDis = 0.0;
while (currentDis < neighborSize)
{
size_t nextIndex = currentIndex + 1;
if (nextIndex >= ori.size())
return 0.0; // the last
currentDis += GetEdgeLength(currentIndex, nextIndex, ori, edgeLengthArray);
currentIndex = nextIndex;
}
const core::Vector3& nextPt = ori[currentIndex];
core::Vector3 lineDir = lastPt - nextPt;
double l = lineDir.Magnitude();
lineDir *= 1.0 / l;
double d = core::Distance::PointLine(thisPt, lastPt, lineDir);
return d / l;
}
inline bool IsPeak(double lastValue, double thisValue, double nextValue)
{
return lastValue < thisValue&& nextValue < thisValue;
}
std::vector<double> curvatureArray(ori.size());
std::vector<double> edgeLengthArray(ori.size(), -1.0);
for (size_t i = 0; i <= num; ++i)
{
curvatureArray[i] = ComputeNormalizedCurvature(ori, i, edgeLengthArray, neighborSize);
}