Some spherical geometry helper functions for JavaScript