Scratchapixel has a lesson on it [1] which takes the same approach.
[1]: https://www.scratchapixel.com/lessons/3d-basic-rendering/ray...
[1]: https://www.scratchapixel.com/lessons/3d-basic-rendering/ray...
Thanks, I looked at scratchapixel but only found the stuff about how pinhole cameras work.