Table of Contents

Struct CubicMotionCurve

Namespace
Xui.Core.Animation
Assembly
Core.dll

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

startTime TimeSpan
endTime TimeSpan
a NFloat
b NFloat
c NFloat
d NFloat

Fields

A

The cubic coefficient (multiplied by t³).

public readonly NFloat A

Field Value

NFloat

B

The quadratic coefficient (multiplied by t²).

public readonly NFloat B

Field Value

NFloat

C

The linear coefficient (multiplied by t).

public readonly NFloat C

Field Value

NFloat

D

The constant offset term.

public readonly NFloat D

Field Value

NFloat

EndTime

The time at which the motion curve ends.

public readonly TimeSpan EndTime

Field Value

TimeSpan

StartTime

The time at which the motion curve starts.

public readonly TimeSpan StartTime

Field Value

TimeSpan

Properties

DurationSeconds

The duration of the motion curve, in seconds.

public NFloat DurationSeconds { get; }

Property Value

NFloat

FinalPosition

The final position at EndTime.

public NFloat FinalPosition { get; }

Property Value

NFloat

this[TimeSpan]

Evaluates the position at the specified time.

public NFloat this[TimeSpan time] { get; }

Parameters

time TimeSpan

An 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

startTime TimeSpan
endTime TimeSpan
endPosition NFloat
endVelocity NFloat

Returns

CubicMotionCurve

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 TimeSpan

The curve's start time.

startPosition NFloat

The position at startTime.

startVelocity NFloat

The velocity at startTime.

endTime TimeSpan

The curve's end time.

endPosition NFloat

The position at endTime.

endVelocity NFloat

The 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 TimeSpan

An absolute time value.

Returns

NFloat

The velocity at the given time.