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

◆ normalize_shape()

std::vector< glm::vec2 > MayaFlux::Kinesis::normalize_shape ( std::span< const glm::vec2 >  path)
inline

Centre a path at the origin and scale it to unit spread.

Parameters
pathPositions in chronological order
Returns
Path translated so its centroid is at the origin and scaled so its root mean square distance from the origin is one

The alternative shape normalization to a turning profile. A profile compares how paths bent; this compares where their points are, once position and size are removed. Point comparison keeps information about proportion that turning discards, and unlike turning it stays well defined for paths with stationary stretches where no heading exists. Rotation is not removed, so orientation remains part of the identity of the shape under this normalization.

Definition at line 277 of file PathShape.hpp.

279{
280 std::vector<glm::vec2> out(path.begin(), path.end());
281 if (out.empty())
282 return out;
283
284 glm::vec2 mean { 0.0F };
285 for (const auto& p : out)
286 mean += p;
287 mean /= static_cast<float>(out.size());
288
289 float acc = 0.0F;
290 for (auto& p : out) {
291 p -= mean;
292 acc += glm::dot(p, p);
293 }
294
295 const float rms = std::sqrt(acc / static_cast<float>(out.size()));
296 if (rms < 1e-6F)
297 return out;
298
299 for (auto& p : out)
300 p /= rms;
301 return out;
302}
std::vector< float > * out
double mean(const std::vector< double > &data)
Calculate mean of single-channel data.
Definition Yantra.cpp:55

References MayaFlux::mean(), out, and MayaFlux::rms().

Referenced by shape_distance().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: