* Performant method to determine if box if fully inside a sphere. The * box is defined by (min,max) corners; the sphere by (center,radius**2). * Inspired by Graphics Gems 1. */
| 241 | * Inspired by Graphics Gems 1. |
| 242 | */ |
| 243 | static bool InsideSphere( |
| 244 | const double min[3], const double max[3], const double center[3], double r2) |
| 245 | { |
| 246 | double dmin = 0.0, dmax = 0.0; |
| 247 | for (int i = 0; i < 3; ++i) |
| 248 | { |
| 249 | double a = (center[i] - min[i]) * (center[i] - min[i]); |
| 250 | double b = (center[i] - max[i]) * (center[i] - max[i]); |
| 251 | dmax += std::max(a, b); |
| 252 | if (min[i] <= center[i] && center[i] <= max[i]) |
| 253 | { |
| 254 | dmin += std::min(a, b); |
| 255 | } |
| 256 | } |
| 257 | return (!(dmin <= r2 && r2 <= dmax)); |
| 258 | } |
| 259 | |
| 260 | /** |
| 261 | * Determine if this bounding box is completely contained by a sphere. |
no test coverage detected