🎯 DDA Algorithm: Step-by-Step Grid Traversal

Watch how delta distances guide the ray through each grid cell

25Β°
3
40px

πŸ“Š Current Values

Ray Direction: (0, 0)

Delta Dist X: 0

Delta Dist Y: 0

Current Step: 0

Grid Cell: (0, 0)

πŸ” What You're Seeing

  • πŸ”΄ Red Ray: The actual ray path
  • πŸ”΅ Blue Dots: Grid intersection points
  • 🟑 Yellow Cells: Visited grid cells
  • 🟠 Orange Cell: Currently processing
  • 🟒 Green Lines: Delta distance vectors

πŸ€– DDA Algorithm Steps

1. Initialize: Calculate delta_dist_x = |1/ray_dir_x| and delta_dist_y = |1/ray_dir_y|
2. Setup: Determine step directions and calculate distances to next grid lines
3. Loop: Always step to the nearest grid intersection (smallest distance)
4. Update: Add delta_dist to the side that was stepped, move to next grid cell
5. Repeat: Continue until hitting a wall or reaching maximum distance