I am working on a game mod and I need to calculate a field of view setting, based on a subject's distance from the camera. I have already written a test programme (basically a programme that creates a camera at a fixed distance from the subject and then lets me manually adjust FOV to the value that I think is best) that has given me the following values:
- 1 - 90
- 2 - 60
- 3 - 40
- 4 - 30
- 5 - 24
- 6 - 20
Where the first number is the distance from the camera and the second value is the FOV setting I need to use to keep the subject at full height within the screen. The distance units are fictional and non-specific and the FOV values have no real connection to real-world lenses.
I can't see any obvious relationship between the values, so I suspect this requires a formula or equation to define one. Maths of this kind is not my strong suit and I am not even sure where to start to formulate something that fits the situation.
I have a fallback plan of creating a coarse resolution lookup table, i.e. for every .1 distance change, store a value but I would prefer a smoother transition between values if possible.
So how would I go about formulating a function that maps itself to these defined values?