當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。