Table of Contents

Class PanFlingMath

Namespace
LansMap.Core.Control

Steps pan-fling inertia in screen density-independent pixels, independent of zoom.

public static class PanFlingMath
Inheritance
object
PanFlingMath

Remarks

Velocity and deceleration live in dp/s. Convert to mercator each frame with the live dp-per-mercator factor.

Methods

DpVelocityToMercatorDelta(double, double, double, double, out double, out double)

Converts one frame of dp/s velocity to a mercator displacement.

public static void DpVelocityToMercatorDelta(double velDpX, double velDpY, double dpPerMercLive, double deltaTime, out double mercDeltaX, out double mercDeltaY)

Parameters

velDpX double

X velocity in dp/s.

velDpY double

Y velocity in dp/s.

dpPerMercLive double

Live dp per normalized mercator unit (WorldSizePx/DpiScale this frame).

deltaTime double

Frame duration in seconds.

mercDeltaX double

X displacement in normalized mercator.

mercDeltaY double

Y displacement in normalized mercator.

Remarks

Pass the current WorldSizePx/DpiScale after any zoom that already landed, never a value cached from an earlier frame. This is the only place mercator and dp space meet.

Step(double, double, double, double, double)

Decays one frame of fling velocity in dp/s, with no mercator or zoom input.

public static PanFlingMath.Result Step(double velDpX, double velDpY, double flingDecelDpPerS2, double flingMinSpeedDp, double deltaTime)

Parameters

velDpX double

Current x velocity in dp/s (used for this frame's move).

velDpY double

Current y velocity in dp/s (used for this frame's move).

flingDecelDpPerS2 double

Linear deceleration in dp/s^2.

flingMinSpeedDp double

Stop threshold in dp/s.

deltaTime double

Frame duration in seconds.

Returns

PanFlingMath.Result

Decayed dp/s velocity for the next call, or StoppedResult.

Remarks

Convert the pre-decay (velDpX, velDpY) to a mercator move via DpVelocityToMercatorDelta(double, double, double, double, out double, out double), then store this result for the next frame (move at current speed, then decay).