0

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.

Darina
  • 1
  • 3
    Basic [physics simulation](https://gist.github.com/james-d/8327842) using an AnimationTimer. – jewelsea Aug 06 '23 at 16:32
  • 1
    This related [example](https://stackoverflow.com/a/31761362/230513) manages a queue of non-interacting particles and cites a fireworks simulation. – trashgod Aug 07 '23 at 11:55

0 Answers0