The width of the truncated cone at a given distance from the near plane

I use CML to control 3D math in an OpenGL-based interface project that I make for work. I need to know the width of the viewing truncation at a given distance from the eye point, which is stored as part of the 4x4 matrix that represents the camera. My goal is to position gui objects along the visible edge of the viewport, but at some distance from the screen from the near clipping plane.

CML has a function to extract the planes of the truncated cone, returning them in the form Ax + By + Cz + D = 0. This truncation is perpendicular to the camera, which does not necessarily coincide with the z axis of the perspective projection.

I would like to select the x and z coordinates in order to align the graphic elements on the sides of the screen at different distances from the camera. What is the best way to do this?

Thank!

+3
source share
1 answer

This seems to be a duplicate. Search for the length of the side of the cross section of the truncated / truncated pyramid , if you already have a cross section of the known width of the known distance from the top. If you don’t have this and want to receive an answer yourself, you can follow these steps.

  • Take two adjacent planes and find their intersection line L1. You can use the steps here . In fact, you need the direction of the line vector.
  • , , L2.
  • , Ax + By + Cz + D = 0 , , L1 L2 .
  • L1 L2, . ; theta. , . .
  • . , ( , ). - w. , w .
  • r - . rcos (theta/2) = d rsin (theta/2) = w/2, tan (theta/2) = (w/2)/d, = 2d * (/2). d , .

, . . , .

+2

Source: https://habr.com/ru/post/1740548/


All Articles