RK4Spring class

A spring simulation using 4th-order Runge-Kutta numerical integration.

The critical feature: _accelerationMultiplier ramps from 0→1 over ~167ms. This makes the spring start gentle and build up force — the "soft onset" that no standard analytical spring can produce.

Usage:

final spring = RK4Spring(
  initValue: 0.0,
  desc: RK4SpringDescription(tension: 450, friction: 50),
);
spring.target = 1.0;
// Call elapseTime() each frame, read spring.value

Constructors

RK4Spring({double initValue = 0.0, RK4SpringDescription desc = const RK4SpringDescription()})

Properties

desc → RK4SpringDescription
final
hashCode → int
The hash code for this object.
no setterinherited
isDone → bool
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
target ↔ double
Set a new target. The spring picks up from its current value and velocity. If the direction flips, velocity is negated (preserving momentum).
getter/setter pair
value → double
no setter
velocity → double
no setter

Methods

elapseTime(double seconds) → void
Advance the simulation by seconds.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited