Helper class to compute the middle point in a point set. More...
#include <geo_vectors_utils.h>
Public Member Functions | |
MiddlePointAccumulatorDim () | |
Default constructor: starts with no accumulated point. More... | |
template<typename BeginIter , typename EndIter > | |
MiddlePointAccumulatorDim (BeginIter begin, EndIter end) | |
Constructor: starts with accumulating a sequence of points. More... | |
Result query | |
bool | empty () const |
Returns whether the total weight is zero (usually means no points). More... | |
double | weight () const |
Returns the total weight (number of points if all have weight 1). More... | |
template<typename Point > | |
Point | middlePointAs () const |
Returns the middle point, NaN components if no point. More... | |
geo::Point_t | middlePoint () const |
Addition of points | |
template<typename Point > | |
void | add (Point const &p) |
Accumulates a point. More... | |
template<typename Point > | |
void | add (Point const &p, double weight) |
Accumulates a point. More... | |
template<typename BeginIter , typename EndIter > | |
void | add (BeginIter begin, EndIter end) |
Adds a sequence of points. More... | |
void | clear () |
Resets the status of the object to no accumulated points. More... | |
Private Types | |
using | IndexSequence_t = std::make_index_sequence< Dim > |
Private Member Functions | |
template<typename Point , std::size_t... I> | |
Point | makePointImpl (std::index_sequence< I...>) const |
template<typename Point , std::size_t... I> | |
Point | makeWeightedPointImpl (double w, std::index_sequence< I...>) const |
template<typename Point > | |
Point | makePoint () const |
Converts the internal sums into a Point . More... | |
template<typename Point > | |
Point | makeWeightedPoint (double w) const |
Private Attributes | |
std::array< Length_t, Dim > | fSums |
Sum of each of the point components. More... | |
double | fW = 0.0 |
Total weight. More... | |
Static Private Attributes | |
static constexpr unsigned int | Dim = N |
Dimension of the points. More... | |
Helper class to compute the middle point in a point set.
N | _(default: 3 )_ dimension of the points |
This class accumulates cartesian points and returns their middle point when asked.
In the following example, only the points from a list (points
) which have y coordinate larger than 0 are averaged, all with the same weight:
Note the check to make sure that there are points that fulfil the requirement.
Definition at line 1246 of file geo_vectors_utils.h.
|
private |
Definition at line 1358 of file geo_vectors_utils.h.
|
inline |
Default constructor: starts with no accumulated point.
Definition at line 1253 of file geo_vectors_utils.h.
|
inline |
Constructor: starts with accumulating a sequence of points.
BeginIter | type of iterator to a point type compatible with add() |
EndIter | type of end iterator |
begin | iterator to the first point to be added |
end | iterator after the last point to be added |
Definition at line 1264 of file geo_vectors_utils.h.
|
inline |
Accumulates a point.
Point | point type, required to have X(), Y() and Z() accessors |
p | point to be included |
The point is added with weight 1.
Definition at line 1316 of file geo_vectors_utils.h.
|
inline |
Accumulates a point.
Point | point type, required to have X(), Y() and Z() accessors |
p | point to be included |
weight | the relative weight of this point |
Definition at line 1330 of file geo_vectors_utils.h.
|
inline |
Adds a sequence of points.
BeginIter | type of iterator to a point type compatible with add() |
EndIter | type of end iterator |
begin | iterator to the first point to be added |
end | iterator after the last point to be added |
Each point is added with weight 1.0.
Definition at line 1348 of file geo_vectors_utils.h.
|
inline |
Resets the status of the object to no accumulated points.
Definition at line 1352 of file geo_vectors_utils.h.
|
inline |
Returns whether the total weight is zero (usually means no points).
Definition at line 1274 of file geo_vectors_utils.h.
|
inlineprivate |
Converts the internal sums into a Point
.
Definition at line 1370 of file geo_vectors_utils.h.
|
inlineprivate |
Definition at line 1361 of file geo_vectors_utils.h.
|
inlineprivate |
Converts the internal sums into a Point
with components scaled by w
.
Definition at line 1376 of file geo_vectors_utils.h.
|
inlineprivate |
Definition at line 1365 of file geo_vectors_utils.h.
|
inline |
Returns the middle point as a geo::Point_t
, NaN components if no point.
Definition at line 1297 of file geo_vectors_utils.h.
|
inline |
Returns the middle point, NaN components if no point.
Point | type of the output point |
The type of return point must be specified as template argument, e.g.
The Point
type is required to have a constructor with the three cartesian components as arguments.
Definition at line 1291 of file geo_vectors_utils.h.
|
inline |
Returns the total weight (number of points if all have weight 1).
Definition at line 1277 of file geo_vectors_utils.h.
|
staticprivate |
Dimension of the points.
Definition at line 1247 of file geo_vectors_utils.h.
|
private |
Sum of each of the point components.
Definition at line 1248 of file geo_vectors_utils.h.
|
private |
Total weight.
Definition at line 1249 of file geo_vectors_utils.h.