In the previous blog, we talked about the use of the nature of vector direction to solve the problem. This blog will continue to use a simple small example to illustrate how to apply the vector's point-multiplication to the actual game development. geometric definition of vector point multiplication
In a two-dimensional space with two vectors U and V, with an angle of θ ([0,π]), the inner product is defined as the following real number:
Vector-point multiplication formula:u V = **| u| | v|**cosθ
According to the formula, you can return to the following three conclusions:
1. u V > 0, indicating that the angle between the vector U and V is less than 90 degrees (acute angle)
2. u V < 0, indicating that the angle between the vector U and V is greater than 90 degrees (obtuse)
3. u V = 0, which indicates that the angle between the vector U and V is 90 degrees (perpendicular to each other)
4. u V = 1, which means the vector U and V are in the same direction
5. u V =-1, indicating the opposite direction of the vector U and V
On the other definition of vector point multiplication, law and application of interested friends can refer to Baidu Encyclopedia, here is no longer wordy. This blog is mainly about how to apply the above three conclusions to game development. the application scenario of Vector point multiplication is to find the angle size of two vectors according to the vector point multiplication formula. According to conclusions 1 and 2, the angle between two vectors can be determined to limit the angle of two vectors. According to conclusion 3, the two vectors are judged to be perpendicular. The azimuth can be judged according to conclusions 4 and 5. You can tell whether an object is in front of or behind another object (or left or right).
Vector point multiplication How to determine whether an object is in front of or behind another object. This is well explained in the book 3D Mathematical Fundamentals: Graphics and Game development. The following is posted in the book:
Since you can judge the front or the back, of course, you can also judge the left or right, just choose the direction of the vector is different, left here to the reader to think.