3 XCSoar Glide Computer - http://www.xcsoar.org/
4 Copyright (C) 2000-2013 The XCSoar Project
5 A detailed list of copyright holders can be found in the file "AUTHORS".
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 #include "SectorZone.hpp"
24 #include "Boundary.hpp"
25 #include "Geo/GeoVector.hpp"
28 SectorZone::GetBoundary() const
33 boundary
.GenerateArcExcluding(GetReference(), GetRadius(),
34 GetStartRadial(), GetEndRadial());
36 boundary
.push_front(GetSectorEnd());
37 boundary
.push_front(GetSectorStart());
38 boundary
.push_front(GetReference());
44 SectorZone::ScoreAdjustment() const
50 SectorZone::UpdateSector()
52 sector_start
= GeoVector(GetRadius(), start_radial
).EndPoint(GetReference());
53 sector_end
= GeoVector(GetRadius(), end_radial
).EndPoint(GetReference());
57 SectorZone::IsInSector(const GeoPoint
&location
) const
59 GeoVector
f(GetReference(), location
);
61 return f
.distance
<= GetRadius() && IsAngleInSector(f
.bearing
);
65 SectorZone::SetStartRadial(const Angle x
)
72 SectorZone::SetEndRadial(const Angle x
)
79 SectorZone::IsAngleInSector(const Angle b
) const
81 // Quit early if we have a full circle
82 if ((end_radial
- start_radial
).AsBearing() <= Angle::FullCircle() / 512)
85 return b
.Between(start_radial
, end_radial
);
89 SectorZone::Equals(const ObservationZonePoint
&other
) const
91 const SectorZone
&z
= (const SectorZone
&)other
;
93 return CylinderZone::Equals(other
) &&
94 start_radial
== z
.GetStartRadial() &&
95 end_radial
== z
.GetEndRadial();