I have an object with its vertices in cartesian coordinates. These cartesian coordinates are the ECEF(Earth centred earth fixed) coordinates. This object is actually present on an ellipsoidal model of the earth using wgs84 corrdinates.The cartesian coordinates were actually obtained by converting the set of latitudes and longitudes along which the object lies but i no longer have access to them. What i have is an axis aligned bounding box with xmax, ymax, zmax and xmin,ymin,zmin obtained by parsing the cartesian coordinates (There is no obviously no cartesian point of the object at xmax,ymax,zmax or xmin,ymin,zmin. The bounding box is just a cuboid enclosing the object).
What i want to do is to calculate the camera distance for an overview on this object such that this object's bounding box perfectly fits the camera frustum. I have a perspective camera but just for an overview (directly on top of the object) i think it doesnt matter.
I know that an approximate distance can be calculated using a simple (boundingBox.ymax - boundingBox.ymin)/(tan(fovy/2) X 2) . But this would work only if the box is parallel to the x-y plane. For a random bounding box anywhere on the ellipsoid this wont work.
I am not very clear with the approach to take here. A method like using a local to world matrix comes to mind but its not very clear. Any input would be helpful.