Contents
- Description
- Field Summary
- Constructor Summary
- Method Summary
- Field Details
- Constructor Details
- Method Details
- fromNormalized(double, double, double)
- fromNormalized(double, double, double, double)
- forSlowEndSpeedRatio(double, double, double, double)
- maxSeamSlope(double)
- maxInitialSlope(double)
- maxFinalSlope(double)
- defaultSeamSlope(double)
- defaultNormalizedSeamSlope(double)
- defaultNormalizedFinalSlope()
- value(double)
- valueFrom(double, double)
- derivative(double)
- inverse(double)
- inverse(double, double)
- integral(double)
- normalizedIntegral(double)
- normalizedIntegralFrom(double, double)
- peakDerivative()
- slowEndSpeedRatio()
- totalIntegral()
- meanValueFrom(double)
Class BiasedEasing
java.lang.Object
com.hypixel.hytale.server.npc.util.BiasedEasing
Strictly monotonic C² function on [0, 1] with
f(0) = 0, f(1) = 1, f'(0) = k, f'(1) = e, f(0.5) = t
Seam at x = 0.5 with slope s = f'(0.5) and zero second derivative there.
Raw parameter bounds (monotonicity):
0 invalid input: '<'= s invalid input: '<'= maxSeamSlope(t) = 4 * min(t, 1 - t)
0 invalid input: '<'= k invalid input: '<'= maxInitialSlope(t) = 4 * t
0 invalid input: '<'= e invalid input: '<'= maxFinalSlope(t) = 4 * (1 - t)
fromNormalized(t, sNorm, kNorm, eNorm) maps the unit cube onto the full valid
box, so every normalized input tuple is legal.
Read as a velocity profile, f is the relative speed and the endpoint slopes are
accelerations. Read as a position profile, f is the fraction of the distance
covered and the endpoint slopes are the speeds there, which is why e has to be
settable: a ramp that ends at full speed cannot have f'(1) = 0.
Also provides the closed-form antiderivative F(x) = ∫₀ˣ f, and a version
rescaled so that it reaches exactly 1 at x = 1.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final doubleHow close to the true rootinverse(double)narrows before returning. -
Constructor Summary
ConstructorsConstructorDescriptionBiasedEasing(double t) Recommended: s = 4t(1-t), k = 0, e = 0.BiasedEasing(double t, double s) Explicit seam slope, zero endpoint slopes.BiasedEasing(double t, double s, double k) Explicit seam and initial slope, zero final slope.BiasedEasing(double t, double s, double k, double e) Fully explicit (raw units). -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleReturns the legal upper bound for the normalized final slope.static doubledefaultNormalizedSeamSlope(double t) Normalized seam slope that reproduces the harmonic-mean default.static doubledefaultSeamSlope(double t) The recommended default seam slope: harmonic mean of the chord slopes.doublederivative(double x) Evaluates f'(x).static BiasedEasingforSlowEndSpeedRatio(double t, double sNorm, double eNorm, double slowEndSpeedRatio) Builds a position profile whose initial speed isslowEndSpeedRatioof its peak speed.static BiasedEasingfromNormalized(double t, double sNorm, double kNorm) Maps normalized seam and initial slopes linearly onto their valid bounds.static BiasedEasingfromNormalized(double t, double sNorm, double kNorm, double eNorm) AsfromNormalized(double, double, double), with eNorm mapped onto [0, eMax(t)].doubleintegral(double x) Antiderivative F(x) = ∫₀ˣ f(ξ) dξ, consistent with the clamped value(): constant 0 below x = 0, growing with slope 1 above x = 1.doubleinverse(double y) Solves f(x) = y to withinDEFAULT_INVERSE_TOLERANCE.doubleinverse(double y, double tolerance) Solves f(x) = y on [0, 1] by bisection.static doublemaxFinalSlope(double t) Largest final slope keeping the curve monotone for this t.static doublemaxInitialSlope(double t) Largest initial slope keeping the curve monotone for this t.static doublemaxSeamSlope(double t) Largest seam slope keeping the curve monotone for this t.doublemeanValueFrom(double offset) Returns the mean of f over [offset, 1].doublenormalizedIntegral(double x) Returns the integral normalized to 1 at x = 1.doublenormalizedIntegralFrom(double offset, double progress) Returns the fraction accumulated over avalueFrom(double, double)sweep.doubleSteepest slope anywhere on [0, 1].doublef'(0) as a fraction ofpeakDerivative(), so 0 when the curve starts flat.doubleTotal integral ∫₀¹ f(ξ) dξ = F(1).doublevalue(double x) Evaluates f(x), clamped outside [0, 1].doublevalueFrom(double offset, double progress) Evaluates the curve over [offset, 1].
-
Field Details
-
DEFAULT_INVERSE_TOLERANCE
public static final double DEFAULT_INVERSE_TOLERANCEHow close to the true rootinverse(double)narrows before returning.- See Also:
-
-
Constructor Details
-
BiasedEasing
public BiasedEasing(double t) Recommended: s = 4t(1-t), k = 0, e = 0. Valid for every t in (0, 1). -
BiasedEasing
public BiasedEasing(double t, double s) Explicit seam slope, zero endpoint slopes. -
BiasedEasing
public BiasedEasing(double t, double s, double k) Explicit seam and initial slope, zero final slope. -
BiasedEasing
public BiasedEasing(double t, double s, double k, double e) Fully explicit (raw units). Clamps t into (0, 1) and each slope against its t-dependent bound.
-
-
Method Details
-
fromNormalized
Maps normalized seam and initial slopes linearly onto their valid bounds. -
fromNormalized
@Nonnull public static BiasedEasing fromNormalized(double t, double sNorm, double kNorm, double eNorm) AsfromNormalized(double, double, double), with eNorm mapped onto [0, eMax(t)]. -
forSlowEndSpeedRatio
@Nonnull public static BiasedEasing forSlowEndSpeedRatio(double t, double sNorm, double eNorm, double slowEndSpeedRatio) Builds a position profile whose initial speed isslowEndSpeedRatioof its peak speed. Uses bisection because the peak depends on the initial slope. An unreachable ratio uses the steepest legal initial slope. -
maxSeamSlope
public static double maxSeamSlope(double t) Largest seam slope keeping the curve monotone for this t. -
maxInitialSlope
public static double maxInitialSlope(double t) Largest initial slope keeping the curve monotone for this t. -
maxFinalSlope
public static double maxFinalSlope(double t) Largest final slope keeping the curve monotone for this t. -
defaultSeamSlope
public static double defaultSeamSlope(double t) The recommended default seam slope: harmonic mean of the chord slopes. -
defaultNormalizedSeamSlope
public static double defaultNormalizedSeamSlope(double t) Normalized seam slope that reproduces the harmonic-mean default. -
defaultNormalizedFinalSlope
public static double defaultNormalizedFinalSlope()Returns the legal upper bound for the normalized final slope. Position-profile ramps use it for a full-speed handover at the fast end. -
value
public double value(double x) Evaluates f(x), clamped outside [0, 1]. -
valueFrom
public double valueFrom(double offset, double progress) Evaluates the curve over [offset, 1]. Maps progress from [0, 1] onto that range. -
derivative
public double derivative(double x) Evaluates f'(x). Returns k at 0 and e at 1. Constant outside [0, 1]. -
inverse
public double inverse(double y) Solves f(x) = y to withinDEFAULT_INVERSE_TOLERANCE. -
inverse
public double inverse(double y, double tolerance) Solves f(x) = y on [0, 1] by bisection. Strict monotonicity makes the root unique and bounds its value error by4 * tolerance. -
integral
public double integral(double x) Antiderivative F(x) = ∫₀ˣ f(ξ) dξ, consistent with the clamped value(): constant 0 below x = 0, growing with slope 1 above x = 1. F is C³ across the seam. F(1) = totalIntegral(). -
normalizedIntegral
public double normalizedIntegral(double x) Returns the integral normalized to 1 at x = 1. For a velocity profile, this is normalized displacement. Its endpoint slopes are f(x) / F(1). -
normalizedIntegralFrom
public double normalizedIntegralFrom(double offset, double progress) Returns the fraction accumulated over avalueFrom(double, double)sweep. For a velocity profile, this is its position profile. A degenerate span returnsprogress. -
peakDerivative
public double peakDerivative()Steepest slope anywhere on [0, 1]. -
slowEndSpeedRatio
public double slowEndSpeedRatio()f'(0) as a fraction ofpeakDerivative(), so 0 when the curve starts flat. -
totalIntegral
public double totalIntegral()Total integral ∫₀¹ f(ξ) dξ = F(1). -
meanValueFrom
public double meanValueFrom(double offset) Returns the mean of f over [offset, 1]. For a velocity profile, distance divided by this mean gives duration. A degenerate span returns f(1) = 1.
-