本文整理汇总了C#中System.Random.NormallyDistributedSingle方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NormallyDistributedSingle方法的具体用法?C# Random.NormallyDistributedSingle怎么用?C# Random.NormallyDistributedSingle使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.NormallyDistributedSingle方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Generate
protected internal override IEnumerable<Star> Generate(Random random)
{
var density = Math.Max(0, random.NormallyDistributedSingle(_densityDeviation, _densityMean));
var countMax = Math.Max(0, (int)(_size * _size * _size * density));
if (countMax <= 0)
yield break;
var count = random.Next(countMax);
for (int i = 0; i < count; i++)
{
var pos = new Vector3(
random.NormallyDistributedSingle(_deviationX * _size, 0),
random.NormallyDistributedSingle(_deviationY * _size, 0),
random.NormallyDistributedSingle(_deviationZ * _size, 0)
);
var d = pos.Length() / _size;
var m = d * 2000 + (1 - d) * 15000;
var t = random.NormallyDistributedSingle(4000, m, 1000, 40000);
yield return new Star(
pos,
StarName.Generate(random),
t
);
}
}
示例2: Generate
protected internal override IEnumerable<Star> Generate(Random random)
{
var count = Math.Max(0, random.NormallyDistributedSingle(_countDeviation, _countMean));
if (count <= 0)
yield break;
for (int i = 0; i < count; i++)
{
Vector3 center = new Vector3(
random.NormallyDistributedSingle(_deviationX, 0),
random.NormallyDistributedSingle(_deviationY, 0),
random.NormallyDistributedSingle(_deviationZ, 0)
);
foreach (var star in _basis.Generate(random))
yield return star.Offset(center);
}
}
示例3: GenerateArms
private IEnumerable<Star> GenerateArms(Random random)
{
int arms = random.Next(MinimumArms, MaximumArms);
float armAngle = (float) ((Math.PI * 2) / arms);
int maxClusters = (Size / Spacing) / arms;
for (int arm = 0; arm < arms; arm++)
{
int clusters = (int) Math.Round(random.NormallyDistributedSingle(maxClusters * ClusterCountDeviation, maxClusters));
for (int i = 0; i < clusters; i++)
{
//Angle from center of this arm
float angle = random.NormallyDistributedSingle(0.5f * armAngle * ClusterCenterDeviation, 0) + armAngle * arm;
//Distance along this arm
float dist = Math.Abs(random.NormallyDistributedSingle(Size * 0.4f, 0));
//Center of the cluster
var center = Vector3.Transform(new Vector3(0, 0, dist), Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), angle));
//Size of the cluster
var clsScaleDev = ArmClusterScaleDeviation * Size;
var clsScaleMin = MinArmClusterScale * Size;
var clsScaleMax = MaxArmClusterScale * Size;
var cSize = random.NormallyDistributedSingle(clsScaleDev, clsScaleMin * 0.5f + clsScaleMax * 0.5f, clsScaleMin, clsScaleMax);
var stars = new Sphere(cSize, densityMean: 0.00025f, deviationX: 1, deviationY: 1, deviationZ: 1).Generate(random);
foreach (var star in stars)
yield return star.Offset(center).Swirl(Vector3.UnitY, Swirl);
}
}
}
示例4: Generate
protected internal override IEnumerable<Star> Generate(Random random)
{
var centralVoidSize = random.NormallyDistributedSingle(CentralVoidSizeDeviation, CentralVoidSizeMean);
if (centralVoidSize < 0)
centralVoidSize = 0;
var centralVoidSizeSqr = centralVoidSize * centralVoidSize;
foreach (var star in GenerateArms(random))
if (star.Position.LengthSquared() > centralVoidSizeSqr)
yield return star;
foreach (var star in GenerateCenter(random))
if (star.Position.LengthSquared() > centralVoidSizeSqr)
yield return star;
foreach (var star in GenerateBackgroundStars(random))
if (star.Position.LengthSquared() > centralVoidSizeSqr)
yield return star;
}
示例5: GenerateStarColor
public static Vector3 GenerateStarColor(Random random)
{
var temp = random.NormallyDistributedSingle(7000, 6000, 1000, 40000);
return ConvertTemperature(temp);
}