Maths: Camera Position From AABB?

Miscellaneous Forums/General Discussion/Maths: Camera Position From AABB?

Nope, I can't just move it back until it fits, because it's speed-critical.

I think I'm about half way now though. What I'm doing is creating a vector which describes the scale of the bounding box, then transforming that vector from world space into camera space ( orientation only, since the camera has no scale or indeed position at this point. )

Now I've got a bounding box oriented to the camera, but it has no position. The x and y dimensions of this box tell me the isometric FOV, and the z dimension gives me the distance between the nearplane and farplane. So if I knew where to work back from, I could derive the position of the camera by inverting the camera direction vector and multiplying by the distance between the farplane and the nearplane. I'm just not sure how to determine the point to work back from.

I'll have another think about it and make some more scribblings, see if I can't figure it out.

EDIT: Oh, and in case anyone is wondering why it matters where the camera is positioned, it's because I don't want crappy depth buffer precision. It's true that the position doesn't matter so long as the direction and FOV is right because an orthographic camera renders the same image at any distance, but I don't want flickering vertices and whatnot because the camera is further away than it needs to be.