Cleanup
This commit is contained in:
parent
70f3e458d4
commit
57d6e99256
|
@ -1,17 +1,34 @@
|
|||
// 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
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
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 ListOfPointsOnCircle = (double n) =>
|
||||
{
|
||||
List<Point> points = new List<Point>();
|
||||
|
||||
for (int i = 0; i < n; i++)
|
||||
|
@ -25,22 +42,24 @@ var ListOfPointsOnCircle = (double n) =>
|
|||
}
|
||||
|
||||
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");
|
||||
Console.Write("F");
|
||||
}
|
||||
}
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -29,9 +29,9 @@ public static class CoreMaths
|
|||
return num1;
|
||||
}
|
||||
|
||||
public static List<double?> SolveQuadratic(double a, double b, double c)
|
||||
public static List<double> SolveQuadratic(double a, double b, double c)
|
||||
{
|
||||
var solutions = new List<double?>();
|
||||
var solutions = new List<double>();
|
||||
|
||||
double discriminant = b * b - 4 * a * c;
|
||||
if (discriminant < 0)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
Binary file not shown.
|
@ -1,7 +1,6 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// 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.
|
||||
|
|
|
@ -1 +0,0 @@
|
|||
04bd4ca88629d5173ee0b51ca8fd93faa8aa5ffb
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -1,4 +1,4 @@
|
|||
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "F00A131DD7A3DD8BE845A0DF7A7CAC5E61751361"
|
||||
#pragma checksum "..\..\..\MainWindow.xaml" "{ff1816ec-aa5e-4d10-87f7-6f4963833460}" "1F75E03F780127AE90566E2C2C23D77355CE45A9"
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
|
|
Loading…
Reference in New Issue