[vtk-developers] [VTK 0011988]: vtkPolygon::ComputeNormal returns wrong directed normal if polygon has more concave than convex vertices
Mantis Bug Tracker
mantis at public.kitware.com
Fri Mar 18 17:56:11 EDT 2011
The following issue has been SUBMITTED.
======================================================================
http://public.kitware.com/Bug/view.php?id=11988
======================================================================
Reported By: Ronald Römer
Assigned To:
======================================================================
Project: VTK
Issue ID: 11988
Category: (No Category)
Reproducibility: always
Severity: minor
Priority: normal
Status: new
======================================================================
Date Submitted: 2011-03-18 17:56 EDT
Last Modified: 2011-03-18 17:56 EDT
======================================================================
Summary: vtkPolygon::ComputeNormal returns wrong directed
normal if polygon has more concave than convex vertices
Description:
Hello,
the methods in vtkPolygon that are purposed for computing the normal of a
polygon does not work, if the polygon has more concave than convex vertices. The
normal there is an average from all cross-products, that cause a wrong sign of
the normal. In Graphics Gems III there is an interesting method from Nevell,
that should replace the actual versions of ComputeNormal. A lite version,
without optimation for triangles, I provide below:
void ComputeNormal(vtkPoints *pts, vtkIdList *poly, double *n) {
n[0] = 0; n[1] = 0; n[2] = 0;
double pt0[3], pt1[3];
pts->GetPoint(poly->GetId(0), pt0);
unsigned int nbr = poly->GetNumberOfIds();
for(unsigned int i = 0; i < nbr; i++) {
pts->GetPoint(poly->GetId((i+1)%nbr), pt1);
n[0] += (pt0[1]-pt1[1])*(pt0[2]+pt1[2]);
n[1] += (pt0[2]-pt1[2])*(pt0[0]+pt1[0]);
n[2] += (pt0[0]-pt1[0])*(pt0[1]+pt1[1]);
pt0[0] = pt1[0];
pt0[1] = pt1[1];
pt0[2] = pt1[2];
}
vtkMath::Normalize(n);
}
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2011-03-18 17:56 Ronald Römer New Issue
======================================================================
More information about the vtk-developers
mailing list