Use single HermiteInterpolator for position

This commit is contained in:
Moulberry committed 2025-02-11 18:18:26 +08:00
1 parent f947480196
commit c0f66ad93d
1 file changed
+7 -15
@@ -9,27 +9,19 @@ import java.util.Map;
public class Hermite {
public static Vector3d position(Map<Integer, Vector3d> map, float amount) {
HermiteInterpolator hermiteInterpolatorX = new HermiteInterpolator();
HermiteInterpolator hermiteInterpolatorY = new HermiteInterpolator();
HermiteInterpolator hermiteInterpolatorZ = new HermiteInterpolator();
HermiteInterpolator hermiteInterpolator = new HermiteInterpolator();
double[] array = new double[1];
double[] array = new double[3];
for (Map.Entry<Integer, Vector3d> entry : map.entrySet()) {
array[0] = entry.getValue().x;
hermiteInterpolatorX.addSamplePoint(entry.getKey(), array);
array[1] = entry.getValue().y;
array[2] = entry.getValue().z;
array[0] = entry.getValue().y;
hermiteInterpolatorY.addSamplePoint(entry.getKey(), array);
array[0] = entry.getValue().z;
hermiteInterpolatorZ.addSamplePoint(entry.getKey(), array);
hermiteInterpolator.addSamplePoint(entry.getKey(), array);
}
return new Vector3d(
hermiteInterpolatorX.value(amount)[0],
hermiteInterpolatorY.value(amount)[0],
hermiteInterpolatorZ.value(amount)[0]
);
var values = hermiteInterpolator.value(amount);
return new Vector3d(values[0], values[1], values[2]);
}
public static double value(Map<Integer, Double> map, float amount) {