计算面向原点的方向向量
我有两个向量定义三维空间中的两个单独的点。一个在原点 (0.0f, 0.0f, 0.0f) 处静止,另一个则缓慢移动。从这些数据中,我需要获得一个(三维)方向向量,该向量描述从移动点当前位置到原点的方向。
移动点将是一个始终面向原点的定向光(3D 游戏)。 我不需要任何代码,只需要有关如何计算向量的基本信息。
I have two vectors defining two separate points in a three-dimensional space. One is static at the origin (0.0f, 0.0f, 0.0f) and the other one will be moving slowly. From this data i need to get a (three-dimensional) direction vector that describes the direction from the moving points current position to the origin.
The moving point will be a directional light (3D game) that always myst face the origin.
I don't require any code, just basic information on how to calculate the vector.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我觉得我可能会错过一些东西。您只想从原点减去移动向量吗?如果你有一个向量 (x, y, z),那么向量 (-x, -y, -z) 应指向原点。我误解了什么吗?
I feel like I might be missing something. Do you just want to subtract the moving vector from the origin? If you have a vector (x, y, z), then the vector (-x, -y, -z) should point towards the origin. Am I misunderstanding something?
如果你在空间中有一个点,并且你想知道它到原点的方向,那么它肯定只是该点的负值,如果你想要一个纯方向向量,则将其归一化为单位大小。
原点 <- (x,y,z) = (0, 0, 0) + l(-x, -y, -z)
If you have a point in space, and you want to know the direction to the origin for it, surely it's just the negative of the point, normalised to unit magnitude if you want a pure direction vector.
Origin <- (x,y,z) = (0, 0, 0) + l(-x, -y, -z)