Login

Fancade Wiki

Updated image

... ...
@@ -42,11 +42,11 @@ The dot product of two [[unit vector|Normalize]]s outputs the cosine of the angl
42 42
- Normalize the two input vectors first.
43 43
- Get the output of the dot product and divide it by the product of the two input vectors' length.
44 44
45
[[/uploads/20210106_122008.jpg]]
45
[[/uploads/IMG_20220625_162102.jpg]]
46 46
47 47
To find the angle, we then use the inverse cosine function:
48 48
49
[[/uploads/Screenshot_20210106-121820_Fancade.jpg]]
49
[[/uploads/IMG_20220625_164709.jpg]]
50 50
51 51
Here is another example, there is a guard facing a direction with a FOV of 90° (highlighted in green) and a ninja sneaking up on him. How can we check if the ninja is on sight?
52 52
... ...
@@ -54,7 +54,7 @@ Here is another example, there is a guard facing a direction with a FOV of 90°
54 54
55 55
The first input for the dot product is the direction that the guard is facing, the second input is the vector from the guard's position to the ninja's position. Then we compare the cosine of the angle formed by those two vector with the cosine of half the FOV:
56 56
57
[[/uploads/Screenshot_20210106-135840_Fancade.jpg]]
57
[[/uploads/IMG_20220625_165556.jpg]]
58 58
59 59
Let me explain the script:
60 60
- First we subtract the ninja's position by the guard's position. Then we normalize the vector before the dot product.
Fancade Wiki