File tree Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Expand file tree Collapse file tree 1 file changed +11
-4
lines changed Original file line number Diff line number Diff line change 2525
2626#include < limits>
2727
28+ #include < geode/basic/logger.hpp>
29+
2830#include < geode/geometry/basic_objects/tetrahedron.hpp>
2931#include < geode/geometry/basic_objects/triangle.hpp>
3032#include < geode/geometry/mensuration.hpp>
@@ -42,7 +44,8 @@ namespace
4244 geode::Vector< dimension >{ point, point_prev }.normalize ();
4345 const auto next =
4446 geode::Vector< dimension >{ point, point_next }.normalize ();
45- const auto angle = std::acos ( prev.dot ( next ) );
47+ const auto dot = std::clamp ( prev.dot ( next ), -1.0 , 1.0 );
48+ const auto angle = std::acos ( dot );
4649 if ( std::isnan ( angle ) )
4750 {
4851 return 0 ;
@@ -272,14 +275,18 @@ namespace geode
272275 const auto point_next = vertices[( v + 1 ) % 3 ].get ();
273276 const auto angle =
274277 compute_angle ( point, point_prev, point_next );
278+ DEBUG ( angle );
275279 sinus[v] = std::sin ( angle );
280+ DEBUG ( sinus[v] );
276281 }
277- const auto quality = 4 * sinus[0 ] * sinus[1 ] * sinus[2 ]
278- / ( sinus[0 ] + sinus[1 ] + sinus[2 ] );
279- if ( std::isnan ( quality ) )
282+ const auto denominator = sinus[0 ] + sinus[1 ] + sinus[2 ];
283+ if ( denominator == 0 )
280284 {
281285 return 0 ;
282286 }
287+ const auto quality =
288+ 4 * sinus[0 ] * sinus[1 ] * sinus[2 ] / ( denominator );
289+ DEBUG ( quality );
283290 return quality;
284291 }
285292 catch ( ... )
You can’t perform that action at this time.
0 commit comments