is there people good enough for a math problem (for a shader)?
I want to write an algorithm that would **intersect** any primitives (circle, sphere, cube, cylinder) inside a unit wrapping space, **no raymarching**

[![https://29a.ch/2013/9/25/wild-webgl-raymarching/boring.jpg][1]][1]

similar to this math problem
https://amininima.wordpress.com/2013/05/27/the-laser-gun/

But without the reflection.
[![enter image description here][2]][2]

I figure out how to do it with a single point at the boundaries of the space, using the planet alignment problem (akin to the two clock hand overlap problem). But I fail to generalized it.


  [1]: https://i.sstatic.net/yz0rX.jpg
  [2]: https://i.sstatic.net/qx3VE.png