PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

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

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