Class SpringParams
- All Implemented Interfaces:
Proxy
SpringAnimation.
Any spring can be described by three parameters: mass, stiffness and damping.
An undamped spring will produce an oscillatory motion which will go on forever.
The frequency and amplitude of the oscillations will be determined by the stiffness (how "strong" the spring is) and its mass (how much "inertia" it has).
If damping is larger than 0, the amplitude of that oscillating motion will exponientally decrease over time. If that damping is strong enough that the spring can't complete a full oscillation, it's called an overdamped spring.
If we the spring can oscillate, it's called an underdamped spring.
The value between these two behaviors is called critical damping; a critically damped spring will comes to rest in the minimum possible time without producing oscillations.
The damping can be replaced by damping ratio, which produces the following springs:
- 0: an undamped spring.
- Between 0 and 1: an underdamped spring.
- 1: a critically damped spring.
- Larger than 1: an overdamped spring.
As such
-
Constructor Summary
ConstructorsConstructorDescriptionSpringParams(double dampingRatio, double mass, double stiffness) Creates a newAdwSpringParamsfrommass,stiffnessanddampingRatio.SpringParams(MemorySegment address) Create a SpringParams proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionstatic SpringParamsfull(double damping, double mass, double stiffness) Creates a newAdwSpringParamsfrommass,stiffnessanddamping.doubleGets the damping ofself.doubleGets the damping ratio ofself.doublegetMass()Gets the mass ofself.doubleGets the stiffness ofself.static @Nullable TypegetType()Get the GType of the SpringParams classref()Increases the reference count ofself.voidunref()Decreases the reference count ofself.Methods inherited from class org.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
SpringParams
Create a SpringParams proxy instance for the provided memory address.- Parameters:
address- the memory address of the native object
-
SpringParams
public SpringParams(double dampingRatio, double mass, double stiffness) Creates a newAdwSpringParamsfrommass,stiffnessanddampingRatio.The damping value is calculated from
dampingRatioand the other two parameters.- If
dampingRatiois 0, the spring will not be damped and will oscillate endlessly. - If
dampingRatiois between 0 and 1, the spring is underdamped and will always overshoot. - If
dampingRatiois 1, the spring is critically damped and will reach its resting position the quickest way possible. - If
dampingRatiois larger than 1, the spring is overdamped and will reach its resting position faster than it can complete an oscillation.
full(double, double, double)allows to pass a raw damping value instead.- Parameters:
dampingRatio- the damping ratio of the springmass- the mass of the springstiffness- the stiffness of the spring
- If
-
-
Method Details
-
getType
-
full
Creates a newAdwSpringParamsfrommass,stiffnessanddamping.See
SpringParams(double, double, double)for a simplified constructor using damping ratio instead ofdamping.- Parameters:
damping- the damping of the springmass- the mass of the springstiffness- the stiffness of the spring- Returns:
- the newly created spring parameters
-
getDamping
public double getDamping()Gets the damping ofself.- Returns:
- the damping
-
getDampingRatio
public double getDampingRatio()Gets the damping ratio ofself.- Returns:
- the damping ratio
-
getMass
public double getMass()Gets the mass ofself.- Returns:
- the mass
-
getStiffness
public double getStiffness()Gets the stiffness ofself.- Returns:
- the stiffness
-
ref
-
unref
public void unref()Decreases the reference count ofself.If the last reference is dropped, the structure is freed.
-