PostGIS  2.5.7dev-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.

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 z
Definition: liblwgeom.h:343
double x
Definition: liblwgeom.h:343
double y
Definition: liblwgeom.h:343
double m
Definition: liblwgeom.h:355
double x
Definition: liblwgeom.h:355
double z
Definition: liblwgeom.h:355
double y
Definition: liblwgeom.h:355
unsigned int uint32_t
Definition: uthash.h:78

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

Referenced by lwmpoint_median().

Here is the caller graph for this function: