fix point tris dist
This commit is contained in:
parent
9edb9a5385
commit
f8e26b4890
@ -14,8 +14,7 @@ double pointSegmentDistance(double *p, double *a, double *b, double* direction)
|
|||||||
direction[0] = ap[0];
|
direction[0] = ap[0];
|
||||||
direction[1] = ap[1];
|
direction[1] = ap[1];
|
||||||
direction[2] = ap[2];
|
direction[2] = ap[2];
|
||||||
vtkMath::Normalize(direction);
|
return vtkMath::Normalize(direction);
|
||||||
return vtkMath::Norm(ap, 3);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double h = vtkMath::ClampValue(vtkMath::Dot(ap, ab) / segSqrLength, 0., 1.);
|
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[0] = v[0];
|
||||||
direction[1] = v[1];
|
direction[1] = v[1];
|
||||||
direction[2] = v[2];
|
direction[2] = v[2];
|
||||||
vtkMath::Normalize(direction);
|
return vtkMath::Normalize(direction);
|
||||||
return vtkMath::Norm(v);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
double pointTriangleDistance(double *p, vtkCell *triangle, double *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);
|
double dc = vtkMath::Dot(vecTC, cp);
|
||||||
|
|
||||||
if(da <= 0 && db <= 0 && dc <= 0) {
|
if(da <= 0 && db <= 0 && dc <= 0) {
|
||||||
double na[3] = {
|
double d = vtkMath::Dot(n, ap);
|
||||||
n[0] * a[0],
|
double n2 = vtkMath::Dot(n, n);
|
||||||
n[1] * a[1],
|
|
||||||
n[2] * a[2],
|
|
||||||
};
|
|
||||||
|
|
||||||
double np[3] = {
|
if(d >= 0) {
|
||||||
n[0] * p[0],
|
direction[0] = n[0];
|
||||||
n[1] * p[1],
|
direction[1] = n[1];
|
||||||
n[2] * p[2],
|
direction[2] = n[2];
|
||||||
};
|
} else {
|
||||||
|
direction[0] = -n[0];
|
||||||
double t[3]; vtkMath::Subtract(np, na, t);
|
direction[1] = -n[1];
|
||||||
|
direction[2] = -n[2];
|
||||||
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);
|
|
||||||
|
|
||||||
|
return sqrt(d * d / n2);
|
||||||
} else {
|
} else {
|
||||||
double normalA[3];
|
double normalA[3];
|
||||||
double normalB[3];
|
double normalB[3];
|
||||||
|
Loading…
Reference in New Issue
Block a user