当前位置: 首页>>代码示例>>C#>>正文


C# Random.NormallyDistributedSingle方法代码示例

本文整理汇总了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
                );
            }
        }
开发者ID:Quantumplation,项目名称:CasualGodComplex,代码行数:27,代码来源:Sphere.cs

示例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);
            }
        }
开发者ID:Quantumplation,项目名称:CasualGodComplex,代码行数:18,代码来源:Cluster.cs

示例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);
                }
            }
        }
开发者ID:martindevans,项目名称:CasualGodComplex,代码行数:32,代码来源:Spiral.cs

示例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;
        }
开发者ID:martindevans,项目名称:CasualGodComplex,代码行数:19,代码来源:Spiral.cs

示例5: GenerateStarColor

        public static Vector3 GenerateStarColor(Random random)
        {
            var temp = random.NormallyDistributedSingle(7000, 6000, 1000, 40000);

            return ConvertTemperature(temp);
        }
开发者ID:Quantumplation,项目名称:CasualGodComplex,代码行数:6,代码来源:StarColor.cs


注:本文中的System.Random.NormallyDistributedSingle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。