Beam direction algorithm

algorithm

Solution

A simplified algorithm for rectangular grid would work by calculating the virtual position of the receiver in the next grid -- just as if you were playing pool and wanted to do an amazing bank shot.

     +---------+----------+---------+----------+
     | O                  |                    |
     |===>                |                <===|
     |     Real           |    Virtual copy    |
     |                    |                    |
     A---------+----------+---------+----------a

Here you want to shoot O to A, so you mirror the geometry of the pool in your mind and aim to the virtual pocket 'a'. This scenario can be repeated (infinitely) by mirroring the geometry over and over again both horizontally and vertically. At some point there should exists some virtual copy of the pocket/receiver a(n), which isn't blocked by anything.

Problem

Suppose we are given with a system of mirrors. Also we have a beam emitter and a beam receiver. Then we should find the direction the emitter should emit in order the beam to reach the receiver through the shortest path. How can that be accomplished effectively? The picture is just a sketch for example.

Original source