Advertisement
Guest User

Helper.cs

a guest
Oct 5th, 2017
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. /// <summary>
  2. /// This class is used to store common funcions across the game
  3. /// </summary>
  4. public static class Helper
  5. {
  6.  
  7. /// <summary>
  8. /// Returns a list of positions
  9. /// </summary>
  10. /// <param name="radius">Radius of the circle</param>
  11. /// <param name="nPositions">Number of positions to calculate</param>
  12. /// <returns></returns>
  13. public static List<Vector2> GetCirclePositions(float radius, float nPositions)
  14. {
  15. float degrees = 0;
  16. float radian = 0f;
  17. float x;
  18. float y;
  19.  
  20. List<Vector2> result = new List<Vector2>();
  21.  
  22. for (int i = 0; i < nPositions; i++)
  23. {
  24. degrees = i * (360 / nPositions);
  25. radian = (degrees * ((float)Math.PI / 180));
  26. x = radius * (float)Math.Sin(radian);
  27. y= radius * (float)Math.Cos(radian);
  28.  
  29. result.Add(new Vector2(x, y));
  30. }
  31. return result;
  32. }
  33.  
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement