I. Question proposal
We know that an n-dimensional vector A and a scalar K can perform scalar multiplication to obtain vector B --
B = Ka
So, if we only know the vectors a and B of the two collinearity, how can we find K --
K = B/a =?
Ii. Solution
We can take (dot product) ""--
K = B/
= (B. a)/(A.)
= (B. a)/(| A | ^ 2)
= (B1 * A1 + B2 * A2 + B3 * A3 +... + BN * an)/(A1 * A1 + A2 * A2 + A3 * A3 +... + an *)
Iii. geometric interpretation and promotion to non-linear Vectors
First, let's recall the ry of the dot product of the vector.Algorithm--
A. B = | A | * | B | * Cos (th)
Note: TH is the angle between two vectors.
Divide the formula above by | A | (modulus of vector A) to obtain the modulus of projection of vector B on vector --
| Prj (B) A | = | A | * | B | * Cos (th)/| A | = | B | * Cos (th)
Divide the projection modulus by | A |, which is the ratio of the projection modulus to the total length --
K = | prj (B) A |/| A | = (| B |/| A |) * Cos (th)
It is obvious for a linear vector that is the scalar K value previously sought.
For non-linear vectors, It is the correlation K value of the projection vector.
That is to say, the Division has a value (unless a is a zero vector) regardless of the collinearity ).
This feature is often useful. For example, when writing a graphic editing system, you need to calculate which part of the line segment is the click position. Because the number of coordinates clicked by the mouse is a rational number (scale), and the slope of the line segment may be an irrational number, this will cause the two vectors to be non-linear. The division algorithm in this article can handle this situation steadily. In addition, the projection vector is more in line with the general operation habits.