java.lang.Object
com.github.stephengold.joltjni.JoltPhysicsObject
com.github.stephengold.joltjni.LinearCurve
- All Implemented Interfaces:
ConstJoltPhysicsObject,ConstLinearCurve,AutoCloseable,Comparable<JoltPhysicsObject>
Linearly interpolate some value Y versus another value X, such as torque
versus RPMs or wheel friction versus slip ratio.
-
Constructor Summary
ConstructorsConstructorDescriptionInstantiate a default curve.LinearCurve(ConstLinearCurve original) Instantiate a copy of the specified curve. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPoint(float x, float y) Add the specified point to the curve.voidclear()Remove all points from the curve.intCount the points in the curve.floatgetMaxX()Return the highest X value.floatgetMinX()Return the lowest X value.floatgetPointX(int pointIndex) Return the X value of the specified point.floatgetPointY(int pointIndex) Return the Y value of the specified point.floatgetValue(float x) Return the Y value for the specified X.voidrestoreBinaryState(StreamIn stream) Read the state of this curve from the specified stream.voidsaveBinaryState(StreamOut stream) Write the curve to the specified stream.voidsort()Sort the points by their X values, in ascending order.Methods inherited from class com.github.stephengold.joltjni.JoltPhysicsObject
close, compareTo, equals, getContainingObject, hasAssignedNativeObject, hashCode, isCleanerStarted, ownsNativeObject, setVirtualAddress, setVirtualAddress, startCleaner, targetVa, toString, vaMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Comparable
compareToMethods inherited from interface com.github.stephengold.joltjni.readonly.ConstJoltPhysicsObject
close, hasAssignedNativeObject, ownsNativeObject, targetVa
-
Constructor Details
-
LinearCurve
public LinearCurve()Instantiate a default curve. -
LinearCurve
Instantiate a copy of the specified curve.- Parameters:
original- the curve to copy (notnull, unaffected)
-
-
Method Details
-
addPoint
public void addPoint(float x, float y) Add the specified point to the curve.- Parameters:
x- the input (X) coordinatey- the output (Y) coordinate
-
clear
public void clear()Remove all points from the curve. -
restoreBinaryState
Read the state of this curve from the specified stream.- Parameters:
stream- where to read from (notnull)
-
sort
public void sort()Sort the points by their X values, in ascending order. -
countPoints
public int countPoints()Count the points in the curve. The curve is unaffected.- Specified by:
countPointsin interfaceConstLinearCurve- Returns:
- the count (≥0)
-
getMaxX
public float getMaxX()Return the highest X value. The curve is unaffected.- Specified by:
getMaxXin interfaceConstLinearCurve- Returns:
- the highest X value
-
getMinX
public float getMinX()Return the lowest X value. The curve is unaffected.- Specified by:
getMinXin interfaceConstLinearCurve- Returns:
- the lowest X value
-
getPointX
public float getPointX(int pointIndex) Return the X value of the specified point. The curve is unaffected.- Specified by:
getPointXin interfaceConstLinearCurve- Parameters:
pointIndex- the index of the point (≥0)- Returns:
- the point's X value
-
getPointY
public float getPointY(int pointIndex) Return the Y value of the specified point. The curve is unaffected.- Specified by:
getPointYin interfaceConstLinearCurve- Parameters:
pointIndex- the index of the point (≥0)- Returns:
- the point's Y value
-
getValue
public float getValue(float x) Return the Y value for the specified X. The curve is unaffected.- Specified by:
getValuein interfaceConstLinearCurve- Parameters:
x- the input X value- Returns:
- the interpolated Y value
-
saveBinaryState
Write the curve to the specified stream. The curve is unaffected.- Specified by:
saveBinaryStatein interfaceConstLinearCurve- Parameters:
stream- where to write objects (notnull)
-