Struct ConstantDecelerationCurve
Represents a 1D motion curve with constant deceleration (e.g., for scroll or fling). Starts at a given position and velocity, then decelerates linearly to a stop.
public readonly struct ConstantDecelerationCurve
- Inherited Members
Remarks
This model is commonly used in UI frameworks to simulate natural-feeling scroll behavior. The acceleration is constant and opposite to the direction of motion, resulting in a predictable, smooth slowdown.
Constructors
ConstantDecelerationCurve(TimeSpan, NFloat, NFloat, NFloat)
Constructs a motion curve with constant deceleration.
public ConstantDecelerationCurve(TimeSpan startTime, NFloat position, NFloat velocity, NFloat accelerationMagnitude)
Parameters
startTime
TimeSpanThe time when motion begins.
position
NFloatThe initial position at
startTime
.velocity
NFloatThe initial velocity in pixels per second.
accelerationMagnitude
NFloatThe magnitude of deceleration (must be positive).
Exceptions
- ArgumentOutOfRangeException
Thrown if
accelerationMagnitude
is not positive.
Fields
A
The constant acceleration applied during motion, typically negative.
public readonly NFloat A
Field Value
EndTime
The time when the motion stops (velocity reaches zero).
public readonly TimeSpan EndTime
Field Value
P0
The initial position at StartTime, in pixels.
public readonly NFloat P0
Field Value
StartTime
The time when the motion begins.
public readonly TimeSpan StartTime
Field Value
V0
The initial velocity at StartTime, in pixels per second.
public readonly NFloat V0
Field Value
Properties
DurationSeconds
The total duration of the motion in seconds.
public NFloat DurationSeconds { get; }
Property Value
this[TimeSpan]
Evaluates the position at the specified time.
public NFloat this[TimeSpan time] { get; }
Parameters
time
TimeSpanThe absolute time at which to evaluate the position.
Property Value
- NFloat
The position in pixels.
Methods
VelocityAt(TimeSpan)
Evaluates the velocity at the specified time.
public NFloat VelocityAt(TimeSpan time)
Parameters
time
TimeSpanThe absolute time at which to evaluate the velocity.
Returns
- NFloat
The velocity in pixels per second.