Table of Contents

Struct MapFollowSmoother

Namespace
LansMap.Core.Control

Critically damped smoothing state for a map center (X/Y in whatever linear unit the caller feeds it, normally mercator) and, optionally, its rotation.

public struct MapFollowSmoother
Inherited Members

Remarks

A mutable struct: the owning component holds one as a plain field and calls Step(double, double, double, double, double, bool) once per frame, no allocation. Reset(double, double, double) jumps straight to a value with zero velocity, for the frame a follow target changes and the view should snap rather than swoop from wherever it was.

Properties

RotationDeg

Current smoothed rotation in degrees, normalized to [0, 360).

public double RotationDeg { get; }

Property Value

double

X

Current smoothed X.

public double X { get; }

Property Value

double

Y

Current smoothed Y.

public double Y { get; }

Property Value

double

Methods

Reset(double, double, double)

Jumps straight to a value with zero velocity.

public void Reset(double x, double y, double rotationDeg)

Parameters

x double

X to snap to.

y double

Y to snap to.

rotationDeg double

Rotation in degrees to snap to.

ResetPosition(double, double)

Jumps the X/Y channels to a value with zero velocity, leaving rotation untouched.

public void ResetPosition(double x, double y)

Parameters

x double

X to snap to.

y double

Y to snap to.

ResetRotation(double)

Jumps the rotation channel to a value with zero velocity, leaving X/Y untouched.

public void ResetRotation(double rotationDeg)

Parameters

rotationDeg double

Rotation in degrees to snap to.

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

Advances one tick toward the given target.

public void Step(double targetX, double targetY, double targetRotationDeg, double smoothSeconds, double deltaSeconds, bool smoothRotation)

Parameters

targetX double

Target X.

targetY double

Target Y.

targetRotationDeg double

Target rotation in degrees.

smoothSeconds double

Seconds to settle. Zero, negative, or NaN snaps immediately.

deltaSeconds double

Elapsed time this tick, in seconds. Non-positive is a no-op: nothing elapsed, nothing moves.

smoothRotation bool

Whether rotation moves this tick. False leaves RotationDeg and its velocity untouched, other than the snap a non-positive smoothSeconds still applies to X/Y.