查看视锥体可视化
给定相机的 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这可能是 2D 中的基本三角,但 3D 中的问题要复杂一些。我没有给你一个具体的答案,但这可能会给你一些探索的途径。
大致步骤如下:
即可获得该圆所在的平面通过点和法向量,然后允许您确定方程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:
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).