PostGIS  3.4.0dev-r@@SVN_REVISION@@

◆ clairaut_geographic()

int clairaut_geographic ( const GEOGRAPHIC_POINT start,
const GEOGRAPHIC_POINT end,
GEOGRAPHIC_POINT g_top,
GEOGRAPHIC_POINT g_bottom 
)

Computes the pole of the great circle disk which is the intersection of the great circle with the line of maximum/minimum gradient that lies on the great circle plane.

Definition at line 1105 of file lwgeodetic.c.

1106 {
1107  POINT3D t1, t2;
1108  GEOGRAPHIC_POINT vN1, vN2;
1109  LWDEBUG(4,"entering function");
1110  robust_cross_product(start, end, &t1);
1111  normalize(&t1);
1112  robust_cross_product(end, start, &t2);
1113  normalize(&t2);
1114  LWDEBUGF(4, "unit normal t1 == POINT(%.8g %.8g %.8g)", t1.x, t1.y, t1.z);
1115  LWDEBUGF(4, "unit normal t2 == POINT(%.8g %.8g %.8g)", t2.x, t2.y, t2.z);
1116  cart2geog(&t1, &vN1);
1117  cart2geog(&t2, &vN2);
1118  g_top->lat = z_to_latitude(t1.z,LW_TRUE);
1119  g_top->lon = vN2.lon;
1120  g_bottom->lat = z_to_latitude(t2.z,LW_FALSE);
1121  g_bottom->lon = vN1.lon;
1122  LWDEBUGF(4, "clairaut top == GPOINT(%.6g %.6g)", g_top->lat, g_top->lon);
1123  LWDEBUGF(4, "clairaut bottom == GPOINT(%.6g %.6g)", g_bottom->lat, g_bottom->lon);
1124  return LW_SUCCESS;
1125 }
#define LW_FALSE
Definition: liblwgeom.h:94
#define LW_SUCCESS
Definition: liblwgeom.h:97
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
void normalize(POINT3D *p)
Normalize to a unit vector.
Definition: lwgeodetic.c:615
void cart2geog(const POINT3D *p, GEOGRAPHIC_POINT *g)
Convert cartesian coordinates on unit sphere to spherical coordinates.
Definition: lwgeodetic.c:414
double z_to_latitude(double z, int top)
Used in great circle to compute the pole of the great circle.
Definition: lwgeodetic.c:1053
void robust_cross_product(const GEOGRAPHIC_POINT *p, const GEOGRAPHIC_POINT *q, POINT3D *a)
Computes the cross product of two vectors using their lat, lng representations.
Definition: lwgeodetic.c:634
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:83
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:88
Point in spherical coordinates on the world.
Definition: lwgeodetic.h:54
double z
Definition: liblwgeom.h:402
double x
Definition: liblwgeom.h:402
double y
Definition: liblwgeom.h:402

References cart2geog(), GEOGRAPHIC_POINT::lat, GEOGRAPHIC_POINT::lon, LW_FALSE, LW_SUCCESS, LW_TRUE, LWDEBUG, LWDEBUGF, normalize(), robust_cross_product(), POINT3D::x, POINT3D::y, POINT3D::z, and z_to_latitude().

Referenced by test_clairaut().

Here is the call graph for this function:
Here is the caller graph for this function: