The multiplicative distance change between two phases.
The oscillation is defined in LOG distance — d(φ) = d₀·exp(−A·sin φ) with
A = ln(1 + amplitude) — which is what makes it the sinusoidal mousewheel
the feature is named for: the wheel scales distance by a constant factor per
click, so equal-sized swings in and out are equal in RATIO, not in scene
units. An amplitude of 0.15 therefore reaches d₀×1.15 at its far point
and d₀÷1.15 at its near one, on any scene at any scale. The minus sign
makes a rising phase move the camera CLOSER, so switching the feature on
begins with an approach.
Returning the RATIO between two phases rather than an absolute distance is
what lets the user keep zooming while this runs. Distance is only ever
multiplied — by the wheel, and by this — and multiplication commutes, so a
wheel click mid-oscillation just moves the centre the camera is breathing
around, exactly as it would if the motion were not running. Nothing has to
arbitrate between the two, and no baseline has to be tracked and re-derived.
Taking the difference of two sines (rather than integrating the derivative
−A·cos φ · dφ) is also what keeps it exact: the amplitude is right whatever
the frame rate, and the factors over one full period telescope to exactly 1,
so the centre cannot drift over a long session.
Parameters
fromPhase: number
Phase at the previous sample, radians.
toPhase: number
Phase now, radians.
amplitude: number
Peak swing as a fraction of distance (0.15 = ±15%).
Non-finite, zero, or negative is inert.
Returns number
The factor to multiply the orbit distance by (1 = no change).
The multiplicative distance change between two phases.
The oscillation is defined in LOG distance —
d(φ) = d₀·exp(−A·sin φ)withA = ln(1 + amplitude)— which is what makes it the sinusoidal mousewheel the feature is named for: the wheel scales distance by a constant factor per click, so equal-sized swings in and out are equal in RATIO, not in scene units. Anamplitudeof 0.15 therefore reachesd₀×1.15at its far point andd₀÷1.15at its near one, on any scene at any scale. The minus sign makes a rising phase move the camera CLOSER, so switching the feature on begins with an approach.Returning the RATIO between two phases rather than an absolute distance is what lets the user keep zooming while this runs. Distance is only ever multiplied — by the wheel, and by this — and multiplication commutes, so a wheel click mid-oscillation just moves the centre the camera is breathing around, exactly as it would if the motion were not running. Nothing has to arbitrate between the two, and no baseline has to be tracked and re-derived.
Taking the difference of two sines (rather than integrating the derivative
−A·cos φ · dφ) is also what keeps it exact: the amplitude is right whatever the frame rate, and the factors over one full period telescope to exactly 1, so the centre cannot drift over a long session.