MCPcopy Create free account
hub / github.com/Kitware/VTK / InsideSphere

Function InsideSphere

Common/DataModel/vtkBoundingBox.h:243–258  ·  view source on GitHub ↗

* 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. */

Source from the content-addressed store, hash-verified

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.

Callers 2

CanCullBinMethod · 0.85
BucketInsideSphereMethod · 0.85

Calls 2

maxFunction · 0.50
minFunction · 0.50

Tested by

no test coverage detected