By a line on the sphere, I assume you mean a part of a great circle spanning less than 180°. For each of the _N_ points, find what part of the line is closer than _X_ to that point. This is at most a single segment. Find their union _C_ as a disjoint union of segments. This is probably easier if you sort them by their starting point, and the obvious algorithm gives you the union as a sorted list as well – which makes the last part trivial: Find the complement of _C_. Oh, and the first part can be done with some simple linear algebra.