Table of Contents

Class GestureVelocityMath

Pure release-velocity math shared by pan and axis (zoom/rotate) fling tracking: a short windowed history collapsed to one velocity, plus the fling-duration formula derived from it.

public static class GestureVelocityMath
Inheritance
object
GestureVelocityMath

Remarks

Zero-alloc: callers own the sample buffer and pass it in by reference; nothing here allocates. Time is injected (now) rather than read live, so this stays pure C# with no engine dependency.

Methods

AxisVelocity(AxisVelocitySample[], int, double, double, double)

Scalar-axis velocity over the most recent window ending at now. Zero when the buffer is too short, or the newest sample is older than staleSeconds (held-still, no fling).

public static double AxisVelocity(AxisVelocitySample[] buf, int count, double now, double windowSeconds, double staleSeconds)

Parameters

buf AxisVelocitySample[]
count int
now double
windowSeconds double
staleSeconds double

Returns

double

FlingDuration(double)

Fling duration from release speed: (log(|v| + e^-2) + 2) * 150 ms, linear decay to zero.

public static double FlingDuration(double v)

Parameters

v double

Returns

double

TryReleaseVelocity2D(PositionVelocitySample[], int, double, double, double, bool, out double, out double)

2D release velocity over the most recent window ending at now, with optional antimeridian wrap on X (mercator X samples live in [0, 1) and can wrap across the seam). False (velX = velY = 0) when the buffer is too short, the newest sample is stale, or the window collapses to zero duration.

public static bool TryReleaseVelocity2D(PositionVelocitySample[] buf, int count, double now, double windowSeconds, double staleSeconds, bool wrapX, out double velX, out double velY)

Parameters

buf PositionVelocitySample[]
count int
now double
windowSeconds double
staleSeconds double
wrapX bool
velX double
velY double

Returns

bool