[Unity Game Development] the application of vector in game development (II.)

Source: Internet
Author: User

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.

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.