Simulation2D class

A wrapper class that combines two simulations to create 2D motion.

Simulation2D allows you to specify separate physics simulations or curves for X and Y coordinates. Both coordinates must use the same type - either both PhysicsSimulation or both regular non-simulation Curve.

// Using physics simulations
final physics2D = Simulation2D(
  Spring.elegant, // X-axis uses elegant spring motion
  Spring.swift,   // Y-axis uses swift spring motion
);

// Using standard curves
final curves2D = Simulation2D(
  Curves.easeOut, // X-axis eases out
  Curves.easeIn,  // Y-axis eases in
);

When using physics simulations, the simulation provides additional methods for velocity and position calculations in 2D space.

Inheritance

Constructors

Simulation2D(Physics _x, Physics _y)
Creates a 2D simulation using separate simulations for x and y coordinates. Simulation2D allows you to specify separate physics simulations or curves for X and Y coordinates. Both coordinates must use the same type - either both PhysicsSimulation or both regular non-simulation Curve.
const

Properties

hashCode int
The hash code for this object.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
samplingSeed int
Returns a seed value used by generateSamples to seed a random number generator to avoid sample aliasing.
no setterinherited
xPhysics Curve
Returns the physics simulation for the X axis.
no setter
yPhysics Curve
Returns the physics simulation for the Y axis.
no setter

Methods

dx(double time) Offset
Returns the velocity of the 2D simulation at the given time.
findInverse(double x) double
Returns the parameter t that corresponds to the given x value of the spline.
inherited
generateSamples({double start = 0.0, double end = 1.0, double tolerance = 1e-10}) Iterable<Curve2DSample>
Generates a list of samples with a recursive subdivision until a tolerance of tolerance is reached.
inherited
isDone(double time) bool
Returns true if both simulations are done at the given time.
isPhysicsBased() bool
Returns true if both simulations are physics-based, ie. both are of type PhysicsSimulation.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
override
transform(double t) Offset
Returns the value of the curve at point t.
override
transformInternal(double t) Offset
Returns the value of the curve at point t.
inherited
x(double time) Offset
Returns the position of the 2D simulation at the given time.

Operators

operator ==(Object other) bool
The equality operator.
override