/Main/src/DynamicDataDisplay/Common/RandomExtensions.cs

# · C# · 28 lines · 25 code · 3 blank · 0 comment · 0 complexity · 114805d942debc824340cddc4cec6fbd MD5 · raw file

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Windows;
  6. namespace Microsoft.Research.DynamicDataDisplay.Common
  7. {
  8. internal static class RandomExtensions
  9. {
  10. public static Point NextPoint(this Random rnd)
  11. {
  12. return new Point(rnd.NextDouble(), rnd.NextDouble());
  13. }
  14. public static Point NextPoint(this Random rnd, double xMin, double xMax, double yMin, double yMax)
  15. {
  16. double x = rnd.NextDouble() * (xMax - xMin) + xMin;
  17. double y = rnd.NextDouble() * (yMax - yMin) + yMin;
  18. return new Point(x, y);
  19. }
  20. public static Vector NextVector(this Random rnd)
  21. {
  22. return new Vector(rnd.NextDouble(), rnd.NextDouble());
  23. }
  24. }
  25. }