void SampledTaskPoint::set_search_min(const GeoPoint &location, const TaskProjection &projection) { SearchPoint sp(location, projection); set_search_min(sp); }
void StartPoint::find_best_start(const AIRCRAFT_STATE &state, const OrderedTaskPoint &next, const TaskProjection &projection) { class StartPointBestStart: public ZeroFinder { public: StartPointBestStart(const StartPoint& ts, const GeoPoint &loc_from, const GeoPoint &loc_to): ZeroFinder(-fixed_half, fixed_half, fixed(0.01)), m_start(ts), m_loc_from(loc_from), m_loc_to(loc_to) {}; fixed f(const fixed p) { return ::DoubleDistance(m_loc_from,parametric(p),m_loc_to); } GeoPoint solve() { // find approx solution first, being the offset for the local function // minimiser search fixed f_best= f(fixed_zero); fixed p_best= fixed_zero; for (p_offset=fixed_zero; p_offset< fixed_one; p_offset+= fixed(0.25)) { fixed ff = f(fixed_zero); if (ff< f_best) { f_best = ff; p_best = p_offset; } } // now detailed search, returning result return parametric(find_min(fixed_zero)); } private: GeoPoint parametric(const fixed p) { // ensure parametric input is between 0 and 1 fixed pp = p+p_offset; if (negative(pp)) { pp+= fixed_one; } pp = fmod(pp,fixed_one); return m_start.get_boundary_parametric(pp); } const StartPoint& m_start; const GeoPoint m_loc_from; const GeoPoint m_loc_to; fixed p_offset; }; StartPointBestStart solver(*this, state.Location, next.get_location_remaining()); set_search_min(solver.solve(), projection); }
void SampledTaskPoint::set_search_min(const GeoPoint &location) { SearchPoint sp(location, m_task_projection, false); set_search_min(sp); }