This commit is contained in:
Miloslav Ciz 2023-07-30 15:00:49 +02:00
parent 486c142b76
commit 9f32c8079a
12 changed files with 38 additions and 10 deletions

View file

@ -2,7 +2,7 @@
Vector is a basic mathematical object that expresses direction and magnitude (such as velocity, force etc.) and is usually expressed as an "array of numbers". For example in two dimensional space an array `[4,3]` expresses a vector pointing 4 units to the "right" (along X axis) and 3 units "up" (along Y axis) and has the magnitude 5 (which is the vector's length). Vectors are one of the very basic concepts of advanced math and are used almost in any advanced area of math, physics, programming etc. -- basically all of physics and engineering operates with vectors, programmers will mostly encounter them in areas such as 3D [graphics](graphics.md), [physics engines](physics_engine.md) (forces, velocities, acceleration, ...), [machine learning](machine_learning.md) (feature vectors, ...) or [signal processing](signals.md) (e.g. [Fourier transform](fourier_transform.md) just interprets a signal as a vector and transforms it to a different basis) etc. In this article we will implicitly focus on vectors from programmer's point of view (i.e. "arrays of numbers"), which to a mathematician will seem very simplified, but we'll briefly also foreshadow the mathematical view.
Just like in elemental mathematics we deal with "simple" numbers such as 10, -2/3 or [pi](pi.md) -- we retrospectively call such "simple" numbers **[scalars](scalar.md)** -- advanced mathematics generalizes the concept of such a number into vectors ("arrays of numbers", e.g. `[1,0,-3/5]` or `[0.5,0.5]`) and yet further to [matrices](matrix.md) ("two dimensional arrays of numbers") and defines a way to deal with such generalizations into **[linear algebra](linear_algebra.md)**, i.e. we have ways to add and multiply vectors and matrices and solve [equations](equation.md) with them, just like we did in elemental algebra (of course, linear algebra is a bit more complex as it mixes together scalars, vectors and matrices). In yet more advanced mathematics the concepts of vectors and matrices are further generalized to **[tensors](tensor.md)** which may also be seen as "N dimensional arrays of numbers" but further add new rules and interpretation of such "arrays" -- vectors can therefore be also seen as a tensor (of rank 1) -- note that in this context there is e.g. a fundamental distinction between row and column vectors. Keep in mind that vectors, matrices and tensors aren't the only possible generalization of numbers, another one is e.g. that of [complex numbers](complex_number.md), [quaternions](quaternion.md) etc. Anyway, in this article we won't be discussing tensors or any of the more advanced concepts further, they are pretty non-trivial and mostly beyond the scope of mere programmer's needs :) We'll keep it at linear algebra level.
Just like in elemental mathematics we deal with "simple" numbers such as 10, -2/3 or [pi](pi.md) -- we retrospectively call such "simple" numbers **[scalars](scalar.md)** -- advanced mathematics generalizes the concept of such a number into vectors ("arrays of numbers", e.g. `[1,0,-3/5]` or `[0.5,0.5]`) and yet further to [matrices](matrix.md) ("two dimensional arrays of numbers") and defines a way to deal with such generalizations into **[linear algebra](linear_algebra.md)**, i.e. we have ways to add and multiply vectors and matrices and solve [equations](equation.md) with them, just like we did in elemental algebra (of course, linear algebra is a bit more complex as it mixes together scalars, vectors and matrices). In yet more advanced mathematics the concepts of vectors and matrices are further generalized to **[tensors](tensor.md)** which may also be seen as "N dimensional arrays of numbers" but further add new rules and interpretation of such "arrays" -- vectors can therefore be also seen as a tensor (of rank 1) -- note that in this context there is e.g. a fundamental distinction between row and column vectors. Keep in mind that vectors, matrices and tensors aren't the only possible generalization of numbers, another one is e.g. that of [complex numbers](complex_number.md), [quaternions](quaternion.md), [p-adic numbers](p_adic.md) etc. Anyway, in this article we won't be discussing tensors or any of the more advanced concepts further, they are pretty non-trivial and mostly beyond the scope of mere programmer's needs :) We'll keep it at linear algebra level.
**Vector is not merely a coordinate**, though the traditional representation of it suggest such representation and programmers often use vector data types to store coordinates out of convenience (e.g. in 3D graphics engines vectors are used to specify coordinates of 3D objects); vector should properly be seen as a **direction and magnitude** which has **no position**, i.e. a way to correctly imagine a vector is something like an **arrow** -- for example if a vector represents velocity of an object, the direction (where the arrow points) says in which direction the object is moving and the magnitude (the arrow length) says how fast it is moving (its [speed](speed.md)), but it doesn't say the position of the object (the arrow itself records no position, it just "hangs in thin air").