title: Calculating frustum FOV for a PerspectiveCamera
body: <p>I currently have a screen consisting of two areas:</p>
  
  <p>(Values are just assumed for this particular example and may of course vary depending on screen).</p>
  
  <p>The screen in total is 1080x1432px (WxH) and consists of two areas, each clipped using <code>glViewPort</code>. This because I want area (1) not to fill the screen when zooming.</p>
  
  <ol>
  <li>Game area. Can be zoomed. The size is 1080x1277px (WxH) and located at the top.</li>
  <li>The HUD (FYI objects from here can be moved to area (1). Non zoomable. The size is 1080x154 (WxH).</li>
  </ol>
  
  <p>Both have their own cameras.</p>
  
  <p>Area (1) width is 15f and the height is more than 15f (does not matter as long as it's at least 15f).</p>
  
  <p>I want area (2) to be 7f in width and 1f in height (for convenience). Thus I want to set the camera accordingly. I've tried to do this by calculating the FOV: </p>
  
  <pre><code>float size = 1f;
  float halfHeight = size * 0.5f;
  halfHeight *= (float) 154 / (float) 1080;
  float fullHeight = 2 * halfHeight;
  float halfFovRadians = MathUtils.degreesToRadians * camera.fieldOfView * 0.5f;
  float distance = halfHeight / (float) Math.tan(halfFovRadians);
  
  camera.viewportWidth = 1080;
  camera.viewportHeight = 154;
  camera.position.set(0f, 0, distance);
  camera.lookAt(0, 0, 0);
  camera.update();
  </code></pre>
  
  <p>And I create a object:</p>
  
  <pre><code>ModelBuilder builder = new ModelBuilder();
  builder.begin();
  builder.node();
  MeshPartBuilder meshBuilder = builder.part("lattice", GL20.GL_TRIANGLES,
          VertexAttributes.Usage.Position,
          new Material(ColorAttribute.createDiffuse(Color.GRAY)));
  
  BoxShapeBuilder.build(meshBuilder, 0f, 0f, 0f, 7f, 1f, 0f);
  Model model = builder.end();
  mHudModel = new ModelInstance(model);
  </code></pre>
  
  <p>If I manually try to set distance to 1f I can still view the box, but if I go below 1.0f the box won't display. And the distance being calculcated is approx 0.76f.</p>
  
  <p>I am trying to use the same concept as <a href="https://xoppa.github.io/blog/a-simple-card-game/" rel="nofollow noreferrer">https://xoppa.github.io/blog/a-simple-card-game/</a> to calculate the FOV. It works fine for area (1).</p>
  
  <p>Can I not use the camera like this? Do I calculate the FOV incorrectly? Why would my object disappear when I go below 1f in distance? </p>
  
  <p>Thanks.</p>