本文整理汇总了C#中IRandomGenerator.Generate方法的典型用法代码示例。如果您正苦于以下问题:C# IRandomGenerator.Generate方法的具体用法?C# IRandomGenerator.Generate怎么用?C# IRandomGenerator.Generate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRandomGenerator
的用法示例。
在下文中一共展示了IRandomGenerator.Generate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OffsetRandom
/// <summary>
/// Offsets this coordinate in a random direction.
/// </summary>
/// <param name="randomGenerator"></param>
/// <param name="meter"></param>
/// <returns></returns>
public GeoCoordinate OffsetRandom(IRandomGenerator randomGenerator, Meter meter)
{
GeoCoordinate offsetCoordinate = this.OffsetWithDistances(meter.Value /
System.Math.Sqrt(2));
double offsetLat = offsetCoordinate.Latitude - this.Latitude;
double offsetLon = offsetCoordinate.Longitude - this.Longitude;
offsetLat = (1.0 - randomGenerator.Generate(2.0)) * offsetLat;
offsetLon = (1.0 - randomGenerator.Generate(2.0)) * offsetLon;
return new GeoCoordinate(this.Latitude + offsetLat, this.Longitude + offsetLon);
}
示例2: GenerateRandomIn
/// <summary>
/// Generates a random point within this box.
/// </summary>
/// <param name="rand"></param>
/// <returns></returns>
public GeoCoordinate GenerateRandomIn(IRandomGenerator rand)
{
double lat = (double)rand.Generate(1.0) * this.DeltaLat;
double lon = (double)rand.Generate(1.0) * this.DeltaLon;
return new GeoCoordinate(this.MinLat + lat,
this.MinLon + lon);
}