The idea is that you can reduce the problem from 3d to 2d by seeing where the ray hits the first two planes

and then using the uv coordinates of those intersections as two points defining a 2d ray. You then do a

2d raytrace of that ray versus a shape, but valid intersection distances are a multiple of the vector's length

instead of a continuous calculation.

For this to work, you need to be able to analystically solve 2d ray vs 2d infinitely repeating shape.

An way to solve this is to make sure the shape is constrained to a single tile, and when laying the shape on

a grid, that no border between "open spaces" is less than 0.5 units.

The reason for that is because the vector can at most move by 0.5 units on any single axis (since we modulus the vector).

If we have a border that is less than 0.5, we will think we got a hit, when in fact it might be a miss, if the sample point

is not actually inside the solid point!

The last two shapes are fail cases.

The checkerboard is a problem because if the ray is moving up and to the right or down and to the left, it can encounter

border thickness less than 0.5.

The thin square is a problem because it has a very thin border, which is less than 0.5 in all directions!

The ultimate goal of this stuff is to try and figure out how to make infinitely repeating shapes in ray tracing, like

can be done in ray marching via modulus!

http://computergraphics.stackexchange.com/questions/4094/is-there-a-method-to-do-ray-marching-style-modulus-repeat-with-raytracingI think it's a bit different, he solve the problem empirically and didn't pursue further (all contribution by him on internet stop by that point) he basically said it wanted to go further than the limitation here. Also he work on a 2d approximation, I further reduce it to 1d. And we can "see" in the 1d problem that it's a periodic or "rate" problem, except I don't have the mathematical competence to translate it, but I can trace it empirically.

I'm not sure the reason that doesn't work has anything to do with the fundamental, for example I don't use the modulo, I avoid modulo by translating into periodicity (hence focusing on wrapping) that's the contribution I'm trying to make.

I think getting stuck on the raytracing/raymarching semantic it emulate is a red herring. That's why I didn't focus so much on the aspects of the idea, but more on the "math". Once you unfold the space, it looks very much like a trig problem, except we don't intercept a continuous line.

Think about it, if you have two interger interval, you can deduce the bigger pattern by simply multiplying them, so if you have a beat on twos and a beat on 3, they pulse the same way on 6 because (2*3=6) so you have a new interval from the former two. Now if you have 2 beat on twos, they are sync, but if you offset one by one unit, they will never be sync ever. By going 1d I basically have the same problem. I need to translate that intuition into proper mathematical terms and formula.