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

◆ curvature()

float MayaFlux::Kinesis::curvature ( const glm::vec2 &  vel,
const glm::vec2 &  accel,
float  min_speed = 1e-3F 
)
inlinenoexcept

Signed curvature from velocity and acceleration.

Parameters
velVelocity vector
accelAcceleration vector
min_speedSpeed below which curvature is reported as 0 rather than computed. Default 1e-3, not 1e-6: curvature divides by speed^3, so at real input scales (e.g. normalized 0..1 tablet coordinates per second, where a slow-moving stroke is speed 0.05-0.5) a guard near machine epsilon never fires, and the cubic denominator still amplifies ordinary acceleration noise into numbers in the thousands. The threshold has to be picked relative to the caller's actual speed scale, not left at a constant close to zero; 1e-3 is a reasonable default for normalized 0..1 spatial data but a caller working in different units (pixels, millimeters) should pass one appropriate to that scale rather than rely on this default.
Returns
(vx*ay - vy*ax) / |v|^3, or 0 when speed is below min_speed

dtheta/ds rather than dtheta/dt: speed-independent, so a sharp corner drawn slowly and the same corner drawn fast report the same curvature, unlike angular_velocity which conflates turn sharpness with pace. Positive is a leftward (CCW) bend, negative rightward. Even with a correctly scaled min_speed, curvature remains numerically sensitive near that threshold since it is still a cubic denominator; treat curvature values from low-speed samples as low-confidence regardless of whether they cleared the guard.

Definition at line 418 of file Differential.hpp.

419{
420 const float speed_sq = glm::dot(vel, vel);
421 const float spd = std::sqrt(speed_sq);
422 if (spd < min_speed)
423 return 0.0F;
424 return cross_2d(vel, accel) / (speed_sq * spd);
425}
float cross_2d(const glm::vec2 &a, const glm::vec2 &b) noexcept
2D scalar cross product, sign of turn direction

References cross_2d().

Referenced by channel_curvature(), compute_path_curvature(), and curvature_from_history().

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