How to find the longest distance at which the camera can render an object.

Assuming the camera view is a pyramid, the value for camera.farClipPlane will only refer to the height of the pyramid instead of the length of its sides.
alt text

How can i find the length of the sides of the pyramid?
(Note that the camera’s aspect ratio and field of view are all variable so a formula-based solution might be needed.)

Untested Pseudo-code:

HalfHeight = Tan(0.5 * field_of_view) * distance;
HalfWidth = HalfHeight * Screen.width / Screen.height;
Diagonal = Sqrt(HalfHeigth^2 + HalfWidth^2)
GreenLine = Sqrt(distance^2 + Diagonal^2)