PostGIS  3.7.0dev-r@@SVN_REVISION@@

◆ project_pt()

int project_pt ( const POINT2D P,
double  distance,
double  azimuth,
POINT2D R 
)

Azimuth is angle in radians from vertical axis.

Definition at line 2522 of file measures.c.

2523 {
2524  const double TWOPI = 2.0 * M_PI;
2525  double slope;
2526  /* Deal with azimuth out of (-360,360) range */
2527  int orbits = floor(azimuth / TWOPI);
2528  azimuth -= TWOPI * orbits;
2529  /* Convert from azimuth to conventional slope */
2530  slope = TWOPI - azimuth + M_PI_2;
2531  if (slope > 0 && slope > TWOPI) slope -= TWOPI;
2532  if (slope < 0 && slope < -TWOPI) slope += TWOPI;
2533 
2534  double dx = cos(slope) * distance;
2535  double dy = sin(slope) * distance;
2536  R->x = P->x + dx;
2537  R->y = P->y + dy;
2538  return LW_TRUE;
2539 }
#define LW_TRUE
Return types for functions with status returns.
Definition: liblwgeom.h:93
static double distance(double x1, double y1, double x2, double y2)
Definition: lwtree.c:1032
double y
Definition: liblwgeom.h:390
double x
Definition: liblwgeom.h:390

References distance(), LW_TRUE, POINT2D::x, and POINT2D::y.

Referenced by lwpoint_project().

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