I have a flash 500x500 in size. My viewport is 500x500 and so is my cube.
I want the face of my cube to fit exactly the space of the viewport and so the flash stage.
How can I calculate the camera z distance to accomplish this?
Thank you! Andrea
EDIT: I've came up with something, but still it's not the solution of the problem.
I've analized the situation and came up with this graphic:
According to this, what I'm looking for is a catethus of a right triangle and, since I've got the other one and the opposite angle degrees, I can use trigonometry to find it. Still this doesn't work. In my case the box side is 840 and so is the viewport width, while the camera FOV is 60.
Through trial and error I found the right value for camera.z to be about -591 while using the formula in the image I get -1147.4613391789285 I really don't get what I'm missing.
Hope someone can help me.