cgal icon indicating copy to clipboard operation
cgal copied to clipboard

Nef_3: Reduce re-calculation of is_long and orthogonal_pole

Open GilesBathgate opened this issue 2 years ago • 6 comments

Summary of Changes

Within Nef_S2/include/CGAL/Nef_S2/Sphere_segment.h the function do_intersect_internally requires a calculation of the is_long predicate which uses an orientation test against the source and target of the segment against its orthogonal pole. The orientation test is a relatively slow geometric test. In the scenario where the point doesn't intersect the antipode of the point has to also be checked, at this point the code recalculates is_long, which can impact performance.

The solution is to introduce some function overloads and store the result of is_long in a boolean variable such that the second check doesn't need to recalculate it.

Release Management

  • Affected package(s): Nef_3,Nef_S2
  • Issue(s) solved (if any): performance
  • License and copyright ownership: Returned to CGAL authors

GilesBathgate avatar Jan 14 '23 14:01 GilesBathgate

Does it have a measurable impact?

afabri avatar Jan 25 '23 11:01 afabri

Does it have a measurable impact?

I was sure it did but now I cannot reproduce it.

GilesBathgate avatar Jan 25 '23 17:01 GilesBathgate

Successfully tested in CGAL-5.6-Ic-184

sloriot avatar Feb 24 '23 07:02 sloriot

Successfully tested in CGAL-5.6-Ic-184

But the PR is still a draft. @GilesBathgate?

lrineau avatar Mar 31 '23 08:03 lrineau

Successfully tested in CGAL-5.6-Ic-184

But the PR is still a draft. @GilesBathgate?

@afabri, @MaelRL, @sloriot, what should be do with this PR? See also comments above (starting https://github.com/CGAL/cgal/pull/7189#issuecomment-1403443907).

lrineau avatar Mar 31 '23 08:03 lrineau

@lrineau It didn't seem to make a significant performance impact. So I put it as a draft, thinking this would suppress progress.

GilesBathgate avatar Mar 31 '23 08:03 GilesBathgate