pick ray calculation (moved to gph-math and used here)