Struct CubicMotionCurve
Represents a 1D cubic motion curve over time, interpolating both position and velocity. Time is expressed using TimeSpan, and calculations are performed in seconds.
public readonly struct CubicMotionCurve
- Inherited Members
Remarks
This curve is defined by a cubic polynomial:
f(t) = A·t³ + B·t² + C·t + D
, where t
is time in seconds since the global epoch.
It supports generation from boundary conditions (position and velocity at both ends),
as well as curve continuation with seamless velocity transitions.
Constructors
CubicMotionCurve(TimeSpan, TimeSpan, NFloat, NFloat, NFloat, NFloat)
Initializes a new cubic motion curve with the given polynomial coefficients and time range.
public CubicMotionCurve(TimeSpan startTime, TimeSpan endTime, NFloat a, NFloat b, NFloat c, NFloat d)
Parameters
Fields
A
The cubic coefficient (multiplied by t³).
public readonly NFloat A
Field Value
B
The quadratic coefficient (multiplied by t²).
public readonly NFloat B
Field Value
C
The linear coefficient (multiplied by t).
public readonly NFloat C
Field Value
D
The constant offset term.
public readonly NFloat D
Field Value
EndTime
The time at which the motion curve ends.
public readonly TimeSpan EndTime
Field Value
StartTime
The time at which the motion curve starts.
public readonly TimeSpan StartTime
Field Value
Properties
DurationSeconds
The duration of the motion curve, in seconds.
public NFloat DurationSeconds { get; }
Property Value
FinalPosition
The final position at EndTime.
public NFloat FinalPosition { get; }
Property Value
this[TimeSpan]
Evaluates the position at the specified time.
public NFloat this[TimeSpan time] { get; }
Parameters
time
TimeSpanAn absolute time value.
Property Value
- NFloat
The position at the given time.
Methods
ContinueWithBoundaryConditions(TimeSpan, TimeSpan, NFloat, NFloat)
Continues the current curve by constructing a new cubic motion curve that begins where this one leaves off, matching position and velocity, and interpolating to a new position and velocity over the given time range.
public CubicMotionCurve ContinueWithBoundaryConditions(TimeSpan startTime, TimeSpan endTime, NFloat endPosition, NFloat endVelocity)
Parameters
Returns
FromBoundaryConditions(TimeSpan, NFloat, NFloat, TimeSpan, NFloat, NFloat)
Constructs a cubic motion curve that interpolates position and velocity between two points in time using Hermite interpolation.
public static CubicMotionCurve FromBoundaryConditions(TimeSpan startTime, NFloat startPosition, NFloat startVelocity, TimeSpan endTime, NFloat endPosition, NFloat endVelocity)
Parameters
startTime
TimeSpanThe curve's start time.
startPosition
NFloatThe position at
startTime
.startVelocity
NFloatThe velocity at
startTime
.endTime
TimeSpanThe curve's end time.
endPosition
NFloatThe position at
endTime
.endVelocity
NFloatThe velocity at
endTime
.
Returns
- CubicMotionCurve
A cubic motion curve satisfying the specified boundary conditions.
VelocityAt(TimeSpan)
Evaluates the velocity at the specified time.
public NFloat VelocityAt(TimeSpan time)
Parameters
time
TimeSpanAn absolute time value.
Returns
- NFloat
The velocity at the given time.