I've searched everywhere for an equation that suits my needs but i couldn't find anything useful. I'm making a voxel ray-tracer so I need an equation that gets me the intersection of a ray with a box, and the box's normal.
I looked at inigo quilez's intersection code but I can't derive the equation from the code shown so i need the equation itself rather than code.
Say we have the ray's origin $O(-5, 1, 0)$ and the box position $B(0, 0, 0)$ with the ray's direction as a unit vector being $(1, 0, 0)$ and the box's side lengths being $(2, 2, 2)$
I need the equation to return the distance between the point where the ray hits the box, and the ray's origin
I need the box's normal where the intersection is