Always normalize normal vector, for safety

master
Marius Kintel 2015-01-13 18:51:00 -05:00
parent e1c62ea152
commit cd8607d87d
1 changed files with 4 additions and 4 deletions

View File

@ -107,9 +107,9 @@ namespace CGALUtils {
else {
// Calculate best guess at face normal using Newell's method
CGAL::normal_vector_newell_3(polygons.front().begin(), polygons.front().end(), normalvec);
double sqrl = normalvec.squared_length();
if (sqrl > 0.0) normalvec = normalvec / sqrt(sqrl);
}
double sqrl = normalvec.squared_length();
if (sqrl > 0.0) normalvec = normalvec / sqrt(sqrl);
// Pass the normal vector to the (undocumented)
// CGAL::Triangulation_2_filtered_projection_traits_3. This
@ -164,9 +164,9 @@ namespace CGALUtils {
else {
// Calculate best guess at face normal using Newell's method
CGAL::normal_vector_newell_3(polygon.begin(), polygon.end(), normalvec);
double sqrl = normalvec.squared_length();
if (sqrl > 0.0) normalvec = normalvec / sqrt(sqrl);
}
double sqrl = normalvec.squared_length();
if (sqrl > 0.0) normalvec = normalvec / sqrt(sqrl);
// Pass the normal vector to the (undocumented)
// CGAL::Triangulation_2_filtered_projection_traits_3. This