Advertisement
Chronos_Ouroboros

Untitled

Apr 1st, 2018
434
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. static Vector2, Vector2 CalculateSmallestAABB (Array<Vector2> points) {
  2. Vector2 origin = (int.Max, int.Max);
  3. Vector2 size = (int.Min, int.Min);
  4.  
  5. for (int i = 0; i < points.Size (); i++) {
  6. Vector2 vertex = points [0];
  7.  
  8. // Origin
  9. origin.X = min (origin.X, vertex.X);
  10. origin.Y = min (origin.Y, vertex.Y);
  11. // Size
  12. size.X = max (size.X, vertex.X);
  13. size.Y = max (size.Y, vertex.Y);
  14. }
  15.  
  16. return origin, size;
  17. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement