38 #ifndef GREATCIRCLE_H_
39 #define GREATCIRCLE_H_
203 double moveDirection[3];
226 void initialize(
const double* intermediatePoint,
const bool &shortestPath);
237 GeoTessGreatCircle() : firstPoint(NULL), lastPoint(NULL), deleteFirst(true), deleteLast(true), trnsfrm(NULL)
285 GeoTessGreatCircle(
const double* firstPoint,
const double* intermediatePoint,
const double* lastPoint,
286 const bool &shortestPath=
true);
304 GeoTessGreatCircle(
const double* firstPoint,
const double* lastPoint,
const bool &shortestPath=
true);
324 return firstPoint[0] == other.firstPoint[0]
325 && firstPoint[1] == other.firstPoint[1]
326 && firstPoint[2] == other.firstPoint[2]
327 && lastPoint[0] == other.lastPoint[0]
328 && lastPoint[1] == other.lastPoint[1]
329 && lastPoint[2] == other.lastPoint[2]
330 && normal[0] == other.normal[0]
331 && normal[1] == other.normal[1]
332 && normal[2] == other.normal[2];
370 void set(
double* firstPoint,
double* intermediatePoint,
double* lastPoint,
371 const bool& shortestPath=
true,
const bool& deleteWhenDone=
false);
394 void set(
double* frstPoint,
double* lstPoint,
395 const bool& shortestPath=
true,
const bool& deleteWhenDone=
false)
396 { set (frstPoint, NULL, lstPoint, shortestPath, deleteWhenDone); }
413 void set(
double* firstPoint,
const double& distance,
const double& azimuth,
414 const bool& deleteWhenDone=
false);
425 distance = GeoTessUtils::angle(firstPoint, lastPoint);
426 if (GeoTessUtils::scalarTripleProduct(firstPoint, lastPoint, normal) < 0.)
427 distance = 2*PI - distance;
439 return CPPUtils::toDegrees(getDistance());
454 double d = GeoTessUtils::angle(firstPoint, position);
456 if (GeoTessUtils::scalarTripleProduct(firstPoint, position, normal) < 0.)
474 return CPPUtils::toDegrees(getDistance(position));
528 double* location =
new double[3];
529 GeoTessUtils::move(firstPoint, moveDirection, dist, location);
542 void getPoint(
const double &dist,
double* location)
544 GeoTessUtils::move(firstPoint, moveDirection, dist, location);
561 static int getNPoints(
const double& dist,
const double& spacing,
const bool& onCenters=
false)
563 if (dist <= 0.)
return onCenters ? 1 : 2;
564 return onCenters ? (int)ceil(dist/spacing) : ((int)ceil(dist/spacing))+1;
580 int getNPoints(
const double& spacing,
const bool& onCenters=
false)
582 return getNPoints(getDistance(), spacing, onCenters);
603 double getPoints(
double** points,
const int &npoints,
const bool& onCenters=
false)
608 dx = getDistance()/npoints;
609 for (
int i=0; i<npoints; ++i) getPoint((i+0.5)*dx, points[i]);
613 dx = getDistance()/(npoints-1);
614 for (
int i=0; i<npoints; ++i) getPoint(i*dx, points[i]);
640 double getPoints(
const double &spacing,
double** points,
int &npoints,
const bool& onCenters=
false)
642 npoints = getNPoints(spacing, onCenters);
647 dx = getDistance()/npoints;
648 for (
int i=0; i<npoints; ++i) getPoint((i+0.5)*dx, points[i]);
652 dx = getDistance()/(npoints-1);
653 for (
int i=0; i<npoints; ++i) getPoint(i*dx, points[i]);
685 if (GeoTessUtils::crossNormal(normal, other.normal, intersection) == 0.)
687 intersection[0] = intersection[1] = intersection[2] = NaN_DOUBLE;
691 if (GeoTessUtils::scalarTripleProduct(firstPoint, intersection, normal) < 0.)
693 intersection[0] = -intersection[0];
694 intersection[1] = -intersection[1];
695 intersection[2] = -intersection[2];
698 if (inRange && (getDistance(intersection) >= getDistance()
701 intersection[0] = intersection[1] = intersection[2] = NaN_DOUBLE;
748 v[0] = x[0] * trnsfrm[0][0] + x[1] * trnsfrm[0][1] + x[2]
750 v[1] = x[0] * trnsfrm[1][0] + x[1] * trnsfrm[1][1] + x[2]
752 v[2] = x[0] * trnsfrm[2][0] + x[1] * trnsfrm[2][1] + x[2]
779 double* v =
new double[3];