API Reference · Math utilities

Ease

Namespace: Ava3D

public static class Ease

Shaping a 0..1 parameter, so a move starts and stops instead of switching on and off.

A camera that reaches its mark at the same speed it left is a camera on rails. What the eye reads as deliberate is a move that leans into its start and settles at its end, and that is entirely a matter of what number gets handed to the interpolation — not of the interpolation itself. So there is nothing here that interpolates: float.Lerp and Vector3.Lerp already exist and this reshapes what they are given.

var t = Ease.InOut(elapsed / duration);
camera.LookFrom(Vector3.Lerp(from, to, t), target);

Four functions, and the model closes at four. Ease.Ramp turns a measurement into a 0..1 parameter; Ease.In, Ease.Out and Ease.InOut decide which end of that parameter is soft. The usual libraries carry thirty of these — quad, cubic, quart, expo, elastic, back, bounce, each in three flavours — and the honest reading of that list is that it is a menu of polynomials rather than a set of ideas. The idea is which end has zero slope, and there are only three answers.

Methods

MemberDescription
static float In(float t)

Soft start, hard stop: away from rest and still accelerating when it arrives. A thing falling, a shot leaving, a cut that wants to feel like an interruption.

static float InOut(float t)

Soft at both ends — smoothstep, the same curve GLSL and HLSL have as a built-in.

This is the default and it is what most moves want. Zero slope at 0 and at 1 means two of these laid end to end join without a kink, which is what lets a sequence of shots run together as one move rather than as a list of them.

static float Out(float t)

Hard start, soft stop: already moving when it begins and settling as it lands. This is the one for a shot that cuts in on a move already under way, and for anything decaying.

static float Ramp(float from, float to, float value)

Where value falls between from and to, as 0..1, clamped at both ends.

The inverse of float.Lerp, which the framework ships and this does not — the map from a range onto 0..1 is the half everybody writes out by hand, usually as Math.Clamp((x - a) / (b - a), 0, 1), and usually more than once in the same file.

Composed with Ease.InOut it is exactly the three-argument smoothstep(edge0, edge1, x) of the shading languages, which is why that is not a fifth function here: Ease.InOut(Ease.Ramp(0.4f, 0.6f, x)).

See also