change a macro into an inline function, add documentation, correct indentation
add check to clip ray trace calculation for beams outside of viewport