78 typedef std::pair<Math::real, Math::real>
Point;
83 static const unsigned LineCaps = Geodesic::LATITUDE | Geodesic::LONGITUDE |
84 Geodesic::AZIMUTH | Geodesic::REDUCEDLENGTH | Geodesic::GEODESICSCALE |
85 Geodesic::DISTANCE_IN;
87 static const int numit_ = 100;
105 {
using std::fabs;
return fabs(x) + fabs(y); }
115 : x(Math::NaN()), y(Math::NaN()), c(0)
117 XPoint(
const Point& p)
118 : x(p.first), y(p.second), c(0)
120 XPoint& operator+=(
const XPoint& p) {
125 XPoint operator+(
const XPoint& p)
const {
126 XPoint t = *
this; t += p;
return t;
128 Math::real Dist()
const {
return d1(x, y); }
129 Math::real Dist(
const XPoint& p)
const {
return d1(x - p.x, y - p.y); }
130 Point data()
const {
return Point(x, y); }
138 SetComp(Math::real delta) : _delta(delta) {}
139 bool eq(
const XPoint& p,
const XPoint& q)
const {
140 return d1(p.x - q.x, p.y - q.y) <= _delta;
142 bool operator()(
const XPoint& p,
const XPoint& q)
const {
143 return !eq(p, q) && ( p.x != q.x ? p.x < q.x : p.y < q.y );
152 RankPoint(
const Point& p0) : _x(p0.first), _y(p0.second) {}
153 RankPoint(
const XPoint& p0) : _x(p0.x), _y(p0.y) {}
154 bool operator()(
const XPoint& p,
const XPoint& q)
const {
155 real dp = d1(p.x - _x, p.y - _y),
156 dq = d1(q.x - _x, q.y - _y);
157 return dp != dq ? (dp < dq) :
158 (p.x != q.x ? (p.x < q.x) : (p.y < q.y));
162 XPoint Spherical(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
163 const XPoint& p)
const;
165 XPoint Basic(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
166 const XPoint& p0)
const;
168 XPoint ClosestInt(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
169 const XPoint& p0)
const;
171 XPoint NextInt(
const GeodesicLine& lineX,
const GeodesicLine& lineY)
const;
173 XPoint SegmentInt(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
177 AllInt0(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
178 Math::real maxdist,
const XPoint& p0)
const;
180 AllInternal(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
181 Math::real maxdist,
const Point& p0,
182 std::vector<int>& c,
bool cp)
const;
185 Math::real ConjugateDist(
const GeodesicLine& line, Math::real s3,
bool semi,
186 Math::real m12 = 0, Math::real M12 = 1,
187 Math::real M21 = 1)
const;
188 Math::real distpolar(Math::real lat1, Math::real* lat2 =
nullptr)
const;
189 Math::real polarb(Math::real* lata =
nullptr, Math::real* latb =
nullptr)
191 Math::real conjdist(Math::real azi, Math::real* ds =
nullptr,
192 Math::real* sp =
nullptr, Math::real* sm =
nullptr)
194 Math::real distoblique(Math::real* azi =
nullptr, Math::real* sp =
nullptr,
195 Math::real* sm =
nullptr)
const;
199 static XPoint fixcoincident(
const XPoint& p0,
const XPoint& p);
200 static XPoint fixcoincident(
const XPoint& p0,
const XPoint& p,
int c);
201 static XPoint fixsegment(Math::real sx, Math::real sy,
const XPoint& p);
202 static int segmentmode(Math::real sx, Math::real sy,
const XPoint& p) {
203 return (p.x < 0 ? -1 : p.x <= sx ? 0 : 1) * 3
204 + (p.y < 0 ? -1 : p.y <= sy ? 0 : 1);
206 mutable long long _cnt0, _cnt1, _cnt2, _cnt3, _cnt4;
227 Intersect(
const Geodesic& geod);
250 Point Closest(Math::real latX, Math::real lonX, Math::real aziX,
251 Math::real latY, Math::real lonY, Math::real aziY,
252 const Point& p0 = Point(0, 0),
int* c =
nullptr)
const;
270 Point Closest(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
271 const Point& p0 = Point(0, 0),
int* c =
nullptr)
const;
306 Point Segment(Math::real latX1, Math::real lonX1,
307 Math::real latX2, Math::real lonX2,
308 Math::real latY1, Math::real lonY1,
309 Math::real latY2, Math::real lonY2,
310 int& segmode,
int* c =
nullptr)
const;
336 Point Segment(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
337 int& segmode,
int* c =
nullptr)
const;
358 Point Next(Math::real latX, Math::real lonX,
359 Math::real aziX, Math::real aziY,
int* c =
nullptr)
const;
382 Point Next(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
383 int* c =
nullptr)
const;
410 std::vector<Point> All(Math::real latX, Math::real lonX, Math::real aziX,
411 Math::real latY, Math::real lonY, Math::real aziY,
412 Math::real maxdist, std::vector<int>& c,
413 const Point& p0 = Point(0, 0))
436 std::vector<Point> All(Math::real latX, Math::real lonX, Math::real aziX,
437 Math::real latY, Math::real lonY, Math::real aziY,
438 Math::real maxdist,
const Point& p0 = Point(0, 0))
461 std::vector<Point> All(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
462 Math::real maxdist, std::vector<int>& c,
463 const Point& p0 = Point(0, 0))
485 std::vector<Point> All(
const GeodesicLine& lineX,
const GeodesicLine& lineY,
486 Math::real maxdist,
const Point& p0 = Point(0, 0))
577 return fabs(p.first - p0.first) + fabs(p.second - p0.second);