Thanks for the function! I tried using asin, and it draws a nice curve, but it's not quite the same as the curve generated by the brute force line intersection method.
real_type rho = asin(sphere_radius / sphere_location.x);
real_type solid_angle = 2 * pi * (1 - cos(rho));
I've also just tried the obvious, but it doesn't quite work either. Basically, whatever the curve is, multiplying it by r^3 does not form a straight line, like it should (?):
long long unsigned int get_intersecting_line_count(
const vector<vector_3>& unit_vectors,
const vector_3 sphere_location,
const real_type sphere_radius)
{
real_type big_area = 4 * pi * sphere_location.x * sphere_location.x;
real_type small_area = pi * sphere_radius * sphere_radius;
real_type ratio = small_area / big_area;
return static_cast<long long unsigned int>(static_cast<real_type>(unit_vectors.size()) * ratio);
}
Edit: Aha, right… this only works for large r.