Record Class SigmoidScalingFunction
java.lang.Object
java.lang.Record
johnsmith.enchantmentcore.api.enchantment.spellfield.math.function.SigmoidScalingFunction
- Record Components:
steepness- The logistic growth/decay rate k controlling how sharply the transition occurs.midpointRatio- The fraction m ofmaxRadiusat which the multiplier crosses 0.5 (50% intensity).
- All Implemented Interfaces:
DistanceScalingFunction
public record SigmoidScalingFunction(float steepness, float midpointRatio)
extends Record
implements DistanceScalingFunction
A
f(d, R) = 1 / (1 + ek · (d - m · R))
where k is
DistanceScalingFunction that attenuates effect intensity along a logistic S-curve:
f(d, R) = 1 / (1 + ek · (d - m · R))
where k is
steepness() and m is midpointRatio().-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final com.mojang.serialization.MapCodec<SigmoidScalingFunction> MapCodec for serializing and deserializingSigmoidScalingFunctioninstances from JSON.static final StringRegistry path identifier for this distance scaling function.static final StringJSON field key for the normalized inflection midpoint ratio $m$.static final StringJSON field key for the logistic steepness $k$. -
Constructor Summary
ConstructorsConstructorDescriptionSigmoidScalingFunction(float steepness, float midpointRatio) Creates an instance of aSigmoidScalingFunctionrecord class. -
Method Summary
Modifier and TypeMethodDescriptionfloatapply(float distance, float maxRadius) Evaluates the distance scaling function at the given distance relative tomaxRadius.com.mojang.serialization.MapCodec<? extends DistanceScalingFunction> codec()Retrieves theMapCodecresponsible for serializing and deserializing this function type.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.floatReturns the value of themidpointRatiorecord component.floatReturns the value of thesteepnessrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
STEEPNESS
JSON field key for the logistic steepness $k$.- See Also:
-
MIDPOINT_RATIO
JSON field key for the normalized inflection midpoint ratio $m$.- See Also:
-
KEY
Registry path identifier for this distance scaling function.- See Also:
-
CODEC
MapCodec for serializing and deserializingSigmoidScalingFunctioninstances from JSON.
-
-
Constructor Details
-
SigmoidScalingFunction
public SigmoidScalingFunction(float steepness, float midpointRatio) Creates an instance of aSigmoidScalingFunctionrecord class.- Parameters:
steepness- the value for thesteepnessrecord componentmidpointRatio- the value for themidpointRatiorecord component
-
-
Method Details
-
apply
public float apply(float distance, float maxRadius) Description copied from interface:DistanceScalingFunctionEvaluates the distance scaling function at the given distance relative tomaxRadius.- Specified by:
applyin interfaceDistanceScalingFunction- Parameters:
distance- The measured distance from the spatial origin or reference axis.maxRadius- The maximum operational radius of the topological component.- Returns:
- The calculated intensity multiplier scalar (typically bounded in $[0.0, 1.0]$).
-
codec
Description copied from interface:DistanceScalingFunctionRetrieves theMapCodecresponsible for serializing and deserializing this function type.- Specified by:
codecin interfaceDistanceScalingFunction- Returns:
- The registered
MapCodecinstance.
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='. -
steepness
public float steepness()Returns the value of thesteepnessrecord component.- Returns:
- the value of the
steepnessrecord component
-
midpointRatio
public float midpointRatio()Returns the value of themidpointRatiorecord component.- Returns:
- the value of the
midpointRatiorecord component
-