diff --git a/ImplementationTest/Program.cs b/ImplementationTest/Program.cs index 9c46ad1..bdc1209 100644 --- a/ImplementationTest/Program.cs +++ b/ImplementationTest/Program.cs @@ -1,46 +1,65 @@ // See https://aka.ms/new-console-template for more information using System.Diagnostics; -using LensSimulatorCore; using LensSimulatorCore.Optical; using LensSimulatorCore.Shapes; -using LensSimulatorCore.Workspace; +namespace ImplementationTest; -var ellipse = new Ellipse(0.2,3,4,new Point(1,3)); -var result = ellipse.GetIntersectionPoints(new Line(-2, 3)); - -var ListOfPointsOnCircle = (double n) => +internal class Program { - List points = new List(); - - for (int i = 0; i < n; i++) + static void Main(string[] args) { - var radians = Math.PI * 2 / n * i; + var ellipse = new Ellipse(-0.6,1.8,1.4,new Point(2.1,-0.5)); + var resultEllipse = ellipse.GetIntersectionPoints(new Line(3.7, 2.8)); + + var circle = new Circle(1.4, new Point(2.1, -0.5)); + var resultCircle = circle.GetIntersectionPoints(new Line(3.7, 2.8)); - var x = Math.Cos(radians); - var y = Math.Sin(radians); - points.Add(new Point(x, y)); - } + + + + + + + + + + + var ListOfPointsOnCircle = (double n) => + { + List points = new List(); + + for (int i = 0; i < n; i++) + { + var radians = Math.PI * 2 / n * i; + + var x = Math.Cos(radians); + var y = Math.Sin(radians); + + points.Add(new Point(x, y)); + } - return points; -}; + return points; + }; -var test = ListOfPointsOnCircle(8); + var test = ListOfPointsOnCircle(8); -var sellmeier = new SellmeierCoefficients(1.03961212, 0.00600069867, 0.231792344, 0.0200179144, 0, 103); + var sellmeier = new SellmeierCoefficients(1.03961212, 0.00600069867, 0.231792344, 0.0200179144, 0, 103); -var material = new Material(sellmeier); + var material = new Material(sellmeier); -var s = new Stopwatch(); s.Start(); + var s = new Stopwatch(); s.Start(); -var reflectivity = material.Reflectivity(45, 1.00027717, 450); -var transmissivity = material.Transmissivity(45, 1.00027717, 450); + var reflectivity = material.Reflectivity(45, 1.00027717, 450); + var transmissivity = material.Transmissivity(45, 1.00027717, 450); -s.Stop(); -var time = s.ElapsedMilliseconds; + s.Stop(); + var time = s.ElapsedMilliseconds; -Console.Write("F"); \ No newline at end of file + Console.Write("F"); + } +} \ No newline at end of file diff --git a/ImplementationTest/bin/Debug/net7.0/ImplementationTest.dll b/ImplementationTest/bin/Debug/net7.0/ImplementationTest.dll deleted file mode 100644 index 8d1a11d..0000000 Binary files a/ImplementationTest/bin/Debug/net7.0/ImplementationTest.dll and /dev/null differ diff --git a/ImplementationTest/bin/Debug/net7.0/ImplementationTest.pdb b/ImplementationTest/bin/Debug/net7.0/ImplementationTest.pdb deleted file mode 100644 index d5e00ad..0000000 Binary files a/ImplementationTest/bin/Debug/net7.0/ImplementationTest.pdb and /dev/null differ diff --git a/ImplementationTest/bin/Debug/net7.0/LensSimulatorCore.dll b/ImplementationTest/bin/Debug/net7.0/LensSimulatorCore.dll deleted file mode 100644 index 00e8554..0000000 Binary files a/ImplementationTest/bin/Debug/net7.0/LensSimulatorCore.dll and /dev/null differ diff --git a/ImplementationTest/bin/Debug/net7.0/LensSimulatorCore.pdb b/ImplementationTest/bin/Debug/net7.0/LensSimulatorCore.pdb deleted file mode 100644 index 8831f5c..0000000 Binary files a/ImplementationTest/bin/Debug/net7.0/LensSimulatorCore.pdb and /dev/null differ diff --git a/ImplementationTest/obj/Debug/net7.0/ImplementationTest.csproj.AssemblyReference.cache b/ImplementationTest/obj/Debug/net7.0/ImplementationTest.csproj.AssemblyReference.cache deleted file mode 100644 index 2876ce9..0000000 Binary files a/ImplementationTest/obj/Debug/net7.0/ImplementationTest.csproj.AssemblyReference.cache and /dev/null differ diff --git a/ImplementationTest/obj/Debug/net7.0/ImplementationTest.dll b/ImplementationTest/obj/Debug/net7.0/ImplementationTest.dll deleted file mode 100644 index 8d1a11d..0000000 Binary files a/ImplementationTest/obj/Debug/net7.0/ImplementationTest.dll and /dev/null differ diff --git a/ImplementationTest/obj/Debug/net7.0/ImplementationTest.pdb b/ImplementationTest/obj/Debug/net7.0/ImplementationTest.pdb deleted file mode 100644 index d5e00ad..0000000 Binary files a/ImplementationTest/obj/Debug/net7.0/ImplementationTest.pdb and /dev/null differ diff --git a/ImplementationTest/obj/Debug/net7.0/ref/ImplementationTest.dll b/ImplementationTest/obj/Debug/net7.0/ref/ImplementationTest.dll deleted file mode 100644 index 185d2c1..0000000 Binary files a/ImplementationTest/obj/Debug/net7.0/ref/ImplementationTest.dll and /dev/null differ diff --git a/ImplementationTest/obj/Debug/net7.0/refint/ImplementationTest.dll b/ImplementationTest/obj/Debug/net7.0/refint/ImplementationTest.dll deleted file mode 100644 index 185d2c1..0000000 Binary files a/ImplementationTest/obj/Debug/net7.0/refint/ImplementationTest.dll and /dev/null differ diff --git a/LensSimulatorCore/MathsLib/CoreMaths.cs b/LensSimulatorCore/MathsLib/CoreMaths.cs index a057052..64a9afc 100644 --- a/LensSimulatorCore/MathsLib/CoreMaths.cs +++ b/LensSimulatorCore/MathsLib/CoreMaths.cs @@ -29,9 +29,9 @@ public static class CoreMaths return num1; } - public static List SolveQuadratic(double a, double b, double c) + public static List SolveQuadratic(double a, double b, double c) { - var solutions = new List(); + var solutions = new List(); double discriminant = b * b - 4 * a * c; if (discriminant < 0) diff --git a/LensSimulatorCore/Shapes/Ellipse.cs b/LensSimulatorCore/Shapes/Ellipse.cs index 7818a23..77f0044 100644 --- a/LensSimulatorCore/Shapes/Ellipse.cs +++ b/LensSimulatorCore/Shapes/Ellipse.cs @@ -1,3 +1,4 @@ +using System.Drawing; using LensSimulatorCore.MathsLib; using LensSimulatorCore.Shapes; @@ -22,36 +23,49 @@ public class Ellipse { var cosTheta = Math.Cos(_radianAngle); var sinTheta = Math.Sin(_radianAngle); - var majorSquared = _semiMajorAxis * _semiMajorAxis; var minorSquared = _semiMinorAxis * _semiMinorAxis; - var LCM = CoreMaths.CalculateLCM(majorSquared, minorSquared); + var lcm = majorSquared * minorSquared; var intersectionMinusXpos = line.C - _position.X; - var intersectionMinusXposCosTheta = (intersectionMinusXpos * cosTheta); - var intersectionMinusXposSinTheta = (intersectionMinusXpos * sinTheta); + var intersectionMinusXposCosTheta = intersectionMinusXpos * cosTheta; + var intersectionMinusXposSinTheta = intersectionMinusXpos * sinTheta; var ySinTheta = _position.Y * sinTheta; var yCosTheta = _position.Y * cosTheta; var slopeCosTheta = line.B * cosTheta; var slopeSinTheta = line.B * sinTheta; - var a1 = minorSquared * Math.Pow(slopeCosTheta - sinTheta, 2); - var b1 = minorSquared * (slopeCosTheta - sinTheta) * (intersectionMinusXposCosTheta + ySinTheta) * 2; - var c1 = minorSquared * Math.Pow(intersectionMinusXposCosTheta + ySinTheta, 2); + var slopeCosThetaMinusSinTheta = slopeCosTheta - sinTheta; + var intersectionMinusXposCosThetaPlusYSinTheta = intersectionMinusXposCosTheta + ySinTheta; - var a2 = majorSquared * Math.Pow(slopeSinTheta + cosTheta, 2); - var b2 = majorSquared * (slopeSinTheta + cosTheta) * (intersectionMinusXposSinTheta - yCosTheta) * 2; - var c2 = majorSquared * Math.Pow(intersectionMinusXposSinTheta - yCosTheta, 2); + var slopeCosThetaMinusSinThetaPow2 = Math.Pow(slopeCosThetaMinusSinTheta, 2); + var ser = intersectionMinusXposCosThetaPlusYSinTheta * (slopeCosThetaMinusSinTheta) * 2; + var intersectionMinusXposCosThetaPow2 = Math.Pow(intersectionMinusXposCosThetaPlusYSinTheta, 2); + + var a1 = minorSquared * slopeCosThetaMinusSinThetaPow2; + var b1 = minorSquared * ser; + var c1 = minorSquared * intersectionMinusXposCosThetaPow2; + + var slopeSinThetaPlusCosTheta = slopeSinTheta + cosTheta; + var intersectionMinusXposSinThetaMinusYCosTheta = intersectionMinusXposSinTheta - yCosTheta; + + var slopeSinThetaMinusCosThetaPow2 = Math.Pow(slopeSinThetaPlusCosTheta, 2); + var se = intersectionMinusXposSinThetaMinusYCosTheta * (slopeSinThetaPlusCosTheta) * 2; + var intersectionMinusXposSinThetaMinusYCosThetaPow2 = Math.Pow(intersectionMinusXposSinThetaMinusYCosTheta, 2); + + var a2 = majorSquared * slopeSinThetaMinusCosThetaPow2; + var b2 = majorSquared * se; + var c2 = majorSquared * intersectionMinusXposSinThetaMinusYCosThetaPow2; var a = a1 + a2; var b = b1 + b2; - var c = c1 + c2 - LCM; - + var c = c1 + c2 - lcm; + var y = CoreMaths.SolveQuadratic(a, b, c); - return y.Select(y => new Point(line.B * y!.Value + line.C, y.Value)).ToList(); + return y.Select(y => new Point(line.B * y + line.C, y)).ToList(); } } diff --git a/LensSimulatorCore/bin/Debug/net7.0/LensSimulatorCore.dll b/LensSimulatorCore/bin/Debug/net7.0/LensSimulatorCore.dll deleted file mode 100644 index 00e8554..0000000 Binary files a/LensSimulatorCore/bin/Debug/net7.0/LensSimulatorCore.dll and /dev/null differ diff --git a/LensSimulatorCore/bin/Debug/net7.0/LensSimulatorCore.pdb b/LensSimulatorCore/bin/Debug/net7.0/LensSimulatorCore.pdb deleted file mode 100644 index 8831f5c..0000000 Binary files a/LensSimulatorCore/bin/Debug/net7.0/LensSimulatorCore.pdb and /dev/null differ diff --git a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.AssemblyInfo.cs b/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.AssemblyInfo.cs index 8202f59..6a3d183 100644 --- a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.AssemblyInfo.cs +++ b/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.AssemblyInfo.cs @@ -1,7 +1,6 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. diff --git a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.csproj.CoreCompileInputs.cache b/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.csproj.CoreCompileInputs.cache deleted file mode 100644 index c2391db..0000000 --- a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.csproj.CoreCompileInputs.cache +++ /dev/null @@ -1 +0,0 @@ -04bd4ca88629d5173ee0b51ca8fd93faa8aa5ffb diff --git a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.dll b/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.dll deleted file mode 100644 index 00e8554..0000000 Binary files a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.dll and /dev/null differ diff --git a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.pdb b/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.pdb deleted file mode 100644 index 8831f5c..0000000 Binary files a/LensSimulatorCore/obj/Debug/net7.0/LensSimulatorCore.pdb and /dev/null differ diff --git a/LensSimulatorCore/obj/Debug/net7.0/ref/LensSimulatorCore.dll b/LensSimulatorCore/obj/Debug/net7.0/ref/LensSimulatorCore.dll deleted file mode 100644 index 18dce07..0000000 Binary files a/LensSimulatorCore/obj/Debug/net7.0/ref/LensSimulatorCore.dll and /dev/null differ diff --git a/LensSimulatorCore/obj/Debug/net7.0/refint/LensSimulatorCore.dll b/LensSimulatorCore/obj/Debug/net7.0/refint/LensSimulatorCore.dll deleted file mode 100644 index 18dce07..0000000 Binary files a/LensSimulatorCore/obj/Debug/net7.0/refint/LensSimulatorCore.dll and /dev/null differ diff --git a/LensSimulatorWindows/obj/Debug/net7.0-windows/MainWindow.g.cs b/LensSimulatorWindows/obj/Debug/net7.0-windows/MainWindow.g.cs index cc5ef0e..470f96f 100644 --- a/LensSimulatorWindows/obj/Debug/net7.0-windows/MainWindow.g.cs +++ b/LensSimulatorWindows/obj/Debug/net7.0-windows/MainWindow.g.cs @@ -1,4 +1,4 @@ -#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "F00A131DD7A3DD8BE845A0DF7A7CAC5E61751361" +#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1F75E03F780127AE90566E2C2C23D77355CE45A9" //------------------------------------------------------------------------------ // // This code was generated by a tool.