ray casting algo implemented