什么是 3D 矢量?它与 3D 点有何不同?

发布于 2024-09-26 18:35:41 字数 80 浏览 5 评论 0原文

在 3D 游戏数学中,3D 向量与 3D 点元组 (x,y,z) 是否不同?

如果它们不同,那么如何计算给定 3d 点的向​​量?

Does a 3D vector differ from a 3D point tuple (x,y,z) in the context of 3D game mathematics?

If they are different, then how do I calculate a vector given a 3d point?

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

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

发布评论

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

评论(7

零崎曲识 2024-10-03 18:35:41

不同之处在于向量是一个代数对象,它可能会也可能不会作为某个空间中的坐标集给出。 (感谢bungalobill纠正我的草率)。

点只是由坐标给出的点。一般来说,人们可以将两者混为一谈。如果给你一组坐标,并告诉你它们构成一个“点”,而没有更多信息(基础的选择等),那么你可以将这组数字交还给你,并合法地声称已经产生了一个向量。

两者之间最大的区别在于,对一个人做可以对另一个人做的事情是没有意义的。例如,

  1. 您可以添加向量:<1 2 3> + <3 2 1> =<4 4 4>
  2. 您可以将向量乘以(或缩放)一个数字(通常称为标量)
    2*<1 1 1> = <2 2 2>

  3. 您可以询问两点相距多远: d((1, 2, 3), (3, 2, 1) = sqrt((1 - 3)2 + (2 - 2)2 + (3 - 1)2) = sqrt(8) ~= 2.82

思考向量和点之间关联的一个很好的直观方法是向量告诉你如何从原点(空间中的一个点)我们将坐标 (0, 0, 0)) 分配给其关联点。

如果平移坐标系,则会得到同一点的新向量,尽管组成该点的坐标将经历相同的平移。因此,在两者之间进行合并是非常容易的。

同样,如果旋转坐标系或应用一些其他变换(例如剪切),则与该点关联的坐标和向量也

可能会发生 变化。完全是另一回事,例如区间 [0, 1] 上的有界函数是一个向量,因为您可以将它乘以实数并将其添加到区间上的另一个函数,并且它将满足某些要求(即向量空间)。在这种情况下,人们会想到 [0, 1] 中的每个实数 x 都有一个坐标,其中该坐标的值就是 f(x)。这是无限维向量空间最简单的例子。

有各种各样的向量空间,向量是“点和方向”(或任何它应该是什么)的概念实际上是相当空洞的。

The difference is that a vector is an algebraic object that may or may not be given as the set of coordinates in some space. (thanks to bungalobill for correcting my sloppiness).

A point is just a point given by coordinates. Generally, one can conflate the two. If you are given a set of coordinates, and told that they constitute a 'point' with no further information (choice of basis, etc), then you can just hand that set of numbers back and legitimately claim to have produced a vector.

The largest difference between the two is that it makes no sense to do things to one that you can do to the other. For example,

  1. You can add vectors: <1 2 3> + <3 2 1> = <4 4 4>
  2. You can multiply (or scale) a vector by a number (generally called a scalar)
    2 * <1 1 1> = <2 2 2>

  3. You can ask how far apart two points are: d((1, 2, 3), (3, 2, 1) = sqrt((1 - 3)2 + (2 - 2)2 + (3 - 1)2) = sqrt(8) ~= 2.82

A good intuitive way to think about the association between a vector and a point is that a vector tells you how to get from the origin (that one point in space to which we assign the coordinates (0, 0, 0)) to its associated point.

If you translate your coordinate system, then you get a new vector for the same point. Although the coordinates that make up the point will undergo the same translation so it's a pretty easy conflation to make between the two.

Likewise if rotate the coordinate system or apply some other transformation (e.g. a shear), then the coordinates and vector associated to the point will also change.

It's also possible for a vector to be something else entirely, for example a bounded function on the interval [0, 1] is a vector because you can multiply it by a real number and add it to another function on the interval and it will satisfy certain requirements (namely the axioms of a vectorspace). In this case one thinks of having one coordinate for each real number, x, in [0, 1] where the value of that coordinate is just f(x). So that's the easiest example of an infinite dimensional vector space.

There are all sorts of vector spaces and the notion that a vector is a 'point and a direction' (or whatever it's supposed to be) is actually pretty vacuous.

你げ笑在眉眼 2024-10-03 18:35:41

向量表示从一种状态到另一种状态的变化。要创建一个,您需要两个状态(在本例中为点),然后从最终状态中减去初始状态以获得结果向量。

A vector represents a change from one state to another. To create one, you need two states (in this case, points), and then you subtract the initial state from the final state in order to get the resultant vector.

心清如水 2024-10-03 18:35:41

向量是比 3D 空间中的点更普遍的概念。

向量可以有 2、3 或 n 维。除了位置之外,它们还代表物理世界中的许多量(例如速度、力、加速度)。

数学家会说向量是根据以下规则进行变换的一阶张量:

u(i) = A(i, j)v(j)

您需要点和向量,因为它们不同。 3D 空间中表示位置的点是一个向量,但每个向量都不是 3D 空间中的点。

然后是向量作为容器的计算机科学概念 - 它是值或引用数组的抽象。这与数学家的向量概念不同,因为每个向量容器不需要遵守一阶张量变换定律(例如,OrderItems 的向量)。这是另一个单独的想法。

在谈论向量和点时,记住所有这些很重要。

Vectors are a more general idea that a point in 3D space.

Vectors can have 2, 3, or n dimensions. They represent many quantities in the physical world (e.g., velocity, force, acceleration) besides position.

A mathematician would say that a vector is a first order tensor that transforms according to this rule:

u(i) = A(i, j)v(j)

You need both point and vector because they are different. A point in 3D space denoting position is a vector, but every vector is not a point in 3D space.

Then there's the computer science notion of a vector as a container - it's an abstraction for an array of values or references. This is a different concept from a mathematician's idea of a vector, because every vector container need not obey the first order tensor transformation law (e.g. a Vector of OrderItems). That's yet another separate idea.

It's important to keep all these in mind when talking about vectors and points.

相守太难 2024-10-03 18:35:41

在 3D 游戏数学中,3D 向量与 3D 点元组 (x,y,z) 有何不同?

传统上矢量意味着方向和速度。一个点可以被视为来自一个时间步的世界原点的向量。 (尽管它可能不被认为是数学上纯粹的)

如果它们不同,那么如何计算给定 3d 点的向​​量?

target-tower 是常用的助记符。

请小心使用它。得到的向量实际上是法线*速度。如果您想将其更改为在游戏应用程序中有用的东西:您需要首先对向量进行归一化。

示例:乔位于 (10,0,0),他想去 (10,10,0)
目标塔:(10,10,0)-(10,0,0)=(0,10,0)
标准化结果向量:(0,1,0)
应用“物理”:(0,1,0) * speed*elapsed_time < speed = 3,为了便于计算,我们会说计算机在最后一步和这一步之间冻结了整整 2 秒 >
=(0,6,0)
将所得向量添加到 Joe 空间中的当前点,以获得他空间中的下一个点: ... =(10,6,0)

Normal = vector/(sqrt(x*x+y*y+z*z))

。 ..我想我这里拥有一切

Does a 3D vector differ from a 3D point tuple (x,y,z) in the context of 3D game mathematics?

Traditionaly vector means a direction and speed. A point could be considered a vector from the world orgin of one time step. (even though it may not be considered mathematically pure)

If they are different, then how do I calculate a vector given a 3d point?

target-tower is the common mnemonic.

Careful on your usage of this. The resulting vector is really normal*velocity. If you want to change it into something useful in a game application: you will need to normalize the vector first.

Example: Joe is at (10,0,0) and he wants to go to (10,10,0)
Target-Tower: (10,10,0)-(10,0,0)=(0,10,0)
Normalize the resulting vector: (0,1,0)
Apply "physics": (0,1,0) * speed*elapsed_time < speed = 3 and we'll say that the computer froze for a whole 2 seconds between the last step and this one for ease of computation >
=(0,6,0)
Add the resulting vector to Joes current point in space to get his next point in space: ... =(10,6,0)

Normal = vector/(sqrt(x*x+y*y+z*z))

...I think I have everything here

下雨或天晴 2024-10-03 18:35:41

矢量是状态的变化。点是静态点。两个向量可以平行或垂直。您可以得到两个向量的乘积,这是第三个向量。您可以将向量乘以常数。您可以添加两个向量。
所有这些操作都不允许在现场进行。因此,如果您将两者视为 C++ 类,那么在编程方面,向量类中会有很多此类方法,但可能只有 Get 和 Set 。

Vector is the change in the states. A point is the static point. Two vectors can be parallel or perpendicular. You can have product of two vectors which is a third vector. You can multiply a vector by a constant. You can add two vectors.
All these operations are not allowed on point. So program wise if you think both as a C++ class, there will be many such methods in the vector class but probably only Get and Set for point.

作业与我同在 2024-10-03 18:35:41

在游戏数学的背景下没有区别。

点是仿射空间的元素。向量是向量(也称为线性)空间的元素。当您在仿射空间中选择原点时,它会自动在该仿射空间上产生线性结构。反之亦然:如果有一个向量空间,它已经满足仿射空间的所有公理。

事实是,在计算方面,以数字方式表示仿射空间的唯一方法是使用数字元组,它们也形成向量空间。

游戏中的每个对象总是有一个起源,知道它在哪里至关重要。该原点是相对于世界原点设置的,世界原点是相对于相机/视口的原点设置的。对象的顶点表示为向量——距对象原点的偏移量。您可以使用矩阵乘法来变换对象——这也是纯粹的向量空间运算(如果不首先指定原点,则无法将仿射点乘以矩阵)。等等……正如我们所见,所有那些我们可能认为是“点”的数字三元组实际上是局部坐标系中的向量。

那么在代数研究之外还有什么理由区分两者呢?这是一种不必要的抽象,不必要的抽象是有害的(KISS)。所以我的答案是,只需使用单一向量类型即可。

或游戏开发环境之外的任何拓扑空间。

In the context of game mathematics there is no difference.

Points are elements of an affine space. Vectors are elements of a vector (aka linear) space. When you choose an origin in an affine space it automatically induces a linear structure on that affine space. The contrary is also true: if you have a vector space it already satisfies all the axioms of an affine space.

The fact is that when it comes to computation, the only way to represent an affine space numerically is to use tuples of numbers, which also form a vector space.

Each object in a game always has an origin, and it is crucial to know where it is. That origin is set relative to the origin of the world, which is set relative to the origin of the camera/viewport. The vertices of the object are represented as vectors -- offsets from the object origin. You use matrix multiplication to transform the objects -- that is too a purely vector space operation (you cannot multiply an affine point by a matrix without specifying the origin first). Etc, etc... As we see all those triplets of numbers that we might think of as 'points' are actually vectors in the local coordinate system.

So is there any reason to distinguish between the two outside the study of algebra? It is an unnecessary abstraction, and unnecessary abstractions are harmful (KISS). So my answer is no, just go with a single vector type.

Or any topological space outside the context of game development.

夏日落 2024-10-03 18:35:41

矢量是一条线,它是一系列点,但它可以用两个点表示,即起点和终点。

如果您将原点作为起点,那么您可以仅给出终点来描述向量。

A vector is a line, that is a sequence of points but that it can be represented by two points, the starting and the ending point.

If you take the origin as the starting point, then you can describe your vector giving only the ending point.

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