class StopLogic : MotionInterpolator


This contains the class to provide the logic for an animation to come to a stop. The setup defines a series of velocity gradients that gets to the desired position ending at 0 velocity. The path is computed such that the velocities are continuous

Summary

Public constructors

Public functions

Unit
config(
    currentPos: Float,
    destination: Float,
    currentVelocity: Float,
    maxTime: Float,
    maxAcceleration: Float,
    maxVelocity: Float
)

Configure the stop logic base on the parameters

String!
debug(desc: String!, time: Float)

Debugging logic to log the state.

Float

Gets the interpolated given the original interpolation

Float

Gets the velocity at the last interpolated point

Float

Get the velocity at a point in time

Boolean
Unit
springConfig(
    currentPos: Float,
    destination: Float,
    currentVelocity: Float,
    mass: Float,
    stiffness: Float,
    damping: Float,
    stopThreshold: Float,
    boundaryMode: Int
)

This configure the stop logic to be a spring.

Inherited functions

From android.animation.TimeInterpolator
abstract Float

Public constructors

StopLogic

Added in 2.2.0
StopLogic()

Public functions

config

Added in 2.2.0
fun config(
    currentPos: Float,
    destination: Float,
    currentVelocity: Float,
    maxTime: Float,
    maxAcceleration: Float,
    maxVelocity: Float
): Unit

Configure the stop logic base on the parameters

Parameters
currentPos: Float

start position

destination: Float

the ending position

currentVelocity: Float

the starting velocity

maxTime: Float

The maximum time to take

maxAcceleration: Float

the maximum acceleration to use

maxVelocity: Float

the maximum velocity to use

debug

Added in 2.2.0
fun debug(desc: String!, time: Float): String!

Debugging logic to log the state.

Parameters
desc: String!

Description to pre append

time: Float

Time during animation

Returns
String!

string useful for debugging the state of the StopLogic

getInterpolation

Added in 2.2.0
fun getInterpolation(v: Float): Float

Gets the interpolated given the original interpolation

Parameters
v: Float
Returns
Float

getVelocity

Added in 2.2.0
fun getVelocity(): Float

Gets the velocity at the last interpolated point

Returns
Float

getVelocity

Added in 2.2.0
fun getVelocity(x: Float): Float

Get the velocity at a point in time

Parameters
x: Float
Returns
Float

isStopped

Added in 2.2.0
fun isStopped(): Boolean

springConfig

Added in 2.2.0
fun springConfig(
    currentPos: Float,
    destination: Float,
    currentVelocity: Float,
    mass: Float,
    stiffness: Float,
    damping: Float,
    stopThreshold: Float,
    boundaryMode: Int
): Unit

This configure the stop logic to be a spring. Moving from currentPosition(P0) to destination with an initial velocity of currentVelocity (V0) moving as if it has a mass (m) with spring constant stiffness(k), and friction(c) It moves with the equation acceleration a = (-k.x-c.v)/m. x = current position - destination v is velocity

Parameters
currentPos: Float

The current position

destination: Float

The destination position

currentVelocity: Float

the initial velocity

mass: Float

the mass

stiffness: Float

the stiffness or spring constant (the force by which the spring pulls)

damping: Float

the stiffness or spring constant. (the resistance to the motion)

stopThreshold: Float

(When the max velocity of the movement is below this it stops)

boundaryMode: Int

This controls if it overshoots or bounces when it hits 0 and 1