General math solution can be found here:
http://astronomy.swin.edu.au/~pbourk...try/planeline/

If anyone has something like this programmed, please post...