distance is now signed
This commit is contained in:
parent
c34d0d31d9
commit
7e9d928af1
@ -52,6 +52,8 @@ double pointTriangleDistance(double *p, vtkCell *triangle, double *direction) {
|
|||||||
double db = vtkMath::Dot(vecTB, bp);
|
double db = vtkMath::Dot(vecTB, bp);
|
||||||
double dc = vtkMath::Dot(vecTC, cp);
|
double dc = vtkMath::Dot(vecTC, cp);
|
||||||
|
|
||||||
|
double distance = 0;
|
||||||
|
|
||||||
if(da <= 0 && db <= 0 && dc <= 0) {
|
if(da <= 0 && db <= 0 && dc <= 0) {
|
||||||
double na[3] = {
|
double na[3] = {
|
||||||
n[0] * a[0],
|
n[0] * a[0],
|
||||||
@ -78,7 +80,7 @@ double pointTriangleDistance(double *p, vtkCell *triangle, double *direction) {
|
|||||||
direction[1] = nt[1];
|
direction[1] = nt[1];
|
||||||
direction[2] = nt[2];
|
direction[2] = nt[2];
|
||||||
vtkMath::Normalize(direction);
|
vtkMath::Normalize(direction);
|
||||||
return vtkMath::Norm(nt);
|
distance = vtkMath::Norm(nt);
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
double normalA[3];
|
double normalA[3];
|
||||||
@ -105,6 +107,16 @@ double pointTriangleDistance(double *p, vtkCell *triangle, double *direction) {
|
|||||||
direction[2] = normalC[2];
|
direction[2] = normalC[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
return min;
|
distance = min;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(vtkMath::Dot(direction, n) < 0) {
|
||||||
|
direction[0] = -direction[0];
|
||||||
|
direction[1] = -direction[1];
|
||||||
|
direction[2] = -direction[2];
|
||||||
|
|
||||||
|
return -distance;
|
||||||
|
} else {
|
||||||
|
return distance;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user