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

Function IntersectsSphere

Common/DataModel/vtkBoundingBox.h:205–221  ·  view source on GitHub ↗

* Performant method to intersect box with 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

203 * Graphics Gems 1.
204 */
205 static bool IntersectsSphere(
206 const double min[3], const double max[3], const double center[3], double r2)
207 {
208 double d2 = 0.0;
209 for (int i = 0; i < 3; ++i)
210 {
211 if (center[i] < min[i])
212 {
213 d2 += (center[i] - min[i]) * (center[i] - min[i]);
214 }
215 else if (center[i] > max[i])
216 {
217 d2 += (center[i] - max[i]) * (center[i] - max[i]);
218 }
219 }
220 return (d2 <= r2);
221 }
222
223 /**
224 * Intersect this box with a sphere. Parameters involve the

Callers 2

CanCullBinMethod · 0.85
IntersectsSphere2Function · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected