查看视锥体可视化

发布于 2024-10-26 09:21:38 字数 102 浏览 0 评论 0原文

给定相机的 3D 位置、相机的 3D 目标位置(相机指向的点)、距相机的远平面距离、视野和纵横比,如何计算远平面中的四个 3D 点?这应该可以通过基本三角学实现,但我没有得到确切正确的结果。

Given a 3D position of a camera, 3D target position of the camera (the point the camera points to), far plane distance from the camera, field of view and aspect ratio, how can I calculate the four 3D points in the far plane? This should be possible with basic trigonometry but I'm not getting the exact right results.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

つ低調成傷 2024-11-02 09:21:38

这可能是 2D 中的基本三角,但 3D 中的问题要复杂一些。我没有给你一个具体的答案,但这可能会给你一些探索的途径。

大致步骤如下:

  1. 求出图像平面的方程
  2. 求出视场半径
  3. 求出视场圆的方程 求出
  4. 该圆上与您的纵横比相对应的四个点

即可获得该圆所在的平面通过点和法向量,然后允许您确定方程3D 中的那个圆(点是相机的位置,矢量是相机和目标之间的线)。

圆的半径可以通过关系式 r = d tan(theta / 2) 确定,其中 d 是相机和目标之间的距离,theta 是 FOV 角度(以度为单位)。

圆的方程3D可以根据半径和法向量来定义。

最后,您需要找到给定长宽比的矩形,可以是 刻在该圆中,您的四个点是矩形和圆的交点。

您还需要考虑相机是否可以倾斜或水平。这将改变点,但它们仍然位于同一个圆/平面上。

根据您的目标,如果相机始终位于 (0,0,0) 并与其中一个轴对齐(即目标位于其中一个轴上),可能有助于简化问题。

It might be basic trig in 2D, but the problem is a bit more elaborate in 3D. I don't have a specific answer for you, but this might give you some paths to explore.

Rougly, the steps are as follow:

  1. Find the equation of the image plane
  2. Find the FOV radius
  3. Find the equation of the FOV circle
  4. Find the four points lying on that circle that correspond to your aspect ratio

The plane on which that circle sits can be obtained by a point and normal vector, then allowing you to determine the equation of that circle in 3D (the point being the location of the camera, and the vector is the line between the camera and the target).

The radius of the circle can be determine by the relation r = d tan(theta / 2) where d is the distance between the camera and target, and theta is the FOV angle in degrees.

The equation of that circle in 3D can be defined according to the radius and normal vector.

Finally, you need to find the rectangle with given aspect ratio that can be inscribed in that circle, your four points being the intersection of the rectangle and circle.

You also need to consider whether the camera can be tilted or if it is leveled. This will change the points, but they will still lie on the same circle/plane.

Depending on your objective, it might help simplify the problem if the camera is always located at (0,0,0) and is aligned with one of the axes (i.e. the target is on one of the axes).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文