@@ -14,46 +14,48 @@ public virtual void Run(MapData map)
14
14
}
15
15
}
16
16
17
+ private const int OUTPUT_PERCENT_POINTS = 50 ;
18
+ private const int FOURIER_SERIES_LENGTH = 500 ;
19
+ private const double APPROXIMATION_RATIO = 0.1 ;
17
20
private void Run ( List < MapPoint > chain , int startIndex , int endIndex )
18
21
{
19
-
20
22
if ( chain [ startIndex ] . Equals ( chain [ endIndex ] ) )
21
23
{
22
- Fourier fourier = new Fourier ( chain , 1000 ) ; //fourier length
24
+ Fourier fourier = new Fourier ( chain , FOURIER_SERIES_LENGTH , APPROXIMATION_RATIO ) ;
23
25
24
- double Dist = fourier . GetAllDist ( ) ;
26
+ fourier . GetAllDist ( ) ;
25
27
fourier . GetFourierXparameter ( ) ;
26
28
fourier . GetFourierYparameter ( ) ;
27
29
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 ) ;
30
32
31
- for ( int i = 0 ; i < fitt ; i ++ )
33
+ for ( int i = 0 ; i < outputPointCount ; i ++ )
32
34
{
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 ;
35
37
}
36
38
37
- while ( chain . Count > fitt )
39
+ while ( chain . Count > outputPointCount )
38
40
{
39
- chain . RemoveAt ( chain . Count - 1 ) ;
41
+ chain . RemoveAt ( chain . Count - 1 ) ;
40
42
}
41
43
}
42
44
else
43
45
{
44
- Fourier_NotClosed fourier = new Fourier_NotClosed ( chain , 100 ) ;
46
+ FourierNotClosed fourier = new FourierNotClosed ( chain , FOURIER_SERIES_LENGTH , APPROXIMATION_RATIO ) ;
45
47
46
- double Dist = fourier . GetAllDist ( ) ;
48
+ fourier . GetAllDist ( ) ;
47
49
fourier . GetFourierXparameter ( ) ;
48
50
fourier . GetFourierYparameter ( ) ;
49
51
50
- var t = fourier . GetRecoveryPoints ( chain . Count , fourier . Ax . Length ) ;
52
+ var t = fourier . GetRecoveryPoints ( chain . Count ) ;
51
53
52
- int k = t . Length / 2 ;
54
+ int k = t . Count / 2 ;
53
55
chain . Clear ( ) ;
54
56
for ( int i = 0 ; i < k ; i ++ )
55
57
{
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 } ) ;
57
59
}
58
60
}
59
61
}
0 commit comments