I am a student engaged in mathematical modeling. The mathematical model (which I am currently working on) has particles located on a cylinder. The coordinates of these particles change due to the interaction with each other and the surface. I need to map the movement of these particles step by step. I use the "while" loop to get the coordinates of the particles at each step. Here is the method for calculating the coordinates of the particles:
public static double[][] Interaction (double[][] newСoordinates, double accuracyEnergy, double accuracyK, double h, int pow, double k, double EnergyOld, double EnergyNew, Group group, Cylinder cylinder, Label labelEnergyValue) {
while (k >= accuracyK & EnergyOld > EnergyNew) {
if (EnergyOld - EnergyNew <= accuracyEnergy) {
k = k/2;
}
EnergyOld = EnergyNew;
newСoordinates = NewCoordinatesWhenMinimizing(newСoordinates,h,pow,k);
EnergyNew = TotalSystemEnergy(newСoordinates,h,pow);
labelEnergyValue.setText(String.valueOf(EnergyNew));
ParticleMapping(newСoordinates,group,cylinder,Color.BISQUE);
}
return newСoordinates;
}
public static void ParticleMapping(double[][] array, Group group, Cylinder cylinder, Color color) {
group.getChildren().clear();
group.getChildren().add(cylinder);
for (int i = 0; i < (array[0].length); i++) {
var nub = new Sphere(5);
nub.setMaterial(new PhongMaterial(color));
nub.setTranslateX (array[0][i]*80);
nub.setTranslateY (array[2][i]*80);
nub.setTranslateZ (array[1][i]*80);
group.getChildren().add(nub);
}
The Particle Mapping method should draw particles having new coordinates. I use javafx but I don't use fxml.
I think I should use AnimationTimer or Timeline, but I don't understand how. I will be grateful if you find the time to help me.