refactor(math): drop unused vector helpers and test moments

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 09:56:27 +00:00
1 parent 6c4f1b7b22
commit 3bc55449ae
3 files changed
+11 -16

No files matched your search

+1 -13
View File
@@ -1,16 +1,7 @@
namespace Titano.Core.Mathematics;
/// <summary>A 3-vector in double precision (colour triplets, homogeneous 2-D points).</summary>
public readonly record struct Vector3D(double X, double Y, double Z)
{
public static Vector3D operator +(Vector3D a, Vector3D b) => new(a.X + b.X, a.Y + b.Y, a.Z + b.Z);
public static Vector3D operator -(Vector3D a, Vector3D b) => new(a.X - b.X, a.Y - b.Y, a.Z - b.Z);
public static Vector3D operator *(Vector3D a, double s) => new(a.X * s, a.Y * s, a.Z * s);
public static double Dot(Vector3D a, Vector3D b) => a.X * b.X + a.Y * b.Y + a.Z * b.Z;
}
public readonly record struct Vector3D(double X, double Y, double Z);
/// <summary>Row-major 3×3 matrix in double precision for colour-space and planar projective work.</summary>
public readonly record struct Matrix3(
@@ -47,9 +38,6 @@ public readonly record struct Matrix3(
m.M21 * v.X + m.M22 * v.Y + m.M23 * v.Z,
m.M31 * v.X + m.M32 * v.Y + m.M33 * v.Z);
public static Matrix3 operator *(Matrix3 m, double s) => new(
m.M11 * s, m.M12 * s, m.M13 * s, m.M21 * s, m.M22 * s, m.M23 * s, m.M31 * s, m.M32 * s, m.M33 * s);
public double Determinant =>
M11 * (M22 * M33 - M23 * M32) - M12 * (M21 * M33 - M23 * M31) + M13 * (M21 * M32 - M22 * M31);
-2
View File
@@ -14,6 +14,4 @@ public readonly record struct Point2(double X, double Y)
public double Length => Math.Sqrt(X * X + Y * Y);
public static double Distance(Point2 a, Point2 b) => (a - b).Length;
public static Point2 Lerp(Point2 a, Point2 b, double t) => new(a.X + (b.X - a.X) * t, a.Y + (b.Y - a.Y) * t);
}
@@ -119,9 +119,18 @@ public sealed class StatisticsTests
var random = new Random(11);
var values = Enumerable.Range(0, 501).Select(_ => random.NextDouble() < 0.1 ? double.NaN : random.NextDouble() * 10 - 5).ToArray();
double Run() => Statistics.Median(values) + Statistics.MedianAbsoluteDeviation(values) + Statistics.TrimmedMean(values, 0.02, 0.02)
+ Statistics.Percentile(values, 0.9) + Statistics.Mean(values) + Statistics.StandardDeviation(values);
+ Statistics.Percentile(values, 0.9) + Statistics.Mean(values) + Statistics.StandardDeviation(values) + Statistics.Rms(values);
var first = Run();
Assert.True(double.IsFinite(first));
Assert.Equal(first, Run());
}
[Test]
public void MomentsOfAKnownSet()
{
double[] values = [2, 4, double.NaN, 4, 4, 5, 5, 7, 9];
Assert.Approximately(5, Statistics.Mean(values), 1e-12);
Assert.Approximately(Math.Sqrt(32.0 / 7), Statistics.StandardDeviation(values), 1e-12);
Assert.Approximately(Math.Sqrt(232.0 / 8), Statistics.Rms(values), 1e-12);
}
}