Class PanFlingMath
Steps pan-fling inertia in screen density-independent pixels, independent of zoom.
public static class PanFlingMath
- Inheritance
-
objectPanFlingMath
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
velDpXdoubleX velocity in dp/s.
velDpYdoubleY velocity in dp/s.
dpPerMercLivedoubleLive dp per normalized mercator unit (WorldSizePx/DpiScale this frame).
deltaTimedoubleFrame duration in seconds.
mercDeltaXdoubleX displacement in normalized mercator.
mercDeltaYdoubleY 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
velDpXdoubleCurrent x velocity in dp/s (used for this frame's move).
velDpYdoubleCurrent y velocity in dp/s (used for this frame's move).
flingDecelDpPerS2doubleLinear deceleration in dp/s^2.
flingMinSpeedDpdoubleStop threshold in dp/s.
deltaTimedoubleFrame 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).