本文整理汇总了C#中Vector2F.GetLength方法的典型用法代码示例。如果您正苦于以下问题:C# Vector2F.GetLength方法的具体用法?C# Vector2F.GetLength怎么用?C# Vector2F.GetLength使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vector2F
的用法示例。
在下文中一共展示了Vector2F.GetLength方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Transform2D
public void Transform2D(Vector2F[,] values, bool forward)
{
if (values == null)
throw new ArgumentNullException("values");
int nx = values.GetLength(0);
int ny = values.GetLength(1);
if (nx > _buffer.Length || ny > _buffer.Length)
throw new ArgumentException("The values array is too large for the current Capacity.");
// Values must contain n = 2^m elements.
int mx = (int)MathHelper.Log2GreaterOrEqual((uint)nx);
int my = (int)MathHelper.Log2GreaterOrEqual((uint)ny);
if ((1 << mx) > nx || (1 << my) > ny)
throw new ArgumentException("The number of values must be a power of two (e.g. 2, 4, 8, ...) in each dimension.");
// Transform the rows.
for (int j = 0; j < ny; j++)
{
for (int i = 0; i < nx; i++)
{
_buffer[i].X = values[i, j].X;
_buffer[i].Y = values[i, j].Y;
}
Transform1D(_buffer, nx, mx, forward);
for (int i = 0; i < nx; i++)
{
values[i, j].X = _buffer[i].X;
values[i, j].Y = _buffer[i].Y;
}
}
// Transform the columns.
for (int i = 0; i < nx; i++)
{
for (int j = 0; j < ny; j++)
{
_buffer[j].X = values[i, j].X;
_buffer[j].Y = values[i, j].Y;
}
Transform1D(_buffer, ny, my, forward);
for (int j = 0; j < ny; j++)
{
values[i, j].X = _buffer[j].X;
values[i, j].Y = _buffer[j].Y;
}
}
}
示例2: 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]));
}