Skip to content
modkitv0.2

math/ease.h

#include <modkit/math/ease.h>39 functions · 1 enums · 1 typedefs · 1 macros

Easing functions and interpolation helpers.

Standard Robert Penner easing set (https://easings.net), plus scalar/vector lerp and remap helpers. All functions take a normalized time t in [0,1] and return an eased value (typically in [0,1], though back/elastic overshoot). Header-only, like math/mat4.h. Use directly:

Functions

mk_clampffunction

float mk_clampf(float v, float lo, float hi)

Clamp v to [lo,hi].

ParameterTypeDescription
vfloatValue for v.
lofloatValue for lo.
hifloatValue for hi.

Returns The resulting value.

mk_easefunction

float mk_ease(mk_ease_type type, float t)

Evaluate an easing function selected at runtime.

ParameterTypeDescription
typemk_ease_typeValue for type.
tfloatValue for t.

Returns The resulting value.

mk_ease_back_infunction

float mk_ease_back_in(float t)

Perform the ease back in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_back_inoutfunction

float mk_ease_back_inout(float t)

Perform the ease back inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_back_outfunction

float mk_ease_back_out(float t)

Perform the ease back out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_bounce_infunction

float mk_ease_bounce_in(float t)

Perform the ease bounce in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_bounce_inoutfunction

float mk_ease_bounce_inout(float t)

Perform the ease bounce inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_bounce_outfunction

float mk_ease_bounce_out(float t)

Perform the ease bounce out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_circ_infunction

float mk_ease_circ_in(float t)

Perform the ease circ in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_circ_inoutfunction

float mk_ease_circ_inout(float t)

Perform the ease circ inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_circ_outfunction

float mk_ease_circ_out(float t)

Perform the ease circ out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_cubic_infunction

float mk_ease_cubic_in(float t)

Perform the ease cubic in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_cubic_inoutfunction

float mk_ease_cubic_inout(float t)

Perform the ease cubic inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_cubic_outfunction

float mk_ease_cubic_out(float t)

Perform the ease cubic out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_elastic_infunction

float mk_ease_elastic_in(float t)

Perform the ease elastic in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_elastic_inoutfunction

float mk_ease_elastic_inout(float t)

Perform the ease elastic inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_elastic_outfunction

float mk_ease_elastic_out(float t)

Perform the ease elastic out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_expo_infunction

float mk_ease_expo_in(float t)

Perform the ease expo in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_expo_inoutfunction

float mk_ease_expo_inout(float t)

Perform the ease expo inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_expo_outfunction

float mk_ease_expo_out(float t)

Perform the ease expo out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_linearfunction

float mk_ease_linear(float t)

Perform the ease linear operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quad_infunction

float mk_ease_quad_in(float t)

Perform the ease quad in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quad_inoutfunction

float mk_ease_quad_inout(float t)

Perform the ease quad inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quad_outfunction

float mk_ease_quad_out(float t)

Perform the ease quad out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quart_infunction

float mk_ease_quart_in(float t)

Perform the ease quart in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quart_inoutfunction

float mk_ease_quart_inout(float t)

Perform the ease quart inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quart_outfunction

float mk_ease_quart_out(float t)

Perform the ease quart out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quint_infunction

float mk_ease_quint_in(float t)

Perform the ease quint in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quint_inoutfunction

float mk_ease_quint_inout(float t)

Perform the ease quint inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_quint_outfunction

float mk_ease_quint_out(float t)

Perform the ease quint out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_sine_infunction

float mk_ease_sine_in(float t)

Perform the ease sine in operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_sine_inoutfunction

float mk_ease_sine_inout(float t)

Perform the ease sine inout operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_ease_sine_outfunction

float mk_ease_sine_out(float t)

Perform the ease sine out operation.

ParameterTypeDescription
tfloatValue for t.

Returns The resulting value.

mk_lerpfunction

float mk_lerp(float a, float b, float t)

Linear interpolation between a and b by t.

ParameterTypeDescription
afloatValue for a.
bfloatValue for b.
tfloatValue for t.

Returns The resulting value.

mk_quat_slerpfunction

mk_quat mk_quat_slerp(mk_quat a, mk_quat b, float t)

Spherical lerp between unit quaternions (thin cglm wrap).

ParameterTypeDescription
amk_quatValue for a.
bmk_quatValue for b.
tfloatValue for t.

Returns The resulting value.

mk_remapfunction

float mk_remap(float v, float in_lo, float in_hi, float out_lo, float out_hi)

Remap v from [in_lo,in_hi] onto [out_lo,out_hi].

ParameterTypeDescription
vfloatValue for v.
in_lofloatValue for in lo.
in_hifloatValue for in hi.
out_lofloatReceives the lo.
out_hifloatReceives the hi.

Returns The resulting value.

mk_unlerpfunction

float mk_unlerp(float a, float b, float v)

Inverse lerp: where v sits in [a,b] as a 0..1 fraction.

ParameterTypeDescription
afloatValue for a.
bfloatValue for b.
vfloatValue for v.

Returns The resulting value.

mk_vec2_lerpfunction

mk_vec2 mk_vec2_lerp(mk_vec2 a, mk_vec2 b, float t)

Component-wise lerp of two vec2.

ParameterTypeDescription
amk_vec2Value for a.
bmk_vec2Value for b.
tfloatValue for t.

Returns The resulting value.

mk_vec3_lerpfunction

mk_vec3 mk_vec3_lerp(mk_vec3 a, mk_vec3 b, float t)

Component-wise lerp of two vec3.

ParameterTypeDescription
amk_vec3Value for a.
bmk_vec3Value for b.
tfloatValue for t.

Returns The resulting value.

Enums

mk_ease_typeenum

Values for ease type.

ValueDescription
MK_EASE_LINEARSelects linear.
MK_EASE_QUAD_INQuadratic acceleration.
MK_EASE_QUAD_OUTQuadratic deceleration.
MK_EASE_QUAD_INOUTQuadratic acceleration then deceleration.
MK_EASE_CUBIC_INCubic acceleration.
MK_EASE_CUBIC_OUTCubic deceleration.
MK_EASE_CUBIC_INOUTCubic acceleration then deceleration.
MK_EASE_QUART_INQuartic acceleration.
MK_EASE_QUART_OUTQuartic deceleration.
MK_EASE_QUART_INOUTQuartic acceleration then deceleration.
MK_EASE_QUINT_INQuintic acceleration.
MK_EASE_QUINT_OUTQuintic deceleration.
MK_EASE_QUINT_INOUTQuintic acceleration then deceleration.
MK_EASE_SINE_INSinusoidal acceleration.
MK_EASE_SINE_OUTSinusoidal deceleration.
MK_EASE_SINE_INOUTSinusoidal acceleration then deceleration.
MK_EASE_EXPO_INExponential acceleration.
MK_EASE_EXPO_OUTExponential deceleration.
MK_EASE_EXPO_INOUTExponential acceleration then deceleration.
MK_EASE_CIRC_INCircular acceleration.
MK_EASE_CIRC_OUTCircular deceleration.
MK_EASE_CIRC_INOUTCircular acceleration then deceleration.
MK_EASE_BACK_INBacktracking acceleration with overshoot.
MK_EASE_BACK_OUTBacktracking deceleration with overshoot.
MK_EASE_BACK_INOUTBacktracking acceleration and deceleration.
MK_EASE_ELASTIC_INElastic acceleration with oscillation.
MK_EASE_ELASTIC_OUTElastic deceleration with oscillation.
MK_EASE_ELASTIC_INOUTElastic acceleration and deceleration.
MK_EASE_BOUNCE_INBouncing acceleration.
MK_EASE_BOUNCE_OUTBouncing deceleration.
MK_EASE_BOUNCE_INOUTBouncing acceleration and deceleration.
MK_EASE_COUNTNumber of easing functions.

Typedefs

mk_ease_typetypedef

typedef enum mk_ease_type mk_ease_type

Values for ease type.

Macros

MK_PIdefine

MK_PI

Constant for pi.