PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ 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 2421 of file measures.c.

2422{
2423 const double TWOPI = 2.0 * M_PI;
2424 double slope;
2425 /* Deal with azimuth out of (-360,360) range */
2426 int orbits = floor(azimuth / TWOPI);
2427 azimuth -= TWOPI * orbits;
2428 /* Convert from azimuth to conventional slope */
2429 slope = TWOPI - azimuth + M_PI_2;
2430 if (slope > 0 && slope > TWOPI) slope -= TWOPI;
2431 if (slope < 0 && slope < -TWOPI) slope += TWOPI;
2432
2433 double dx = cos(slope) * distance;
2434 double dy = sin(slope) * distance;
2435 R->x = P->x + dx;
2436 R->y = P->y + dy;
2437 return LW_TRUE;
2438}
#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: