Advertisement
Guest User

Untitled

a guest
Jul 16th, 2015
853
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.89 KB | None | 0 0
  1. using System;
  2.  
  3. using Rage;
  4.  
  5. public static class Vector3Extension
  6. {
  7. public static Vector3 Around(this Vector3 start, float radius)
  8. {
  9. // Random direction.
  10. Vector3 direction = Vector3Extension.RandomXY();
  11. Vector3 around = start + (direction * radius);
  12. return around;
  13. }
  14.  
  15. public static float DistanceTo(this Vector3 start, Vector3 end)
  16. {
  17. return (end - start).Length();
  18. }
  19.  
  20. public static Vector3 RandomXY()
  21. {
  22. Random random = new Random(Environment.TickCount);
  23.  
  24. Vector3 vector3 = new Vector3();
  25. vector3.X = (float)(random.NextDouble() - 0.5);
  26. vector3.Y = (float)(random.NextDouble() - 0.5);
  27. vector3.Z = 0.0f;
  28. vector3.Normalize();
  29. return vector3;
  30. }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement