3D Mathematical Basis---vector in the unity3d of "Unity3d game development"

Source: Internet
Author: User

Tags: and LAN formula HTML Relationship common factor input allowed

Vectors are the standard tool for 2D and 3D Mathematical research, and in 3D games vectors are the basis. Therefore, it is very important to master some basic concepts and properties of vectors and common operation methods. In this blog, horse and everyone to review and learn about the Unity3d in the common 3D mathematics knowledge.

I. Vector concepts and basic definitions 1, mathematical definitions of vectors
    • A vector is a list of numbers, and for programmers, a vector is an array.
    • The dimension of a vector is the number of "numbers" contained in a vector, which can have any positive dimension, and a scalar can be considered a one-dimensional vector.
    • When writing a vector, enclose a number of columns in square brackets, such as a vector called a line vector that is written vertically by [all-in-one] horizontally, called a column vector .
2, the geometric meaning of the vector
    • In a geometrical sense, a vector is a directed segment with a size and direction. The size of the vector is the length (modulus) vector of the vector has a non-negative length.
    • The direction of the vector describes the point of the vector in space.
    • Vector form: Two elements of the vector definition-size and direction, sometimes need to refer to the head and tail of the vector, shown that the arrow is the end of the vector, the tail of the arrow is the beginning of the vector
    • The number in the vector expresses the directed displacement of the vector on each dimension, such as a 2D vector that lists displacements along the x-coordinate and y-coordinate directions.
3, Vector and point
    • "Point" has a position, but no actual size or thickness, "vector" has size and direction, but no position. So the purpose of using "point" and "vector" is completely different. "Point" describes the position, "vector" describes the displacement.
4. The relationship between points and vectors:
    • Any point can be expressed using vectors starting from the origin.

Vector operations 1, 0 vectors
    • The 0 vector is very special because it is the only vector of zero size. For any other number of M, there are countless vectors of multiple sizes (modulo) to M, and they form a circle. The 0 vector is also the only vector without a direction.
2, Negative vector
    • Negative operators can also be applied to vectors. Each vector v has an additive inverse-V, whose dimensions and V satisfy v+ (-V) = 0. In order to get the negative vectors of any dimension vector, we simply have to turn each component of the vector into a negative one.
    • Geometric interpretation: Negative to the vector, you will get a vector of equal size and opposite direction.
3. Vector size (length or modulus)
  • In linear algebra, the size of a vector is represented by a double vertical line on either side of the vector, which is the square root of the sum of squares of the vector components.
    || v| | =√ (x^2+y^2) (2D vector v)
    || v| | =√ (x^2+y^2+z^2) (3D vector v)
  • Geometrical interpretation: in 2D arbitrary vector v, can construct a V for the hypotenuse of the direct triangle, by the Pythagorean theorem, for any right triangle, the length of the hypotenuse is equal to two square of the right angle side length squared sum. || v| | ^2 = x^2 + y^2
4. Multiplication of scalar and vector
    • Although scalars and vectors cannot be added together, they can be multiplied. The result will be a vector. Parallel to the original vector, but with different lengths or opposite directions.
    • The multiplication of scalars and vectors is very straightforward, and each component of a vector is multiplied by a scalar. such as: k[x,y,z] = [XK,YK,ZK]
    • A vector can also be divided by a nonzero vector, and the effect is equal to the inverse of the scalar. such as: [x,y,z]/k = [x/k,y/k,z/k]
    1. When a scalar is multiplied by a vector, it does not require some multiplication sign, and the two quantities are multiplied by the write.
    2. Multiplication and division precedence of scalar and vector is higher than addition and multiplication
    3. A scalar cannot be divided by a vector, and the vector cannot be divided by another vector.
    4. A negative vector can be thought of as a special case of multiplication multiplied by a scalar-1.
    • Geometric interpretation: the effect of multiplying a vector by a scalar k is to scale the length of the vector with factor |k|, for example: to double the length of the vector, multiply the vector by 2. If k<0, the direction of the vector is reversed.
5. Standardized vectors
    • For many vectors, we only care about the direction of the vector, which doesn't care about the size of the vector, such as: "What direction do I face?" "In such cases, it is very convenient to use a unit vector, which is a vector of size 1, and the unit vectors are often referred to as normalized vectors or normals.
    • For any nonzero vector v, you can calculate a unit vector K, which is the same as the V direction, which is called "normalization" of the vector, which is normalized by dividing the vector by its size (modulo). k=v/| | v| |,v!=0;
    • 0 vectors can not be standardized, mathematically this is not allowed, because will result in dividing by 0, geometrically also meaningless, 0 vectors have no direction.
    • Geometric interpretation: In a 2D environment, if a unit vector is drawn at the origin, then the head of the vector will touch the unit circle at the origin of the center point. The unit vector in the environment will touch the unit ball.
6. Addition and subtraction of vectors
    • The two vectors have the same number of dimensions, so they can be added or subtracted. The dimension of the result vector is the same as the original vector. The notation of the addition and subtraction of vectors is the same as that of scalar plus subtraction. Example: [x, Y, z] + [a,b,c] = [X+a,y+b,z+c]
    • Subtraction is interpreted as a negative vector, a-b=a+ (-B) For example: [X,y,z]–[a,b,c] = [X-a,y-b,c-z]
    • Vectors cannot be added and reduced by a scalar or a different number of dimensions.
    • Like scalar addition, the vector addition satisfies the commutative law, but the vector subtraction does not satisfy the commutative law, there is always a+b = B+a, but a-b=-(b-a), only when A=b, a-B = b-a
    • Geometry interpretation: The geometry of vector A and vector b is interpreted as: translation vector, so that the head of vector a joins the tail of vector B, and then a vector from the tail of a to the head of B. This is the "triangle law" of vector addition.
    • It is a very common requirement to calculate the displacement of a point to another point, which can be solved by using the triangle rule and vector subtraction, such as: d-c calculates the displacement vector from C to D .
7. Distance formula
    • The distance formula is used to calculate the distance between two points. From the above can be learned that the displacement vector between two points through the vector subtraction can be learned that since the two points of the displacement vector, then the displacement vector to find the modulus, you can calculate the displacement between two points.
8, Vector point multiplication

The result of multiplying the two vectors is a scalar. This scalar is equal to the cosine of the two vector length multiplication result and then multiplying the angle between the vectors. When all two vectors are unit vectors, the cosine is defined as the projection length (or vice versa) of the first vector above the second vector, and the order of the parameters is not important.

    • scalars and vectors can be multiplied, and vectors and vectors can also be multiplied. There are two different kinds of multiplication, the point multiplication , the cross-multiply
    • The notation of the point multiplication comes to the point in the A B. As with scalar and vector multiplication, vector-point multiplication takes precedence over addition and subtraction. Scalar multiplication and scalar and vector multiplication can omit multiplication sign, but the point multiplication sign cannot be omitted in Vector point multiplication. the vector-point multiplication is the sum of the corresponding component products.     The result is a scalar. [X,y,z] [A,b,c] = Ax+by+cz;
    • Geometrical interpretation: In general, the point multiplication results describe the "similarity" degree of two vectors, the greater the result of the multiplication, the closer the two vectors are, the correlation between the point multiplication and the vector to calculate the angle between the two vectors θ= arccos (a b)
    • Some of the main cosine values in the following icons are often used:
9. Vector projection
    • Given two vectors v and N, the V can be decomposed into two components, which are vertically and peacefully line to the vector N, and satisfy the two vectors to add equal to the vector V, generally referred to as the parallel component V on the vector n projection.
    • Parallel Component Formula : Parallel component = n(v· n)/| | N| | ^2
    • Vertical Component formula: Vertical component = | | v| | – N(v· n)/| | N| | ^2
10. Vector Fork Multiplication

A fork can only be used to calculate a 3D vector, it needs to input two vectors to return the result is another vector. The resulting result is perpendicular to the two vectors of the input. The left-handed coordinate system can be used to represent the direction of the input and output vectors. If the first argument matches the thumb and forefinger of the hand to match the second parameter, the result will be the middle finger direction. If the order of the arguments is reversed, the resulting vector will point to the exact opposite direction, but will have the same length. The size of the result of the Vector fork is equal to the product of the input vector and then multiplied by the sinusoidal value of the angle between them.

    • The vector fork is multiplied to get a vector and does not satisfy the commutative law. It satisfies the inverse commutative law Axb =-(BXA) Fork multiplication formula: [X,y,z]x[a,b,c] = [Yc-zb, ZA-XC, Xb-ya]
    • When the point multiplication and the fork multiply together, the fork multiplication is first calculated, A. BXC = A. (BXC) Because the point multiplication returns a scalar, and the scalar and the vector cannot be cross-multiplied.
    • Geometric interpretation: the vector obtained by the fork is perpendicular to the original two vectors.
    • The length of the AXB equals the size of the vector and the sum of the sin of the vector angle, | | a x b| | = || a| | || B| | Sinθ| | a x b| | Also equal to a and b for both sides of the usual quadrilateral area.
    • The most important application of cross-multiplication is to create a vector perpendicular to the plane, triangle, and polygon.
11. Scalar Multiplication and division
    • When we discuss the vector, it often uses his scalar as an ordinary number (for example, a float value). This means that the scalar is only size, not the size and direction of the vector. The
    • vector is multiplied by a scalar direction and position still in its original direction and position. However, the size of the new vector is equal to the original size multiplied by the scalar.
    • Similarly, the result of a scalar division is one of a few scalars. These operations are useful when the
    • vector represents a move or force. They allow you to change the size of the vector without affecting its direction.

Any vector divided by his own size, the result is a vector of length 1, which is called the unit vector. If a unit vector is multiplied by a scalar, the length of the result will be a scalar size. When the direction of the force is constant, but the force is controllable. This is very useful. (for example, the force of a car's wheels is always forward, but the size of the force is controlled by the driver).                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                              /    &nbsp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                                         ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                          ,         &NB Sp                                                            ,         &N Bsp                          ,         &NB Sp                          ,         &NB Sp                              

Horse Lad
Source: http://www.cnblogs.com/msxh/p/6156004.html
Please respect the results of other people's work, let the sharing become a virtue, welcome reprint. In addition, the article in the expression and code, if there is inappropriate, welcome criticism. Leave your footprints and welcome the comments!

3D Mathematical Basis---vector in the unity3d of "Unity3d game development"

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

Tags Index: