Skip to content

Commit 008d292

Browse files
committed
adding X, Y Parameters in point calculation
1 parent a382565 commit 008d292

File tree

5 files changed

+214
-560
lines changed

5 files changed

+214
-560
lines changed

AlgorithmsLibrary/FourierDescAlgm/FourierDescAlgm.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -14,46 +14,48 @@ public virtual void Run(MapData map)
1414
}
1515
}
1616

17+
private const int OUTPUT_PERCENT_POINTS = 50;
18+
private const int FOURIER_SERIES_LENGTH = 500;
19+
private const double APPROXIMATION_RATIO = 0.1;
1720
private void Run(List<MapPoint> chain, int startIndex, int endIndex)
1821
{
19-
2022
if (chain[startIndex].Equals(chain[endIndex]))
2123
{
22-
Fourier fourier = new Fourier(chain, 1000); //fourier length
24+
Fourier fourier = new Fourier(chain, FOURIER_SERIES_LENGTH, APPROXIMATION_RATIO);
2325

24-
double Dist = fourier.GetAllDist();
26+
fourier.GetAllDist();
2527
fourier.GetFourierXparameter();
2628
fourier.GetFourierYparameter();
2729

28-
long fitt = (long)(chain.Count * 0.05); //output points
29-
var t = fourier.GetRecoveryPoints(fitt);
30+
int outputPointCount = chain.Count * OUTPUT_PERCENT_POINTS / 100;
31+
var outputs = fourier.GetRecoveryPoints(outputPointCount);
3032

31-
for (int i =0; i < fitt; i++)
33+
for (int i = 0; i < outputPointCount; i++)
3234
{
33-
chain[i].X = t[i].X;
34-
chain[i].Y = t[i].Y;
35+
chain[i].X = outputs[i].X;
36+
chain[i].Y = outputs[i].Y;
3537
}
3638

37-
while (chain.Count > fitt)
39+
while (chain.Count > outputPointCount)
3840
{
39-
chain.RemoveAt(chain.Count - 1);
41+
chain.RemoveAt(chain.Count - 1);
4042
}
4143
}
4244
else
4345
{
44-
Fourier_NotClosed fourier = new Fourier_NotClosed(chain, 100);
46+
FourierNotClosed fourier = new FourierNotClosed(chain, FOURIER_SERIES_LENGTH, APPROXIMATION_RATIO);
4547

46-
double Dist = fourier.GetAllDist();
48+
fourier.GetAllDist();
4749
fourier.GetFourierXparameter();
4850
fourier.GetFourierYparameter();
4951

50-
var t = fourier.GetRecoveryPoints(chain.Count, fourier.Ax.Length);
52+
var t = fourier.GetRecoveryPoints(chain.Count);
5153

52-
int k = t.Length / 2;
54+
int k = t.Count / 2;
5355
chain.Clear();
5456
for (int i = 0; i < k; i++)
5557
{
56-
chain.Add(new MapPoint { X = t[i, 0], Y = t[i, 1] });
58+
chain.Add(new MapPoint { X = t[i].X, Y = t[i].Y });
5759
}
5860
}
5961
}

0 commit comments

Comments
 (0)