- Description
- Method Summary
- Method Details
- acceleration(EasingCurveMode, double, double, double, double)
- deceleration(EasingCurveMode, double, double, double, double)
- curveBiasFor(EasingCurveMode, double)
- zoneOverlapScale(double, double, double)
- durationFor(double, double)
- commandedSpeed(double, double, double, double, double)
- distanceFractionAt(double)
- isScheduleComplete(double)
- latch(double, double)
- drop()
- advance(double)
- isLatched()
- getLatchedDistance()
- getLatchedElapsedTime()
- getMode()
- getMinimumRelativeSpeed()
Class EasingRamp
BiasedEasing gives the shape and the phase
duration comes from the distance the ramp has to cover, so a full sweep covers that distance.
Progress through the curve is a function of elapsed time, never of position, so the ramp cannot get stuck at its own zero-speed boundary.
An acceleration ramp reads the curve forward, from the slow end up to the fast end. A deceleration ramp reads it backwards, so it leaves fast and arrives slow. Both therefore give a config value the same meaning in either phase.
The EasingCurveMode decides what the curve means:
VelocityOverTimereads it as relative speed and commands that speed directly. The curve is traversed over[startOffset, 1]rather than[0, 1], so the ramp bottoms out at the configured minimum relative speed instead of at a standstill.DistanceOverTimereads it as the fraction of the distance covered and commands the speed that closes the gap to that position over the tick. The minimum relative speed becomes the slope at the slow end, solved for when the curve is built. The half time value is mapped onto the fractions a ramp can reach, seecurveBiasFor(EasingCurveMode, double). Because the loop is closed on position, the ramp arrives exactly on its distance and recovers from ticks that delivered less than they were asked for.
A ramp also carries the latch: a deceleration ramp only picks up its distance once the charge reaches its zone, and has to re-latch when the path changes under it. An acceleration ramp runs from the start of the charge and is driven straight from the charge clock, so it leaves the latch unused.
-
Method Summary
Modifier and TypeMethodDescriptionstatic EasingRampacceleration(EasingCurveMode mode, double halfTimeValue, double halfTimeSteepness, double endSteepness, double minimumRelativeSpeed) Ramp that reads the curve forward, from its slow end up to its fast end.voidadvance(double dt) doublecommandedSpeed(double distance, double travelled, double elapsedTime, double maxSpeed, double dt) Speed this ramp asks for, in blocks per second, never abovemaxSpeed.static doublecurveBiasFor(EasingCurveMode mode, double halfTimeValue) Bias of the curve that a half time value asks for.static EasingRampdeceleration(EasingCurveMode mode, double halfTimeValue, double halfTimeSteepness, double endSteepness, double minimumRelativeSpeed) Ramp that reads the curve backwards, from its fast end down to its slow end.doubledistanceFractionAt(double progress) Fraction of the ramp's distance covered atprogressthrough its duration, which is the position profile the ramp follows.voiddrop()Leaves the phase, so a laterlatch(double, double)starts clean.doubledurationFor(double distance, double maxSpeed) Time a full sweep needs to coverdistance.doubledoubledoublegetMode()booleanbooleanisScheduleComplete(double maxSpeed) Whether the latched schedule has run its full duration.voidlatch(double distance, double elapsedTime) Picks updistanceand starts the phase clock atelapsedTime.static doublezoneOverlapScale(double accelerationDistance, double decelerationDistance, double chargeDistance) Factor that shrinks both ramp zones so they meet without overlapping.
-
Method Details
-
acceleration
@Nonnull public static EasingRamp acceleration(@Nonnull EasingCurveMode mode, double halfTimeValue, double halfTimeSteepness, double endSteepness, double minimumRelativeSpeed) Ramp that reads the curve forward, from its slow end up to its fast end. -
deceleration
@Nonnull public static EasingRamp deceleration(@Nonnull EasingCurveMode mode, double halfTimeValue, double halfTimeSteepness, double endSteepness, double minimumRelativeSpeed) Ramp that reads the curve backwards, from its fast end down to its slow end. -
curveBiasFor
Bias of the curve that a half time value asks for.VelocityOverTimereads the value as a speed, where the whole range describes a ramp, so it is the bias as it stands.DistanceOverTimereads it as a fraction of the distance, whichCONSTANT_SPEED_DISTANCE_FRACTIONbounds, so the value is mapped onto the fractions a ramp can reach. A value of 1 then asks for the even split that only a constant speed delivers, and the default 0.5 asks for the quarter that an even acceleration covers.The value fixes one point of the curve and nothing else. The steepness values shape the rest, so 0.5 gives the split of an even acceleration but not its straight speed profile.
A caller that names a steepness default by hand needs this, because the steepness bounds are relative to the bias and not to the config value.
-
zoneOverlapScale
public static double zoneOverlapScale(double accelerationDistance, double decelerationDistance, double chargeDistance) Factor that shrinks both ramp zones so they meet without overlapping. Without it the two schedules each assume they alone control the speed over their full distance budget, while taking the lower of the two speeds actually lets the still-ramping acceleration curve hold the speed below what the deceleration schedule assumed. That starves the deceleration of distance and leaves it to crawl at its floor speed to make up the shortfall. Shrinking mirrors how ease-in and ease-out are compressed for a short animation. -
durationFor
public double durationFor(double distance, double maxSpeed) Time a full sweep needs to coverdistance. Zero when there is nothing to ramp over, which callers read as "this ramp does not constrain the speed".Velocity mode divides the distance by the mean speed of the sweep. Distance mode multiplies by the peak slope instead, which is what puts the fastest speed the ramp commands exactly on
maxSpeed. -
commandedSpeed
public double commandedSpeed(double distance, double travelled, double elapsedTime, double maxSpeed, double dt) Speed this ramp asks for, in blocks per second, never abovemaxSpeed.Velocity mode samples the midpoint of the tick. Distance mode targets the profile position at the end of the tick.
Acceleration hands over when its schedule ends. Deceleration holds the stop position until the caller ends the phase.
- Parameters:
distance- distance the ramp has to covertravelled- distance covered since the ramp startedelapsedTime- time since the ramp started, at the end of this tickmaxSpeed- fastest speed the ramp may commanddt- length of this tick
-
distanceFractionAt
public double distanceFractionAt(double progress) Fraction of the ramp's distance covered atprogressthrough its duration, which is the position profile the ramp follows.Distance mode reads this straight off the curve. Velocity mode integrates its speed profile.
-
isScheduleComplete
public boolean isScheduleComplete(double maxSpeed) Whether the latched schedule has run its full duration. -
latch
public void latch(double distance, double elapsedTime) Picks updistanceand starts the phase clock atelapsedTime. -
drop
public void drop()Leaves the phase, so a laterlatch(double, double)starts clean. -
advance
public void advance(double dt) -
isLatched
public boolean isLatched() -
getLatchedDistance
public double getLatchedDistance() -
getLatchedElapsedTime
public double getLatchedElapsedTime() -
getMode
-
getMinimumRelativeSpeed
public double getMinimumRelativeSpeed()
-