MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ centroid() [1/3]

template<PositionCarrying T>
glm::vec3 MayaFlux::Kinesis::centroid ( std::span< T >  pts)
noexcept

Arithmetic centroid (uniform weight) of a PositionCarrying span.

Computes the first geometric moment with measure 1 per point. Returns the zero vector for an empty span.

Template Parameters
TAny type satisfying PositionCarrying.
Parameters
ptsNon-owning span of points.
Returns
Mean position.

Definition at line 43 of file Morphology.hpp.

44{
45 if (pts.empty())
46 return glm::vec3(0.0F);
47 glm::vec3 acc(0.0F);
48 for (const auto& p : pts)
49 acc += static_cast<glm::vec3>(p.position);
50 return acc / static_cast<float>(pts.size());
51}