Is it possible to calculate camera properties e.g. pos, rotation field of view from four points which will represent far and near clipping planes

Short answer is yes. But i think you need 8 points for that not 4. 4 points for near and 4 points for far clipping pane.

The following code finds the positoin using some geometry.

```
public class InverseCameraCalculator {
public struct CameraInfo {
public Vector3 position;
}
public static CameraInfo CalculateCameraInfo(Vector3[] nearClippingPane, Vector3[] farClippingPane) {
CameraInfo ci;
Vector3 nearCenter = Vector3.zero;
for(int i = 0; i < nearClippingPane.Length; i++) {
nearCenter += nearClippingPane*;*
```

*}*

*Vector3 farCenter = Vector3.zero;*

*for(int i = 0; i < farClippingPane.Length; i++) {*

*farCenter += farClippingPane*;**

*}*

*var nearToFarCenterVector= (nearCenter - farCenter);*

*var distanceBetweenPanes = farToNearCenterVector.magnitude;*

*var nearDimension = (nearClippingPane[1] - nearClippingPane[0]).magnitude;*

*var farDimension = (farClippingPane[1] - farClippingPane[0]).magnitude;*

*// this is sometihg like similiraty between triangles. I am not really good at names of the formulas but i know math.*

*var nearPaneDistance = (distanceBetweenPanes / (farDimension - nearDimension)) * nearDimension;*

*ci.position = (nearToFarCenterVector/ distanceBetweenPanes) * nearPaneDistance + nearCenter;*

*return ci;*

*}*

*}*

*There might be some little errors on my calculation because i did not tested it but you should be able to fix them when you understand the logic behind it.*

*The following image is the visualized representations of some variables used in code.*

* [89098-camera.png*|89098]

*_*

_

_