2
$\begingroup$

Is there any way to compute the volume when a sphere intersects a AABB(cube), with different centers. Also i want to be able given a percentage of sphere's volume to to place the sphere's center in a point in 3D space where it intersects the AABB and satisfies that intersected volume.

$\endgroup$

1 Answer 1

0
$\begingroup$

There are many ways, but the fastest I think is to create an octtree for your cube and choose a small subdivision level. Then do simple collision detection of the cube to the sphere. If the sphere collides with the cube, subdivide it into 8 smaller cubes. Test each of those cubes and repeat. When you are finished, you will know how many cubes have intersected the sphere, just multiply their dimensions by the number of intersections and you have a close approximation of total volume.

You may want to say that a cube collides with a sphere if its center lies within one radius of the spheres center.

I recently did something similar for a CNC simulator I wrote.

Good luck!

As far as the second part of your question, there would have to be constraints. If the cube is substantially smaller than the sphere, it may not be possible to satisfy your volume requirements. Given that constraints are in place, this method is fast enough that you could just drive your sphere into the cube until your required volume is met.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.