4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef THERMALLOCATOR_H
25 #define THERMALLOCATOR_H
27 #include "Math/fixed.hpp"
28 #include "Geo/GeoPoint.hpp"
29 #include "Geo/SpeedVector.hpp"
30 #include "Geo/Flat/FlatPoint.hpp"
33 struct ThermalLocatorInfo
;
36 * Class to estimate the location of the center of a thermal
39 class ThermalLocator
{
41 static constexpr unsigned TLOCATOR_NMIN
= 5;
42 static constexpr unsigned TLOCATOR_NMAX
= 60;
45 /** Class used to hold thermal estimate samples */
49 * Calculate drifted, weighted values of point
51 * @param t Current time
52 * @param location_0 Initial location
53 * @param wind_drift Wind drift offset
54 * @param decay decay factor for weighting
56 void Drift(fixed t
, const TaskProjection
& projection
,
57 const GeoPoint
& wind_drift
);
59 /** Actual location of sample */
61 /** Projected/drifted sample */
63 /** Time of sample (s) */
65 /** Scaled updraft value of sample */
67 /** Lift weighting used for this point */
69 /** Recency weighting used for this point */
73 /** Circular buffer of points */
74 Point points
[TLOCATOR_NMAX
];
76 /** Index of next point to add */
78 /** Number of points in buffer */
83 * Update locator estimate. If not in circling mode, resets the
86 * @param circling Whether aircraft is in circling mode
87 * @param time Time of fix (s)
88 * @param location Location of aircraft
89 * @param w Net updraft speed (m/s)
90 * @param wind Wind vector
91 * @param therm Output thermal estimate data
93 void Process(const bool circling
, const fixed time
, const GeoPoint
&location
,
94 const fixed w
, const SpeedVector wind
,
95 ThermalLocatorInfo
& therm
);
98 * Reset as if never flown
103 FlatPoint
glider_average();
105 void AddPoint(const fixed t
, const GeoPoint
&location
, const fixed w
);
106 void Update(const fixed t_0
, const GeoPoint
&location_0
,
107 const SpeedVector wind
, ThermalLocatorInfo
&therm
);
109 void Drift(const fixed t_0
, const TaskProjection
& projection
,
110 const GeoPoint
& traildrift
);