fix point tris dist

This commit is contained in:
CookieKastanie 2022-03-08 16:59:06 +01:00
parent 9edb9a5385
commit f8e26b4890

View File

@ -14,8 +14,7 @@ double pointSegmentDistance(double *p, double *a, double *b, double* direction)
direction[0] = ap[0];
direction[1] = ap[1];
direction[2] = ap[2];
vtkMath::Normalize(direction);
return vtkMath::Norm(ap, 3);
return vtkMath::Normalize(direction);
}
double h = vtkMath::ClampValue(vtkMath::Dot(ap, ab) / segSqrLength, 0., 1.);
@ -26,8 +25,7 @@ double pointSegmentDistance(double *p, double *a, double *b, double* direction)
direction[0] = v[0];
direction[1] = v[1];
direction[2] = v[2];
vtkMath::Normalize(direction);
return vtkMath::Norm(v);
return vtkMath::Normalize(direction);
}
double pointTriangleDistance(double *p, vtkCell *triangle, double *direction) {
@ -53,33 +51,20 @@ double pointTriangleDistance(double *p, vtkCell *triangle, double *direction) {
double dc = vtkMath::Dot(vecTC, cp);
if(da <= 0 && db <= 0 && dc <= 0) {
double na[3] = {
n[0] * a[0],
n[1] * a[1],
n[2] * a[2],
};
double np[3] = {
n[0] * p[0],
n[1] * p[1],
n[2] * p[2],
};
double t[3]; vtkMath::Subtract(np, na, t);
double nt[3] = {
n[0] * t[0],
n[1] * t[1],
n[2] * t[2],
};
direction[0] = nt[0];
direction[1] = nt[1];
direction[2] = nt[2];
vtkMath::Normalize(direction);
return vtkMath::Norm(nt);
double d = vtkMath::Dot(n, ap);
double n2 = vtkMath::Dot(n, n);
if(d >= 0) {
direction[0] = n[0];
direction[1] = n[1];
direction[2] = n[2];
} else {
direction[0] = -n[0];
direction[1] = -n[1];
direction[2] = -n[2];
}
return sqrt(d * d / n2);
} else {
double normalA[3];
double normalB[3];