This repository has been archived on 2024-09-21. You can view files and clone it, but cannot push or open issues or pull requests.
Optica.Rods.Calculation/Program.cs
2024-08-30 22:44:45 +07:00

120 lines
4.5 KiB
C#

using System.ComponentModel.DataAnnotations;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Xml.XPath;
using RealCoordinatesCalculation;
using RealCoordinatesCalculation.Models;
// | TODO |
// =================
// Подгрузка M1, M2
// Подгрузка PA.TA.HA.TC.PC
// ДИАПАЗОНЫ ВЫЧИСЛЕНИЙ
const double NG_PREDEL_LOW = 1.494452;
const double NG_PREDEL_HIGHT = 1.506247;
const double BETA_PREDEL_LOW = -15;
const double BETA_PREDEL_HIGHT = 15;
// ПРЕДОПРЕДЕЛЕННЫЕ КОНСТАНТЫ ВЫЧИСЛЕНИЙ
const double LAMBDA = 1.550;
const double ALPHA = 0.001383;
const double DGM = 60.00;
// КОЛИЧЕСТВО ЭКСПЕРИМЕНТОВ
const int COUNT_EXPERIMENTS = 6;
//DELETE AFTER PARSER IS GOING TO UP
var XYZ = new Vector3D(5944.787, -1758.92, 3885.021);
var M1 = new Vector3D(3472.706, 2543.101, 952.0311);
var M2 = new Vector3D(-1847.56, 2517.044, -2771.21);
const double PA = 743.056;
const double TA = 27.106;
const double HA = 46.676;
const double PC = 743.12;
const double TC = 26.6;
Console.WriteLine("[*] Start process of calculation");
Console.WriteLine("[1] Layer 1 :: Correcting coordinate is ended");
Console.WriteLine("[2] Layer 2 :: Calculate Distance is resolved");
Console.WriteLine("[3] Layer 3 :: Calculate DELTA is ended");
StartCalc();
// Запуск процесса вычислений
void StartCalc() {
var STEP_NG = (NG_PREDEL_HIGHT - NG_PREDEL_LOW) / 30;
var STEP_BETA = (NG_PREDEL_HIGHT - NG_PREDEL_LOW) / 30;
var CorrectedCoords = new List<Vector3D>();
for (int i = 0; i < COUNT_EXPERIMENTS; i++) {
var res = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW + (STEP_NG * i), (int)(BETA_PREDEL_LOW + (STEP_BETA * i)), PA, TA, HA, PC, TC, M1, M2, XYZ);
System.Console.WriteLine($"[LOG] ITERATION {i} in {COUNT_EXPERIMENTS} :: POINT {"J1.1"} :: " + res);
}
// === Уточняем координаты точек
var J1_1 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J1_2 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J1_3 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J2_1 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J2_2 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J2_3 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J3_1 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J3_2 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
var J3_3 = RunDivergenceCorrectForCoordinate(NG_PREDEL_LOW, (int)BETA_PREDEL_LOW, PA, TA, HA, PC, TC, M1, M2, XYZ);
// === Считаем искомые расстояния
var J1_12 = CalculateDistance(J1_1, J1_2);
var J1_23 = CalculateDistance(J1_2, J1_3);
var J1_13 = CalculateDistance(J1_1, J1_3);
var J2_12 = CalculateDistance(J2_1, J2_2);
var J2_23 = CalculateDistance(J2_2, J2_3);
var J2_13 = CalculateDistance(J2_1, J2_3);
var J3_12 = CalculateDistance(J3_1, J3_2);
var J3_23 = CalculateDistance(J3_2, J3_3);
var J3_13 = CalculateDistance(J3_1, J3_3);
// === Оцениваем отклонения найденных значений от истинного
}
// Корректировка координат для 1 вектора
Vector3D RunDivergenceCorrectForCoordinate(double NG, int BETA, double PA, double TA, double HA, double PC, double TC, Vector3D M1, Vector3D M2, Vector3D XYZ) {
var option = new CalculationSettings
{
NA = null,
NC = null,
NG = (decimal)NG,
Alpha = (decimal)ALPHA,
Dgm = (decimal)DGM,
PA = (decimal)PA,
TA = (decimal)TA,
HA = (decimal)HA,
Lambda = (decimal)LAMBDA,
Beta = BETA,
TC = (decimal)TC,
PC = (decimal)PC,
};
var calcLogger = new CalculateVectorCore(option);
var CALCULATED = calcLogger.CalculateData(
XYZ,
M1,
M2
);
return CALCULATED;
}
// Вычисление длинны вектора
double CalculateDistance(Vector3D JI_1, Vector3D JI_2) {
return (double)Vector3D.Length(JI_1, JI_2);
}