Colin McMillen 2020-02-13 22:53:50 +00:00
parent 04ccc9094b
commit 8bb95a08d1

13
Code-Snippets.md Normal file

@ -0,0 +1,13 @@
```csharp
public static class Geometry {
public static bool PointInCone(
float visionRangeSq, float fovCos, Vector2 eyePos, Vector2 direction, Vector2 test) {
Vector2 delta = Vector2.Subtract(test, eyePos);
if (delta.LengthSquared() > visionRangeSq) {
return false;
}
float dot = Vector2.Dot(Vector2.Normalize(direction), Vector2.Normalize(delta));
return dot > fovCos;
}
}
```