本文整理汇总了C#中System.Random.NextVector2F方法的典型用法代码示例。如果您正苦于以下问题:C# Random.NextVector2F方法的具体用法?C# Random.NextVector2F怎么用?C# Random.NextVector2F使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Random
的用法示例。
在下文中一共展示了Random.NextVector2F方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform1D
public void Transform1D()
{
// Transform forward and inverse and compare with initial values.
var random = new Random(1234567);
var s = new Vector2F[16];
var t = new Vector2F[16];
for (int i = 0; i < s.Length; i++)
{
s[i] = random.NextVector2F(-10, 10);
t[i] = s[i];
}
FastFourierTransformF.Transform1D(t, true);
FastFourierTransformF.Transform1D(t, false);
for (int i = 0; i < s.Length; i++)
Assert.IsTrue(Vector2F.AreNumericallyEqual(s[i], t[i]));
}
示例2: Transform1DAs2DColumn
public void Transform1DAs2DColumn()
{
// Result of 2D with one row/column must be the same as 1D.
var fft = new FastFourierTransformF(16);
var random = new Random(1234567);
var s1D = new Vector2F[16];
var s2D = new Vector2F[16, 1];
for (int i = 0; i < s1D.Length; i++)
{
s1D[i] = random.NextVector2F(-10, 10);
s2D[i, 0] = s1D[i];
}
FastFourierTransformF.Transform1D(s1D, true);
fft.Transform2D(s2D, true);
for (int i = 0; i < s1D.Length; i++)
Assert.AreEqual(s1D[i], s2D[i, 0]);
}
示例3: NoiseRange2D
public void NoiseRange2D()
{
double min = double.MaxValue;
double max = double.MinValue;
var random = new Random(15485863);
for (int i = 0; i < 10000000; i++)
{
var v = random.NextVector2F(0, 255);
var n = PerlinNoise.Compute(v.X, v.Y);
min = Math.Min(min, n);
max = Math.Max(max, n);
}
Assert.IsTrue(min < 0 && min >= -1);
Assert.IsTrue(max > 0 && max <= 1);
}
示例4: Transform2D
public void Transform2D()
{
// Transform forward and inverse and compare with initial values.
var random = new Random(1234567);
var s = new Vector2F[16, 8];
var t = new Vector2F[16, 8];
for (int i = 0; i < s.GetLength(0); i++)
{
for (int j = 0; j < s.GetLength(1); j++)
{
s[i, j] = random.NextVector2F(-10, 10);
t[i, j] = s[i, j];
}
}
var fft = new FastFourierTransformF(16);
fft.Transform2D(t, true);
Assert.IsFalse(Vector2F.AreNumericallyEqual(s[0, 0], t[0, 0]));
fft.Transform2D(t, false);
for (int i = 0; i < s.GetLength(0); i++)
for (int j = 0; j < s.GetLength(1); j++)
Assert.IsTrue(Vector2F.AreNumericallyEqual(s[i, j], t[i, j]));
}