I'm working on a project where I have a 3D grid and an object with a known position and direction. I'm struggling to think of a way to find all of the points on the direction line where any of the three coordinates (x, y, or z) are integer values. My problem is that I need a way to find these points in order by distance from the object's position, so I can't just find them all and then sort them by said distance.
This image hopefully depicts what I'm looking for. I want to find the coordinates of all of the blue points (but in 3D instead of 2D). I think a start would be to find the slope of the line, but I'm not really sure where to go from there.
Any help with this would be seriously appreciated!
Edit: After some thought, I've come up with a way to rephrase this question:
Given a 3-dimensional vector's origin and orientation, will the vector first pass through an x-integer plane, a y-integer plane, or a z-integer plane? Where is that intersection?