Basic knowledge of vectors
Vector has only two properties: direction length (note: Vector temperament does not contain location information)
Vector equality is the equality of its two attributes
Vector processing marker Position: When the starting point of the vector coincides with the origin of the coordinates, so that we can use the end coordinates of the vector to describe a vector in the standard position
0 Vectors: All components are 0 = (0,0,0)
Three special vectors are referred to as the standard base vectors of R3: These vectors are called i,j,k vectors, respectively, in the same direction as the X, Y, Z axis of the coordinate system and are 1 in length.
Vector equal
Vectors are equal in orientation and length.
Calculate the length of a vector
In geometry, the modulus of a vector is the length of a directed segment. We can calculate the size of the vector by algebraic method.
In the D3DX library, you can use the D3dxvec3length function to derive
Normalization of vectors
The normalization of vectors is to change the modulus of the vector to 1, which becomes the unit vector. vector Normalization can be achieved by dividing each component of the vector by the modulus of the vector.
Vector u (x, y, z) normalized after u (x/| | u| |,y/| | u| |,z/| | u| |)
Addition of vectors
Adding the first component of a vector is the addition of a vector.
U + V = (UX+VX,UY+VY,UZ+VZ)
Subtraction of vectors
Multiplication (vector with a scalar multiplicative result for the constant amount)
The multiplication is multiplied by a scalar, which scales the vector
Dot product (vector multiplied by vector results in a scalar)
The above equation does not clearly reflect the geometrical meaning. Using the cosine law, we can find their relationship.
U V =|u| * |v| * cosθ, which indicates that the dot product of two vectors is the cosine product of their modulus and angle. So, if you and V are both unit vectors, then u V is the cosine of their angle.
Some useful features in dot product
if u v = 0, then u⊥v.
if u V > 0, then two vectors have an angle of θ less than 90 degrees.
if u V < 0, then two vectors with an angle of θ greater than 90 degrees
Cross product (vector and vector multiplication result is always amount)
Unlike dot product (the result is a title), the result of the cross product is another vector. The vector p is perpendicular to u and V by multiplying the two vectors from U and V to get another vector p. In other words, the vector p is perpendicular to u and perpendicular to U.
Using D3dxvec3cross to calculate cross product of two vectors in D3DX library
Vector fork multiplication How to calculate such as Vector a= (b=), the calculation process of B (4,5,6) A fork is what should be, for the detailed
Set A= (X1,Y1,Z1), b= (X2,Y2,Z2),
axb= (Y1Z2-Y2Z1,Z1X2-Z2X1,X1Y2-X2Y1)
(X-ray) × (4,5,6) = (12-15,12-6,5-8) = ( -3,6,-3)
Vectors in 3d