that actually doesn’t solve the issue[quote=“Rafsing, post:1, topic:26411”] circles.get(i).point.add(circles.get(i - 1).point);
if starting i == 0, then i - 1 used in the .get(i-1 or -1) returns out of bounds
Simulating a nth degree pendulum is not trivial. Is a chain of masses connected that depend on each other to move. I tried your code with one simple pendulum and the problem is also happening on that simple pendulum as well.
So, my first advice would be to break the problem into smaller steps and build from there. Try first to implement a simple pendulum. Then, move to a double pendulum. The double pendulum equations can be found here:
Daniel Shiffman has implemented a double pendulum, which you can find here if it helps you
Once you have understood the equations of motion you can generalize to nth degrees.
I am not sure if I have the proper time to check your code or implement what I have said above, but I believe that it would be a good exercise for you as well
This kind of relations are also followed in kinematic equations for robotic arms
I will have to take a look into it and check equations. It might take a couple of days but I will let you know if I get something. I know it is not trivial and I am not sure if possible to nth degrees because of the increasing complexity. Meanwhile, maybe try a third one
After some research, I found that as you increase the number of pendulums on the system, the complexity of the equations also increases, and is non-trivial to deduct all the equations. I you have to calculate the position of each arm and derive to get the velocity and acceleration. The system becomes chaotic and trying to brute force the equations isn’t the proper way to go.
However, I found the following blog (the problem is the code being in python):
There is a method called Kane’s method for dynamic motion
Which allows doing all calculations in the back. I haven’t found this same method for java but I don’t have much time either right now to look into this.
I just wanted to update you and point you in some direction that might be hopeful to you.
Hi, if you want more precision, you could slow down the time. To slow down by, let’s say 10, just lower all the forces by factor 10. To lower all the forces by factor 10, just divide gravity by 10. It is the same effect as if you make 10 times smaller timesteps. You now have scaled time. If you want to try out, do this with one of your working simpler pendulums. This method works in all simulation systems.