Companion

Properties

Link copied to clipboard
const val FOLLOW_TIME_CONSTANT: Double = 0.07

How quickly the shown turn catches up with the hand.

Link copied to clipboard
const val FRICTION_TIME_CONSTANT: Double = 0.22

How quickly a released spin slows; it is all but stopped within a second.

Link copied to clipboard
const val MAXIMUM_SPEED: Float = 8.0f
Link copied to clipboard
const val MINIMUM_FLICK_SPEED: Float = 0.6f

Releases slower than this don't coast, so letting go of a held wheel leaves it still.

Link copied to clipboard
const val RESET_TIME_CONSTANT: Double = 0.1

The slower ease a double tap uses to swing back to north.

Link copied to clipboard
const val STOP_SPEED: Float = 0.15f

A coast slows to this and stops.

Link copied to clipboard
const val VELOCITY_WINDOW: Double = 0.1

The span of hand movement the release speed is measured over.

Functions

Link copied to clipboard
fun decayed(velocity: Float, dt: Double): Float

A coasting speed after friction has acted for dt, zero once it is slow enough to stop.

Link copied to clipboard
fun eased(current: Float, target: Float, dt: Double, timeConstant: Double): Float

Moves current toward target by the share of the gap one step of dt closes, the same at any frame rate.

Link copied to clipboard
fun velocityOf(samples: List<Pair<Double, Float>>, now: Double, window: Double = VELOCITY_WINDOW): Float

The speed over the samples (time, yaw) in the last window before now, zero without enough of them. The span runs to now, so a hand that stopped before letting go reads as slower.