moved few help functions from ray_tracing.c into lsqadj.c