简体   繁体   English

如何将世界坐标转换为相机坐标

[英]How to convert from world coordinates to camera coordinates

In the world coordinate system, there are objects with rotation values rx1,ry1,rz1 and position values px1,py1,pz1 .在世界坐标系中,存在旋转值为rx1,ry1,rz1和 position 值为px1,py1,pz1

Similarly, there is an camera in the world coordinate system with rotation values rx2,ry2,rz2 and position values px2,py2,pz2 .类似地,世界坐标系中有一个相机,其旋转值为rx2,ry2,rz2和 position 值为px2,py2,pz2

What formula can be used to convert rx1,ry1,rz1,px1,py1,pz1 to the camera coordinate system? rx1,ry1,rz1,px1,py1,pz1可以用什么公式转换到相机坐标系?

The up vector of the camera is the Y-axis, always oriented toward the object near the world origin.相机的向上矢量是 Y 轴,始终朝向世界原点附近的 object。

The camera and the model are supposed to move within the range as shown in the following gif image.相机和 model 应该在如下 gif 图像所示的范围内移动。 在此处输入图像描述

I would like to use Python to do the calculations, but I am open to any other answers, including other Unity C# or mathematical statements.我想使用 Python 进行计算,但我愿意接受任何其他答案,包括其他 Unity C# 或数学陈述。

You are welcome to have commentary in quaternions or in matrices instead of euler angles.欢迎您在四元数或矩阵而不是欧拉角中进行评论。

Within Unity c# for the position you can simply use the built-in在 position 的 Unity c# 中,您可以简单地使用内置的

var localPosition = camera.transform.InverseTransformPoint(theObject.transform.position);

for the rotation you can use对于轮换,您可以使用

var localRotation = Quaternion.Inverse(camera.transform.rotation) * theObject.transform.rotation;

This should give you the localPosition and localRotation in the coordinate space of the camera .这应该为您提供camera坐标空间中的localPositionlocalRotation

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何将3D世界坐标转换为3D相机坐标 - How convert 3d world coordinates to 3d camera coordinates 在 PyVista 中将绘图仪坐标转换为世界坐标 - Convert from plotter coordinates to world coordinates in PyVista 如何应用基本矩阵将 3D 点从相机 1 的世界坐标转换为相机 2 的世界坐标 - How to apply the essential matrix to transform a 3D point from camera 1's world coordinate to camera 2's world coordinates 如何从Vispy中的屏幕坐标获取世界坐标 - How to get world coordinates from screen coordinates in Vispy 如何获得世界坐标? - How to get world coordinates? 如何将道路上某个点在其图像坐标中的 (x,y) 坐标转换为其在世界坐标中的 (x,y) 坐标? - How do I convert the (x,y) coordinates of a point on the road in its image coordinates, to its (x,y) coordinates in the world coordinates? 通过glUnproject从鼠标坐标到世界坐标 - From mouse coordinates to world coordinates through glUnproject 从图像坐标转换为世界坐标 - Transforming from image coordinates to world coordinates Pybullet中的旋转矩阵是将世界坐标转换为相机还是将相机转换为世界? - Is the rotation matrix in Pybullet converting world coordinates into camera or camera to world? 你如何从Astropy中的AltAz坐标转换为赤道坐标 - How do you convert from AltAz coordinates to equatorial coordinates in Astropy
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM