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

◆ shape_distance()

float MayaFlux::Kinesis::shape_distance ( std::span< const glm::vec2 >  a,
std::span< const glm::vec2 >  b,
size_t  samples = 32 
)
inline

Root mean square point distance between two paths after resampling and normalization.

Parameters
aLeft path in chronological order
bRight path in chronological order
samplesPoint count both paths are resampled to
Returns
RMS distance in normalized units

Resamples both to the same arc-length spacing, removes position and scale from each, and compares point against point. Sensitive to orientation, unlike a rotation-invariant turning profile, and sensitive to proportion, unlike turning in general.

Definition at line 317 of file PathShape.hpp.

319{
320 const std::vector<glm::vec2> ra = normalize_shape(resample_uniform(a, samples));
321 const std::vector<glm::vec2> rb = normalize_shape(resample_uniform(b, samples));
322 if (ra.size() != rb.size() || ra.empty())
323 return std::numeric_limits<float>::infinity();
324
325 float acc = 0.0F;
326 for (size_t i = 0; i < ra.size(); ++i) {
327 const glm::vec2 d = ra[i] - rb[i];
328 acc += glm::dot(d, d);
329 }
330 return std::sqrt(acc / static_cast<float>(ra.size()));
331}
size_t a
size_t b
std::vector< glm::vec2 > normalize_shape(std::span< const glm::vec2 > path)
Centre a path at the origin and scale it to unit spread.
std::vector< glm::vec2 > resample_uniform(std::span< const glm::vec2 > path, size_t count)
Resample a path to a fixed point count at uniform arc length.
Definition PathShape.hpp:45

References a, b, normalize_shape(), and resample_uniform().

+ Here is the call graph for this function: