Move camera using rule of thirds

I am working on a camera control system for cut scenes. I want to write a function that will take the position of two game objects and rotate/move the camera such that the two objects will appear on the left and right third of the screen width according to the rule of thirds.

So far I have been able to get the position of the game objects on the screen using Camera.WorldToScreenPoint and I have been able to calculate where the thirds fall using Screen.width.

I have been toying with the idea of calculating an offset needed to rotate the camera so that the two items are equally offset from their respective third line and then moving the camera either forward or back until each item is on a third line, but I am not having much luck. I can’t seem to get the camera to rotate to the correct spot so that the game objects are equally offset.

To clarify what I am working for, please look at the following pictures:

Start:

From School Stuff

End:

From School Stuff

Sounds like basic trig. It would be interesting to have the camera ‘find’ it’s way to the correct spot(s), or you could calculate it and lerp to it or just jump there.

I don’t have the formula for you (yet), but maybe this will help you: you have the world distance between the objects. You bisect that and get the perpendicular (normal) to that, and that’s the line you’ll move the camera back on. The thing that makes it really interesting is that this depends on FOV. A smaller FOV means moving the camera further away. Also the perpendicular bisector means that the camera may move in one of two directions, so you’ll need to determine which one by which object you want on the left or right.

I think Viewport coordinates will be helpful: http://unity3d.com/support/documentation/ScriptReference/Camera.ViewportToWorldPoint.html