Maths: Camera Position From AABB?

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

Scrap that actually. Drawing that out reveals closer objects may lie outside the the cameras view, even though they aren't the widest points.

BUT, if you take the side of the bounding box, closest to the camera, you can use this edge to perform what i mentioned above.

The scene is the circles and boxes. The large box is the bounding box. And the 40 Deg text is where your camera should be when it's position is worked out



You have your camera angle already, or should be able to work that out. You know the other two angles will be identical, so that should be easy to work out. You know the distance across the bounding box, between angle a and angle b.

So, given that information, you should be able to work out the distance from either point, to perfect point of the camera.

You need not even use line intersection, as given the 3 angles and a distance of one side of the triangle, it should be easy to get the length of the other side. This will give you your position.

Looking over that again, it should be easier to do, as you can create a 90 degree angle by chopping the traingle in halve, and halving the camera view angle. Gives you a nice 90 degree edge and easier maths to work with.