RAYCASTING STEP 5: DRAWING WALLSIn the previous steps, 320 rays are casts, when each ray hits a wall, the distance to that wall is computed. Knowing the distance, the wall slice can then be projected onto the projection plane. To do this, the height of the projected wall slice need to be found. It turns out that this can be done with a simple formula: Actual Slice Height Projected Slice Height=  * Distance to Projection Plane Distance to the Slice The logic behind this formula is explained in the Figure 20 below. Figure 20: The math behind wall
scaling.
Our world consist cubes, where the dimension of each cube
is 64x64x64 units, so the wall height is 64 units. We also already know
the distance of the player to the projection plane (which is 277). Thus,
the equation can be simplified to:
Projected Slice Height = 64 / Distance to the Slice * 277 In an actual implementation, several things can be considered:
For example, suppose the ray at column 200 hits a wall
slice at distance of 330 units. The projection of the slice will be 64
/ 330 * 277 = 54 (rounded up). Figure 21: A partly rendered
view.

