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


C# Vector2d.Normalized方法代码示例

本文整理汇总了C#中Vector2d.Normalized方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2d.Normalized方法的具体用法?C# Vector2d.Normalized怎么用?C# Vector2d.Normalized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Vector2d的用法示例。


在下文中一共展示了Vector2d.Normalized方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateWaves

        private List<Gerstner2.Settings> CreateWaves(double angle, double wavelength, double amplitude, double steepness)
        {
            var waveSettings = new List<Gerstner2.Settings>();
            var random = new Random(4711);
            int waves = 5;
            for (var i = 0; i < waves; i++)
            {
                var waveLengthFactor = wavelength * 2 - wavelength / 2;
                var minWaveLength = wavelength / 2;
                var nextDouble = random.NextDouble();
                var waveLength2 = minWaveLength + nextDouble * waveLengthFactor;

                var amplitudeSpan = amplitude * 2 - amplitude / 2;
                var minAmplitude = amplitude / 2;
                var amplitude2 = minAmplitude + nextDouble * amplitudeSpan;

                var frequency = CalculateFrequency(waveLength2);

                var directionRad = angle + (random.NextDouble() - 0.5);
                var direction = new Vector2d(Math.Cos(directionRad), Math.Sin(directionRad));

                //How to handle the amplitude is a matter of opinion. Although derivations of wave amplitude as a function of wavelength and current weather conditions probably exist,
                //we use a constant (or scripted) ratio, specified at authoring time. More exactly, along with a median wavelength, the artist specifies a median amplitude.
                //For a wave of any size, the ratio of its amplitude to its wavelength will match the ratio of the median amplitude to the median wavelength.

                var q = steepness / (frequency * amplitude2 * waves);

                var s = new Gerstner2.Settings
                {
                    Direction = direction.Normalized(),
                    WaveLength = waveLength2,
                    Frequency = frequency,
                    Steepness = steepness,
                    Phase = nextDouble,
                };

                waveSettings.Add(s);
            }

            return waveSettings;
        }
开发者ID:smoothdeveloper,项目名称:ProceduralGeneration,代码行数:41,代码来源:OceanSystem.cs


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