Skip to content
Snippets Groups Projects
Commit f9c1d6c2 authored by T.J. Corona's avatar T.J. Corona
Browse files

Changing vtkTriangle::TriangleArea() to use parallelogram method.

This commit is in reference to bug report 0015584. Compared with Heron's
formula for computing the area of a triangle, the cross product method
uses fewer operations and appears to be more accurate for sharp triangles.
parent 6f284f4f
Branches
Tags
No related merge requests found
......@@ -251,11 +251,10 @@ inline void vtkTriangle::TriangleCenter(double p1[3], double p2[3],
//----------------------------------------------------------------------------
inline double vtkTriangle::TriangleArea(double p1[3], double p2[3], double p3[3])
{
double a,b,c;
a = vtkMath::Distance2BetweenPoints(p1,p2);
b = vtkMath::Distance2BetweenPoints(p2,p3);
c = vtkMath::Distance2BetweenPoints(p3,p1);
return (0.25* sqrt(fabs(4.0*a*c - (a-b+c)*(a-b+c))));
double n[3];
vtkTriangle::ComputeNormalDirection(p1,p2,p3,n);
return 0.5*vtkMath::Norm(n);
}
#endif
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment