Well, the one I posted works great, and the version you mentioned... well, gave me a completely different result.
I checked this by doing the following:
- Set the initial FOV to 90 (So both x and y will be 90 degrees)
- I then set two keys to run your distance formula and my function respectively.
- Using the values 90 and 45 for XAngle and YAngle respectively, the results came as follows for the two key presses:
Pressing the key for my function, the image was stretched in the y direction so the top quarter and bottom quarter of the screen (effectively HALF the screen) were no longer visible. The image was unchanged in the x direction... this is what should happen because the XAngle was left at 90 degrees, and the initial FOV was also 90.
Pressing the key for your distance formula, the image simply had a zoom effect that was based upon the images current aspect/FOV setting. Meaning, if I pressed this key FIRST, the original image zoomed outward. If I had pushed the key for my function BEFORE this key, then it had a very strong zoom out effect of the image produced by my function.
I suppose if you wanted to zoom your camera without actually moving it, then your distance formula may come in handy, but it certainly does not do the same thing as what this function was built to do.
If you would like to test it, then I can put together a simple program that will do that for you.
The one and only,
~PlystirE~
Dammit, Jim! I'm a programmer not a graphic designer!!!