@@ -354,37 +354,23 @@ class Segment_2_Segment_2_pair {
354354};
355355
356356
357- // code generated using Herbie https://herbie.uwplse.org/
358357inline
359358double s2s2_alpha (double x0, double y0,
360359 double x1, double y1,
361360 double x2, double y2,
362361 double x3, double y3)
363362{
364- double tmp;
365- if (x1 <= -9.794158788366665e-11 ) {
366- tmp = -(x1 / (x0 - x1));
367- } else {
368- double t_0 = (y1 - y3) / (y1 - y0);
369- double tmp_1;
370- if (x1 <= -1.7579125018815487e-296 ) {
371- tmp_1 = t_0;
372- } else if (x1 <= 1.7250761038378636e-206 ) {
373- tmp_1 = x2 / ((std::fma (x2, y0, std::fma (y3, x0, (x1 * y2))) - std::fma (x2, y1, std::fma (y3, x1, (x0 * y2)))) / (y3 - y1));
374- } else if (x1 <= 3.6888389969707494e-205 ) {
375- tmp_1 = t_0;
376- } else if (x1 <= 1.4339509931401463e-80 ) {
377- tmp_1 = (std::fma (x1, y2, std::fma (y1, x3, (y3 * x2))) - std::fma (x2, y1, std::fma (x1, y3, (y2 * x3)))) / std::fma ((x3 - x2), (y1 - y0), ((x0 - x1) * (y3 - y2)));
378- } else if (x1 <= 1.72960576050945e+52 ) {
379- tmp_1 = (y1 - y2) / (y1 - y0);
380- } else if (x1 <= 2.145089573601479e+104 ) {
381- tmp_1 = (x1 - x3) / (x1 - x0);
382- } else {
383- tmp_1 = (x1 - x2) / (x1 - x0);
384- }
385- tmp = tmp_1;
386- }
387- return tmp;
363+ const double s1_dx = x0 - x1,
364+ s1_dy = y0 - y1,
365+ s2_dx = x3 - x2,
366+ s2_dy = y3 - y2,
367+ lx = x3 - x1,
368+ ly = y3 - y1;
369+ double val = std::fma (lx,s2_dy,-ly*s2_dx)/std::fma (s1_dx,s2_dy,-s1_dy*s2_dx);
370+ if (val!=val) return 0.5 ;
371+ if (val<0 ) return 0 ;
372+ if (val>1 ) return 1 ;
373+ return val;
388374}
389375
390376template <class FT >
@@ -402,6 +388,7 @@ FT s2s2_alpha(const FT& x0, const FT& y0,
402388 return (lx*s2_dy-ly*s2_dx)/(s1_dx*s2_dy-s1_dy*s2_dx);
403389}
404390
391+
405392template <class K >
406393typename Segment_2_Segment_2_pair<K>::Intersection_results
407394Segment_2_Segment_2_pair<K>::intersection_type() const
0 commit comments