-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegistration.cs
More file actions
102 lines (94 loc) · 4.18 KB
/
Copy pathRegistration.cs
File metadata and controls
102 lines (94 loc) · 4.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
// --------------------------------------------------------------------------------
// VariScan module
//
// Description:
//
// Environment: Windows 10 executable, 32 and 64 bit
//
// Usage: TBD
//
// Author: (REM) Rick McAlister, rrskybox@yahoo.com
//
// Edit Log: Rev 1.0 Initial Version
//
// Date Who Vers Description
// ----------- --- ----- -------------------------------------------------------
//
// ---------------------------------------------------------------------------------
//
using MathNet.Spatial.Euclidean;
using System.Collections.Generic;
namespace VariScan
{
class Registration
{
public static StarField.FieldLightSource[] RegisterLightSources(StarField.FieldLightSource[] masterList, StarField.FieldLightSource[] minionList, double minDistanceArcSec)
{
//For each minion light source, find a registered master light source
// there may be more minions than masters, so some registrations will be null
// also, check if the gaia and variable, if so then don't register it
List<StarField.FieldLightSource> registeredList = new List<StarField.FieldLightSource>();
foreach (StarField.FieldLightSource minion in minionList)
{
int? closestMasterFLS = ClosestLightSource(masterList, minion, minDistanceArcSec);
if (closestMasterFLS != null)
{
StarField.FieldLightSource minionStarField = minion;
minionStarField.RegistrationIndex = (int)closestMasterFLS;
minionStarField.CatalogInfo = masterList[(int)closestMasterFLS].CatalogInfo;
registeredList.Add(minionStarField);
}
}
return registeredList.ToArray();
}
private static int? ClosestLightSource(StarField.FieldLightSource[] lightsourceList, StarField.FieldLightSource lightsource, double minDistanceArcSec)
{
//Determines the index of the lightsource on the lightsource list that is closest to the given light source
int closestIndex = 0;
double ldDistance = double.MaxValue;
Point2D aP = new Point2D(lightsource.LightSourceRA, lightsource.LightSourceDec);
for (int i = 0; i < lightsourceList.Length; i++)
{
Point2D bP = new Point2D(lightsourceList[i].LightSourceRA, lightsourceList[i].LightSourceDec);
double d = aP.DistanceTo(bP);
if (d < ldDistance)
{
closestIndex = i;
ldDistance = d;
}
}
if (ldDistance <= minDistanceArcSec)
return closestIndex;
else return null;
}
public static int? ClosestLightSource(StarField.FieldLightSource[] lightsourceList, double ra, double dec, double minDistanceArcSec)
{
//Determines the index of the lightsource from the lightsource list that is the least distance from RA, dec
int closestIndex = 0;
double closestDistance = double.MaxValue;
double currentDistance = 0;
Point2D aP = new Point2D(ra, dec);
for (int i = 0; i < lightsourceList.Length; i++)
{
Point2D bP = new Point2D(lightsourceList[i].LightSourceRA, lightsourceList[i].LightSourceDec);
currentDistance = aP.DistanceTo(bP);
if (currentDistance < closestDistance)
{
closestIndex = i;
closestDistance = currentDistance;
}
}
if (closestDistance <= minDistanceArcSec)
return closestIndex;
else return null;
}
public static int? FindRegisteredLightSource(StarField.FieldLightSource[] lightSourceArray, int registrationIndex)
{
//Returns the index of the light source from the lightsource list that has the registration in
for (int i = 0; i < lightSourceArray.Length; i++)
if (lightSourceArray[i].RegistrationIndex == registrationIndex)
return i;
return null;
}
}
}