I'm looking for a simplified algorithm to test for intersection between an OBB and a sphere. There are algorithms out there that I've seen, but most of them over-complicate things because they need to account for all 3 axes of rotation on the OBB. In my case, the OBB rotates only on the Z axis, so I feel like something in between the standard Circle/Rotated Rectangle algorithm and the Sphere/OBB algorithms would probably be more optimal.
For reference, the OBB is stored as a Vector3
for the center, another Vector3
for the half-dimensions, and a Matrix33
for the orientation - keeping in mind that we can guarantee that when translated to Euler rotation, two of the axes will be 0, and only the Z axis will change. The sphere is just a Vector3
for the center and a float
for radius.
I suspect such a thing may be possible by simply figuring out the radii of the cross sections of the sphere that correspond to the top and bottom of the OBB, and also the maximum radius of the sphere if its center is between the top and bottom, and then running a Circle/Rotated Rectangle collision check on each of these two (or three) radii. What I'm not sure of is if this will be easier (in terms of both coding and performance) than the full Sphere/OBB test.
(I'm going to leave this language-agnostic. I'm working in C++, but I'll accept an algorithm in any common language provided it's simple enough to translate to C++.)