celeritas icon indicating copy to clipboard operation
celeritas copied to clipboard

Add ORANGE safety distance calculation

Open sethrj opened this issue 3 years ago • 4 comments

Per a code review code discussion with @hahnjo, the CalcSafetyDistance algorithm (unused but in there as a placeholder) is incorrect. The "safety distance" is a bounding sphere for remaining in the current volume, used to accelerate propagation in a field and multiple scattering. In both cases, the algorithm takes numerous small steps but must not cross a boundary into a different material.

sethrj avatar Jan 20 '22 14:01 sethrj

From celeritas-project/celeritas#291:

Maybe the safety could be approximated with a few iterations with steepest descent?

The most promising literature that I could find to date is ON THE DISTANCE FROM A POINT TO A QUADRIC SURFACE. What we need for safety is a sort of "conservative" estimate, ie the returned value can be too low but it must never be too large, I think.

hahnjo avatar Jan 20 '22 14:01 hahnjo

This is a blocking task for celeritas-project/celeritas#181 to calculate the step length.

sethrj avatar Feb 10 '22 19:02 sethrj

celeritas-project/celeritas#406 implements the CalcSafetyDistance algorithm, which works for spheres, planes, and cylinders, since the gradient of those surfaces points to the nearest point on the surface. For any other surfaces, the safety distance is zero (ultra-conservative). For "complex" volumes (those with internal surfaces) the safety distance will be unnecessarily conservative near those internal surfaces.

sethrj avatar Apr 18 '22 16:04 sethrj

I finally rediscovered this reference: Hart, Sphere Tracing: A Geometric Method for the Antialiased Ray Tracing of Implicit Surfaces which in Appendix A (pp 5-109–5-110) discusses distance to plane, sphere, cylinder, cone, torus. Distance to an ellipsoid requires solving a sixth degree polynomial.

sethrj avatar Oct 20 '23 13:10 sethrj