PostGIS  2.5.0rc1dev-r@@SVN_REVISION@@

◆ init_guess()

static POINT3D init_guess ( const POINT4D points,
uint32_t  npoints 
)
static

Definition at line 152 of file lwgeom_median.c.

References POINT4D::m, POINT3D::x, POINT4D::x, POINT3D::y, POINT4D::y, POINT3D::z, and POINT4D::z.

Referenced by lwmpoint_median().

153 {
154  assert(npoints > 0);
155  POINT3D guess = { 0, 0, 0 };
156  double mass = 0;
157  uint32_t i;
158  for (i = 0; i < npoints; i++)
159  {
160  guess.x += points[i].x * points[i].m;
161  guess.y += points[i].y * points[i].m;
162  guess.z += points[i].z * points[i].m;
163  mass += points[i].m;
164  }
165  guess.x /= mass;
166  guess.y /= mass;
167  guess.z /= mass;
168  return guess;
169 }
double x
Definition: liblwgeom.h:354
double m
Definition: liblwgeom.h:354
double y
Definition: liblwgeom.h:342
double x
Definition: liblwgeom.h:342
double z
Definition: liblwgeom.h:342
unsigned int uint32_t
Definition: uthash.h:78
double z
Definition: liblwgeom.h:354
double y
Definition: liblwgeom.h:354
Here is the caller graph for this function: