Vector.2d:
Addition: A + B = (AX + bx), (Ay + ))
Meaning:A vector is connected to B vector at the beginning and end. Start with the starting point of a, and end with the end point of B is a + B
Subtraction:A-B = (ax-bx), (Ay-))
Meaning:The starting points of the two vectors overlap. The starting point from the end point of B to the end point of A is a-B.
Multiply by a constant:A * n = E = (N * ax, N * Ay)
Meaning:Multiply by a number greater than 0, the direction of the vector remains unchanged, but it is scaled up in the same direction. Multiply by a number smaller than 0, and then scale in the opposite direction. The constant size determines the degree of scaling.
Dot multiplication:A · B = A. x * B. x + A. y * B. Y
Meaning:The product of the length of a and the projection length of B on a, or the product of the length of B and the projection length of a on B. It is a scalar and can be positive or negative.
Basic Properties of vectors:
1)A + B = B +
2)(A + B) + C = a + (B + C)
3)A + 0 = 0 + A =
4)A + (-a) = 0
5)K * (L * a) = (k * l) * A = A * (K * l)
6)K * (a + B) = K * A + K * B
7)(K + l) * A = K * A + L *
8)1 * A =
9)A · B = B ·
10)A · (B + C) = A · B + A · C
11)K * (A · B) = (k * A) · B = A · (K * B)
12)0 · A = 0
13)A · A = | A | ^ 2
Vector movement:
V2.x = v1.x + VX; // VX represents the X direction shift
V2.y = v1.y + Vy; // Vy indicates y-direction displacement.
Vector projection:
Dp = v1.x * v2.x + v1.y * v2.y; // The result of V1 vector dot multiplication when DP is V0
DP is the projection length of V1 vector in the V2 vector direction, or v2 in the V1 direction. If DP is a positive number, the two vectors point to the same direction, and if it is a negative number, their direction is relative.
Projection vector:
Proj. VX = DP * v2.dx; proj. vy = DP * v2.dy // The projection vector of the V1 vector on the V2 vector. v2.dx and v2.dy represent the unit vectors of the V2 vector X and Y directions respectively.
Vector.3d:
There are two types of 3D Cartesian coordinate systems: Left-hand coordinate system and right-hand coordinate system. We use the left-hand coordinate system.
Because 2D is only a special case of 3D, vector characteristics in 3D. There are many similarities with 3D:
Vector equality:Each component is equal (v0.x = v1.x & v0.y = v1.y & v0.z = v1.z)
Vector Addition:Add each component (v0.x + v1.x, v0.y + v1.y, v0.z + v1.z)
Vector subtraction:Subtract each component (v0.x-v1.x, v0.y-v1.y, v0.z-v1.z)
Vector modulo:That is, the length of the vector.
Function getlength (): Number
{
Math. SQRT (V. x * v. x + v. y * v. Y + v. z * v. z );
}
Vector Normalization:Unit Vector
Function normalize (): void
{
VaR vlen: Number = math. SQRT (V. x * v. x + v. y * v. Y + v. z * v. z );
If (n! = 0)
{
V. x = V. X/vlen;
V. Y = V. Y/vlen;
V. z = V. Z/vlen;
}
}
Multiplication of vectors and scalar:= V0.x * k + v0.y * k + v0.z * K;
Point multiplication dot of a vector:= V0.x * v1.x + v0.y * v1.y + v0.z * v1.z;
We often use dot multiplication to calculate the angle between two vectors, as shown below: (v0 dot V1 = | V0 | * | V1 | * Cos (θ) (θ is the angle between two vectors)
θ = math. ACOs (v0 dot V1/| V0 | * | V1 | );
P.s:
V0 dot V1 = 0
The two vectors are perpendicular to each other.
V0 dot V1> 0
The angle between two vectors is less than 90 degrees.
V0 dot V1 <0
The angle between two vectors is greater than 90 degrees.
(*) Cross:
The result of the Cross-multiplication of a vector is also a vector, which is the vertical and cross-multiplication vector.
The vector direction is determined by the left-hand rule, that is, the left hand is bent from the first vector to the second vector, and the direction pointed by the left-hand thumb is obtained.
V0 = (x0, y0, z0), V1 = (x1, Y1, Z1 ).
V0 cross V1 = (y0 * Z1-Y1 * z0, z0 * x1-z1 * x0, x0 * Y1-X1 * y0)
If the two vectors have the same or opposite direction, their result vector is a zero vector.
The main application of the Cross multiplication of vectors is the method vector:
Assume that the vertex of a triangle is P0, P1, P2. The method of vector query is as follows:
VaR V1 = (p1.x-Snapshot X, p1.y-Snapshot y, p1.z-Snapshot Z );
VaR v2 = (p2.x-rjx, p2.y-1_y, p2.z-1_z );
Normal Vector v = V1 cross V2;