CI / Build and test (push) Successful in 8m19s
CI / Windows tests and installer (push) Skipped
CI / YAML check (push) Successful in 7s
Release / Build, test and publish (push) Successful in 12m9s
CI / PostgreSQL 16 integration (push) Successful in 7m49s
CI / PostgreSQL 17 integration (push) Successful in 7m19s
CI / Docker image (push) Successful in 46s
Release / Server image (push) Successful in 1m14s
Owner review 1 R5 + R6. Camera rotation, mirror, flip, straighten and crop handles locked to the output; an Exposure Look group; Export output size ("proportions win"); settings format 2 with older-node gates. Also fixes project text and hashes differing between Windows and Linux.
Closes #19
Closes #20
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: Alberto Balbo <alberto.balbo.96@gmail.com>
69 lines
2.3 KiB
C#
69 lines
2.3 KiB
C#
using Chronos.Core.Imaging.Geometry;
|
|
using Chronos.Testing;
|
|
|
|
namespace Chronos.Core.Tests.Geometry;
|
|
|
|
public sealed class Affine2DTests
|
|
{
|
|
[Test]
|
|
public void CompositionAppliesInnerFirst()
|
|
{
|
|
var scale = Affine2D.Scaling(2, 3);
|
|
var move = Affine2D.Translation(5, -1);
|
|
var (x, y) = (move * scale).Apply(1, 1);
|
|
Assert.Approximately(7, x, 1e-15);
|
|
Assert.Approximately(2, y, 1e-15);
|
|
Assert.Equal(move * scale, scale.Then(move));
|
|
}
|
|
|
|
[Test]
|
|
public void InverseUndoesTheMap()
|
|
{
|
|
var map = Affine2D.Similarity(1.3, 0.4, 12, -7) * Affine2D.Scaling(1, 0.8);
|
|
var inverse = map.Invert();
|
|
Assert.True((inverse * map).IsIdentity(1e-12));
|
|
Assert.True((map * inverse).IsIdentity(1e-12));
|
|
var (x, y) = map.Apply(3.5, -2.25);
|
|
var (bx, by) = inverse.Apply(x, y);
|
|
Assert.Within(3.5, -2.25, bx, by, 1e-12);
|
|
}
|
|
|
|
[Test]
|
|
public void SingularMapsDoNotInvert()
|
|
{
|
|
Assert.False(new Affine2D(1, 2, 2, 4, 0, 0).TryInvert(out _));
|
|
Assert.Throws<InvalidOperationException>(() => Affine2D.Scaling(0, 1).Invert());
|
|
}
|
|
|
|
[Test]
|
|
public void RotationAboutPivotKeepsThePivot()
|
|
{
|
|
var map = Affine2D.About(Affine2D.Rotation(0.7), 40, 30);
|
|
var (x, y) = map.Apply(40, 30);
|
|
Assert.Within(40, 30, x, y, 1e-12);
|
|
var (vx, vy) = map.ApplyVector(1, 0);
|
|
Assert.Within(double.Cos(0.7), double.Sin(0.7), vx, vy, 1e-15);
|
|
}
|
|
|
|
[Test]
|
|
public void AQuarterTurnRotationIsNotExact()
|
|
{
|
|
// Why FrameOrientation writes its quarter turns as integer matrices: cos(π/2) is about 6e-17, not 0.
|
|
var rotation = Affine2D.Rotation(double.Pi / 2);
|
|
Assert.NotEqual(0.0, rotation.M11);
|
|
Assert.Approximately(0, rotation.M11, 1e-16);
|
|
var turn = new Affine2D(0, -1, 1, 0, 0, 0);
|
|
Assert.Equal(Affine2D.Identity, turn * turn * turn * turn);
|
|
Assert.Equal(new Affine2D(0, 1, -1, 0, 0, 0), turn.Invert());
|
|
}
|
|
|
|
[Test]
|
|
public void SimilarityDecomposes()
|
|
{
|
|
var map = Affine2D.Similarity(1.25, -0.3, 4, 5);
|
|
Assert.Approximately(1.25, map.Scale, 1e-12);
|
|
Assert.Approximately(-0.3, map.Angle, 1e-12);
|
|
Assert.Approximately(1.25 * 1.25, map.Determinant, 1e-12);
|
|
}
|
|
}
|