I'm doing project using raycasting (just remaking old good wolf3d game). And I am led by one tutorial. I am stuck in understanding the math which he is using in it. I tried to get into it and lost a lot of hours googling, drawing and solving it, but I can't get that result. Asking here, because math and gamedev communities looks like much less populated. And also gamedev community has the same question as mine, and it is still unanswered. So, maybe someone with good math could explain it.
When deriving deltaDistX geometrically you get, with Pythagoras, the formula "sqrt(1 + (rayDirY * rayDirY) / (rayDirX * rayDirX))", but this can be simplified to abs(1 / rayDirX). Similarly, deltaDistY is "sqrt(1 + (rayDirX * rayDirX) / (rayDirY * rayDirY))" which can be simplified to abs(1 / rayDirY).
rayDirX and rayDirY is our ray's X and Y coordinates. Each side of the grid is a 1. I guess it is connected with rescaling the Pythagorean theorem here it goes. But how is this simplified to this?
abs(1 / rayDirX) and abs(1 / rayDirY)
Any help and info is appreciated.