PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ circ_center_spherical()

static int circ_center_spherical ( const GEOGRAPHIC_POINT c1,
const GEOGRAPHIC_POINT c2,
double  distance,
double  offset,
GEOGRAPHIC_POINT center 
)
static

Given the centers of two circles, and the offset distance we want to put the new center between them (calculated as the distance implied by the radii of the inputs and the distance between the centers) figure out where the new center point is, by getting the direction from c1 to c2 and projecting from c1 in that direction by the offset distance.

Definition at line 166 of file lwgeodetic_tree.c.

167 {
168  /* Direction from c1 to c2 */
169  double dir = sphere_direction(c1, c2, distance);
170 
171  LWDEBUG(4,"calculating spherical center");
172 
173  LWDEBUGF(4,"dir is %g", dir);
174 
175  /* Catch sphere_direction when it barfs */
176  if ( isnan(dir) )
177  return LW_FAILURE;
178 
179  /* Center of new circle is projection from start point, using offset distance*/
180  return sphere_project(c1, offset, dir, center);
181 }
#define LW_FAILURE
Definition: liblwgeom.h:96
int sphere_project(const GEOGRAPHIC_POINT *r, double distance, double azimuth, GEOGRAPHIC_POINT *n)
Given a starting location r, a distance and an azimuth to the new point, compute the location of the ...
Definition: lwgeodetic.c:1268
double sphere_direction(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e, double d)
Given two points on a unit sphere, calculate the direction from s to e.
Definition: lwgeodetic.c:927
#define LWDEBUG(level, msg)
Definition: lwgeom_log.h:101
#define LWDEBUGF(level, msg,...)
Definition: lwgeom_log.h:106
static double distance(double x1, double y1, double x2, double y2)
Definition: lwtree.c:1032

References distance(), LW_FAILURE, LWDEBUG, LWDEBUGF, sphere_direction(), and sphere_project().

Referenced by circ_node_internal_new().

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