diff --git a/WaveOptics.Tests/WaveOpticsDepthTests.cs b/WaveOptics.Tests/WaveOpticsDepthTests.cs index 09efee8..577f391 100644 --- a/WaveOptics.Tests/WaveOpticsDepthTests.cs +++ b/WaveOptics.Tests/WaveOpticsDepthTests.cs @@ -161,6 +161,21 @@ public sealed class WaveOpticsDepthTests } } + [Theory] + [InlineData(380d)] + [InlineData(550d)] + [InlineData(650d)] + public void AMonochromeWaveCountIsMeasuredInTheChosenWavelength(double wavelength) + => Assert.Equal(wavelength, WaveOpticsDepth.ReferenceWavelength(WaveOpticsColorMode.Monochrome, wavelength)); + + [Theory] + [InlineData(WaveOpticsColorMode.Primaries, 380d)] + [InlineData(WaveOpticsColorMode.Primaries, 650d)] + [InlineData(WaveOpticsColorMode.Broadband, 380d)] + [InlineData(WaveOpticsColorMode.Broadband, 780d)] + public void APrimariesOrBroadbandWaveCountIsMeasuredIn550Nanometres(WaveOpticsColorMode colorMode, double wavelength) + => Assert.Equal(550d, WaveOpticsDepth.ReferenceWavelength(colorMode, wavelength)); + [Fact] public void TheDefocusIsZeroAtTheFocusDistance() => Assert.Equal(0d, WaveOpticsDepth.DefocusWaves(50d, 8d, 1500d, 1500d, Wavelength)); diff --git a/WaveOptics/Effects/WaveOpticsDepth.cs b/WaveOptics/Effects/WaveOpticsDepth.cs index 60423be..e6de8f7 100644 --- a/WaveOptics/Effects/WaveOpticsDepth.cs +++ b/WaveOptics/Effects/WaveOpticsDepth.cs @@ -1,4 +1,5 @@ using System.Numerics; +using WaveOptics.Optics; using YukkuriMovieMaker.Player.Video; namespace WaveOptics.Effects; @@ -27,6 +28,9 @@ internal static class WaveOpticsDepth return true; } + public static double ReferenceWavelength(WaveOpticsColorMode colorMode, double wavelength) + => colorMode == WaveOpticsColorMode.Monochrome ? wavelength : SpectralPlan.ReferenceWavelength; + public static double DefocusWaves(double focalLength, double fNumber, double focusDistance, double distance, double wavelength) { var minimum = focalLength * MinimumDistanceRatio;