79 typedef std::pair<Math::real, Math::real>
Point;
84 static const unsigned LineCaps = Geodesic::LATITUDE | Geodesic::LONGITUDE |
85 Geodesic::AZIMUTH | Geodesic::REDUCEDLENGTH | Geodesic::GEODESICSCALE |
86 Geodesic::DISTANCE_IN;
88 static const int numit_ = 100;
106 {
using std::fabs;
return fabs(x) + fabs(y); }
116 : x(Math::NaN()), y(Math::NaN()), c(0)
118 XPoint(
const Point& p)
119 : x(p.first), y(p.second), c(0)
121 XPoint& operator+=(
const XPoint& p) {
126 XPoint operator+(
const XPoint& p)
const {
127 XPoint t = *
this; t += p;
return t;
129 Math::real Dist()
const {
return d1(x, y); }
130 Math::real Dist(
const XPoint& p)
const {
return d1(x - p.x, y - p.y); }
131 Point data()
const {
return Point(x, y); }
139 SetComp(Math::real delta) : _delta(delta) {}
140 bool eq(
const XPoint& p,
const XPoint& q)
const {
141 return d1(p.x - q.x, p.y - q.y) <= _delta;
143 bool operator()(
const XPoint& p,
const XPoint& q)
const {
144 return !eq(p, q) && ( p.x != q.x ? p.x < q.x : p.y < q.y );
153 RankPoint(
const Point& p0) : _x(p0.first), _y(p0.second) {}
154 RankPoint(
const XPoint& p0) : _x(p0.x), _y(p0.y) {}
155 bool operator()(
const XPoint& p,
const XPoint& q)
const {
156 real dp = d1(p.x - _x, p.y - _y),
157 dq = d1(q.x - _x, q.y - _y);
158 return dp != dq ? (dp < dq) :
159 (p.x != q.x ? (p.x < q.x) : (p.y < q.y));
163 XPoint Spherical(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
164 const XPoint& p)
const;
166 XPoint Basic(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
167 const XPoint& p0)
const;
169 XPoint ClosestInt(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
170 const XPoint& p0)
const;
172 XPoint NextInt(
const GeodesicLine& lineX,
const GeodesicLine& lineY)
const;
174 XPoint SegmentInt(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
178 AllInt0(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
179 Math::real maxdist,
const XPoint& p0)
const;
181 AllInternal(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
182 Math::real maxdist,
const Point& p0,
183 std::vector<int>& c,
bool cp)
const;
186 Math::real ConjugateDist(
const GeodesicLine& line, Math::real s3,
bool semi,
187 Math::real m12 = 0, Math::real M12 = 1,
188 Math::real M21 = 1)
const;
189 Math::real distpolar(Math::real lat1, Math::real* lat2 =
nullptr)
const;
190 Math::real polarb(Math::real* lata =
nullptr, Math::real* latb =
nullptr)
192 Math::real conjdist(Math::real azi, Math::real* ds =
nullptr,
193 Math::real* sp =
nullptr, Math::real* sm =
nullptr)
195 Math::real distoblique(Math::real* azi =
nullptr, Math::real* sp =
nullptr,
196 Math::real* sm =
nullptr)
const;
200 static XPoint fixcoincident(
const XPoint& p0,
const XPoint& p);
201 static XPoint fixcoincident(
const XPoint& p0,
const XPoint& p,
int c);
202 static XPoint fixsegment(Math::real sx, Math::real sy,
const XPoint& p);
203 static int segmentmode(Math::real sx, Math::real sy,
const XPoint& p) {
204 return (p.x < 0 ? -1 : p.x <= sx ? 0 : 1) * 3
205 + (p.y < 0 ? -1 : p.y <= sy ? 0 : 1);
207 mutable long long _cnt0, _cnt1, _cnt2, _cnt3, _cnt4;
228 Intersect(
const Geodesic& geod);
251 Point Closest(Math::real latX, Math::real lonX, Math::real aziX,
252 Math::real latY, Math::real lonY, Math::real aziY,
253 const Point& p0 = Point(0, 0),
int* c =
nullptr)
const;
271 Point Closest(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
272 const Point& p0 = Point(0, 0),
int* c =
nullptr)
const;
307 Point Segment(Math::real latX1, Math::real lonX1,
308 Math::real latX2, Math::real lonX2,
309 Math::real latY1, Math::real lonY1,
310 Math::real latY2, Math::real lonY2,
311 int& segmode,
int* c =
nullptr)
const;
337 Point Segment(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
338 int& segmode,
int* c =
nullptr)
const;
359 Point Next(Math::real latX, Math::real lonX,
360 Math::real aziX, Math::real aziY,
int* c =
nullptr)
const;
383 Point Next(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
384 int* c =
nullptr)
const;
411 std::vector<Point> All(Math::real latX, Math::real lonX, Math::real aziX,
412 Math::real latY, Math::real lonY, Math::real aziY,
413 Math::real maxdist, std::vector<int>& c,
414 const Point& p0 = Point(0, 0))
437 std::vector<Point> All(Math::real latX, Math::real lonX, Math::real aziX,
438 Math::real latY, Math::real lonY, Math::real aziY,
439 Math::real maxdist,
const Point& p0 = Point(0, 0))
462 std::vector<Point> All(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
463 Math::real maxdist, std::vector<int>& c,
464 const Point& p0 = Point(0, 0))
486 std::vector<Point> All(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
487 Math::real maxdist,
const Point& p0 = Point(0, 0))
578 return fabs(p.first - p0.first) + fabs(p.second - p0.second);