style: apply whitespace formatting to motion tests
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
6 files changed
+31
-31
No files matched your search
@@ -44,8 +44,8 @@ public sealed class GeometryStageTests
|
|||||||
{
|
{
|
||||||
using var ramp = new ImageBuffer(64, 64, 1);
|
using var ramp = new ImageBuffer(64, 64, 1);
|
||||||
for (var y = 0; y < 64; y++)
|
for (var y = 0; y < 64; y++)
|
||||||
for (var x = 0; x < 64; x++)
|
for (var x = 0; x < 64; x++)
|
||||||
ramp[0, x, y] = 0.01f * x + 0.005f * y;
|
ramp[0, x, y] = 0.01f * x + 0.005f * y;
|
||||||
using var output = new ImageBuffer(64, 64, 1);
|
using var output = new ImageBuffer(64, 64, 1);
|
||||||
var map = Affine2D.About(Affine2D.Similarity(0.8, 0.2, 0, 0), 32, 32);
|
var map = Affine2D.About(Affine2D.Similarity(0.8, 0.2, 0, 0), 32, 32);
|
||||||
GeometryStage.Warp(ramp, output, map);
|
GeometryStage.Warp(ramp, output, map);
|
||||||
@@ -110,13 +110,13 @@ public sealed class GeometryStageTests
|
|||||||
{
|
{
|
||||||
using var checker = new ImageBuffer(256, 256, 1);
|
using var checker = new ImageBuffer(256, 256, 1);
|
||||||
for (var y = 0; y < 256; y++)
|
for (var y = 0; y < 256; y++)
|
||||||
for (var x = 0; x < 256; x++)
|
for (var x = 0; x < 256; x++)
|
||||||
checker[0, x, y] = (x + y) % 2 == 0 ? 1f : 0f;
|
checker[0, x, y] = (x + y) % 2 == 0 ? 1f : 0f;
|
||||||
using var small = GeometryStage.Apply(checker, new GeometrySettings { OutputWidth = 64 });
|
using var small = GeometryStage.Apply(checker, new GeometrySettings { OutputWidth = 64 });
|
||||||
Assert.Equal(64, small.Height);
|
Assert.Equal(64, small.Height);
|
||||||
for (var y = 2; y < 62; y++)
|
for (var y = 2; y < 62; y++)
|
||||||
for (var x = 2; x < 62; x++)
|
for (var x = 2; x < 62; x++)
|
||||||
Assert.Approximately(0.5, small[0, x, y], 0.02);
|
Assert.Approximately(0.5, small[0, x, y], 0.02);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
|
|||||||
@@ -74,13 +74,13 @@ public sealed class MotionBlurTests
|
|||||||
using var source = Texture();
|
using var source = Texture();
|
||||||
using var motion = new MotionField(Size, Size, 2);
|
using var motion = new MotionField(Size, Size, 2);
|
||||||
for (var j = 0; j < motion.Rows; j++)
|
for (var j = 0; j < motion.Rows; j++)
|
||||||
for (var i = 0; i < motion.Columns; i++)
|
for (var i = 0; i < motion.Columns; i++)
|
||||||
{
|
{
|
||||||
// A smooth swirl: magnitude up to ~6 px.
|
// A smooth swirl: magnitude up to ~6 px.
|
||||||
var k = j * motion.Columns + i;
|
var k = j * motion.Columns + i;
|
||||||
motion.U[k] = (float)(6 * double.Sin(j * 0.1));
|
motion.U[k] = (float)(6 * double.Sin(j * 0.1));
|
||||||
motion.V[k] = (float)(4 * double.Cos(i * 0.08));
|
motion.V[k] = (float)(4 * double.Cos(i * 0.08));
|
||||||
}
|
}
|
||||||
using var output = new ImageBuffer(Size, Size);
|
using var output = new ImageBuffer(Size, Size);
|
||||||
new MotionBlurRenderer().Render(source, motion, 1.0, output);
|
new MotionBlurRenderer().Render(source, motion, 1.0, output);
|
||||||
for (var c = 0; c < 3; c++)
|
for (var c = 0; c < 3; c++)
|
||||||
@@ -98,11 +98,11 @@ public sealed class MotionBlurTests
|
|||||||
double sum = 0;
|
double sum = 0;
|
||||||
var n = 0;
|
var n = 0;
|
||||||
for (var y = margin; y < Size - margin; y++)
|
for (var y = margin; y < Size - margin; y++)
|
||||||
for (var x = margin; x < Size - margin; x++)
|
for (var x = margin; x < Size - margin; x++)
|
||||||
{
|
{
|
||||||
sum += plane[y * Size + x];
|
sum += plane[y * Size + x];
|
||||||
n++;
|
n++;
|
||||||
}
|
}
|
||||||
return sum / n;
|
return sum / n;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -85,11 +85,11 @@ public sealed class OpticalFlowTests
|
|||||||
Assert.Equal(3, field.Columns);
|
Assert.Equal(3, field.Columns);
|
||||||
Assert.Equal(2, field.Rows);
|
Assert.Equal(2, field.Rows);
|
||||||
for (var j = 0; j < field.Rows; j++)
|
for (var j = 0; j < field.Rows; j++)
|
||||||
for (var i = 0; i < field.Columns; i++)
|
for (var i = 0; i < field.Columns; i++)
|
||||||
{
|
{
|
||||||
field.U[j * field.Columns + i] = i;
|
field.U[j * field.Columns + i] = i;
|
||||||
field.V[j * field.Columns + i] = 2 * j;
|
field.V[j * field.Columns + i] = 2 * j;
|
||||||
}
|
}
|
||||||
var (u, v) = field.Sample(6, 2);
|
var (u, v) = field.Sample(6, 2);
|
||||||
Assert.Approximately(1.5, u, 1e-6);
|
Assert.Approximately(1.5, u, 1e-6);
|
||||||
Assert.Approximately(1, v, 1e-6);
|
Assert.Approximately(1, v, 1e-6);
|
||||||
|
|||||||
@@ -22,8 +22,8 @@ public sealed class PlaneOpsTests
|
|||||||
{
|
{
|
||||||
var window = new List<float>();
|
var window = new List<float>();
|
||||||
for (var dy = -radius; dy <= radius; dy++)
|
for (var dy = -radius; dy <= radius; dy++)
|
||||||
for (var dx = -radius; dx <= radius; dx++)
|
for (var dx = -radius; dx <= radius; dx++)
|
||||||
window.Add(source[int.Clamp(y + dy, 0, Height - 1) * Width + int.Clamp(x + dx, 0, Width - 1)]);
|
window.Add(source[int.Clamp(y + dy, 0, Height - 1) * Width + int.Clamp(x + dx, 0, Width - 1)]);
|
||||||
window.Sort();
|
window.Sort();
|
||||||
Assert.Equal(window[window.Count / 2], output[y * Width + x]);
|
Assert.Equal(window[window.Count / 2], output[y * Width + x]);
|
||||||
}
|
}
|
||||||
@@ -44,8 +44,8 @@ public sealed class PlaneOpsTests
|
|||||||
{
|
{
|
||||||
double sum = 0;
|
double sum = 0;
|
||||||
for (var dy = -radius; dy <= radius; dy++)
|
for (var dy = -radius; dy <= radius; dy++)
|
||||||
for (var dx = -radius; dx <= radius; dx++)
|
for (var dx = -radius; dx <= radius; dx++)
|
||||||
sum += source[int.Clamp(y + dy, 0, Height - 1) * Width + int.Clamp(x + dx, 0, Width - 1)];
|
sum += source[int.Clamp(y + dy, 0, Height - 1) * Width + int.Clamp(x + dx, 0, Width - 1)];
|
||||||
Assert.Approximately(sum / ((2 * radius + 1) * (2 * radius + 1)), output[y * Width + x], 1e-5);
|
Assert.Approximately(sum / ((2 * radius + 1) * (2 * radius + 1)), output[y * Width + x], 1e-5);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -158,8 +158,8 @@ public sealed class StabilizerTests
|
|||||||
private static IEnumerable<(double X, double Y)> GridPoints()
|
private static IEnumerable<(double X, double Y)> GridPoints()
|
||||||
{
|
{
|
||||||
for (var j = 1; j <= 3; j++)
|
for (var j = 1; j <= 3; j++)
|
||||||
for (var i = 1; i <= 3; i++)
|
for (var i = 1; i <= 3; i++)
|
||||||
yield return (Width * i / 4.0, Height * j / 4.0);
|
yield return (Width * i / 4.0, Height * j / 4.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static double Gaussian(Random random)
|
private static double Gaussian(Random random)
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ public sealed class TemporalStackerTests
|
|||||||
{
|
{
|
||||||
// An aircraft light streak crossing one frame.
|
// An aircraft light streak crossing one frame.
|
||||||
for (var c = 0; c < 3; c++)
|
for (var c = 0; c < 3; c++)
|
||||||
for (var x = 10; x < 80; x++)
|
for (var x = 10; x < 80; x++)
|
||||||
frame[c, x, 40 + x / 8] = 5f;
|
frame[c, x, 40 + x / 8] = 5f;
|
||||||
}
|
}
|
||||||
stacker.Push(frame);
|
stacker.Push(frame);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user