# Positioning camera to see mentioned points

This topic is 2562 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi

Lets say I have 3 points I want to make sure are included in the camera's vision frustum.
How can I ensure that the camera is placed at the most optimal position closest to the points but far enough to be able to see all of them together?

Thanks

##### Share on other sites
Bumpity bump...anyone plz?

##### Share on other sites
I think you should give some more information in order to get more specific answers. How is your camera "defined", do you want the frustum's geometry to be static (meaning the angle of view never changes), how accurate does it have to be?

##### Share on other sites
Are there obstacles that can occlude the points? If not, this is basically a 2d problem. Your three points lie in a single plane. Now you're looking for the smallest bounding box containing those points. Google "minimum bounding box" and you'll find how to do this. Once you have that, some simple logic will tell you what a minimal bounding box with your camera's aspect ratio is; it'll be the minimal box with one dimension stretched a little. Once you have this, the size of the box, and its rotation, tell you how far away from the plane the camera needs to be, and how it needs to be rotated.

Granted, there are other choices, and I haven't even really thought through what optimization problem this answer is solving, but it seems quite reasonable.

##### Share on other sites
@szecs
My camera is defined as an object that could be translated and rotated. The problem is I don't really have access to the camera's view frustum settings. All I can do is zoom in and out. That works for player controlled camera where he would like to zoom in and out but I'm having trouble automating the zoom to have the proper view frustum.
To begin with need not be that accurate. If the points had to move, I would simply put the logic in game loop. To start with I would just like to have the camera look straight at the points(lets say they were in the same vertical plane).

@Emergent. Yes this is like a 2d problem No obstacles or anything. I'll try messing with your suggested solution. Thanks

1. 1
2. 2
Rutin
19
3. 3
4. 4
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631781
• Total Posts
3002315
×