本文整理汇总了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;
}