+ int octantNum = -1;
+
+ moof::plane::halfspace halfspace;
+
+ moof::plane xy = aabb.xy_plane();
+ halfspace = xy.intersects(sphere_);
+ if (halfspace == moof::plane::intersecting)
+ {
+ halfspace = xy.intersects(aabb_);
+ }
+
+ if (halfspace == moof::plane::positive)
+ {
+ moof::plane xz = aabb.xz_plane();
+ halfspace = xz.intersects(sphere_);
+ if (halfspace == moof::plane::intersecting)
+ {
+ halfspace = xz.intersects(aabb_);
+ }
+
+ if (halfspace == moof::plane::positive)
+ {
+ moof::plane yz = aabb.yz_plane();
+ halfspace = yz.intersects(sphere_);
+ if (halfspace == moof::plane::intersecting)
+ {
+ halfspace = yz.intersects(aabb_);
+ }
+
+ if (halfspace == moof::plane::positive)
+ {
+ octantNum = 2;
+ }
+ else if (halfspace == moof::plane::negative)
+ {
+ octantNum = 3;
+ }
+ }
+ else if (halfspace == moof::plane::negative)
+ {
+ moof::plane yz = aabb.yz_plane();
+ halfspace = yz.intersects(sphere_);
+ if (halfspace == moof::plane::intersecting)
+ {
+ halfspace = yz.intersects(aabb_);
+ }
+
+ if (halfspace == moof::plane::positive)
+ {
+ octantNum = 1;
+ }
+ else if (halfspace == moof::plane::negative)
+ {
+ octantNum = 0;
+ }
+ }
+ }
+ else if (halfspace == moof::plane::negative)
+ {
+ moof::plane xz = aabb.xz_plane();
+ halfspace = xz.intersects(sphere_);
+ if (halfspace == moof::plane::intersecting)
+ {
+ halfspace = xz.intersects(aabb_);
+ }
+
+ if (halfspace == moof::plane::positive)
+ {
+ moof::plane yz = aabb.yz_plane();
+ halfspace = yz.intersects(sphere_);
+ if (halfspace == moof::plane::intersecting)
+ {
+ halfspace = yz.intersects(aabb_);
+ }
+
+ if (halfspace == moof::plane::positive)
+ {
+ octantNum = 6;
+ }
+ else if (halfspace == moof::plane::negative)
+ {
+ octantNum = 7;
+ }
+ }
+ else if (halfspace == moof::plane::negative)
+ {
+ moof::plane yz = aabb.yz_plane();
+ halfspace = yz.intersects(sphere_);
+ if (halfspace == moof::plane::intersecting)
+ {
+ halfspace = yz.intersects(aabb_);
+ }
+
+ if (halfspace == moof::plane::positive)
+ {
+ octantNum = 5;
+ }
+ else if (halfspace == moof::plane::negative)
+ {
+ octantNum = 4;
+ }
+ }
+ }
+
+ return octantNum;