PostGIS  3.4.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 2475 of file measures.c.

2476 {
2477  const double TWOPI = 2.0 * M_PI;
2478  double slope;
2479  /* Deal with azimuth out of (-360,360) range */
2480  int orbits = floor(azimuth / TWOPI);
2481  azimuth -= TWOPI * orbits;
2482  /* Convert from azimuth to conventional slope */
2483  slope = TWOPI - azimuth + M_PI_2;
2484  if (slope > 0 && slope > TWOPI) slope -= TWOPI;
2485  if (slope < 0 && slope < -TWOPI) slope += TWOPI;
2486 
2487  double dx = cos(slope) * distance;
2488  double dy = sin(slope) * distance;
2489  R->x = P->x + dx;
2490  R->y = P->x + dy;
2491  return LW_TRUE;
2492 }
#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: