Greetings,
I don’t know what to do to solve this. If anyone know what’s the problem, tell it to me in words. I am not learning if someone is pasting codes ^w^!
Tick
for (int i = 0; i < entities.size(); i++){
if(entities.get(i) != sun){
for (int j = 0; j < entities.size(); j++){
if (i != j){
double dist = Math.sqrt(Math.exp(entities.get(i).getX() - entities.get(j).getX()) + Math.exp(entities.get(i).getY() - entities.get(j).getY()));
double accMag = entities.get(j).getMass()/(Math.exp(dist));
double accX = accMag*(entities.get(j).getX() - entities.get(j).getY())/dist;
double accY = accMag*(entities.get(j).getY() - entities.get(j).getY())/dist;
entities.get(i).addVX(accX);
entities.get(i).addVY(accY);
System.out.println("dist: " + dist + ", accMag: " + accMag + ", accX: " + accX + ", accY: " + accY);
}
}
entities.get(i).updatePosition();
System.out.println("New postition of Planet [x=" + entities.get(i).getX() + ", y=" + entities.get(i).getY() + "]");
}
}
System.out.println()
dist: Infinity, accMag: 0.0, accX: 0.0, accY: 0.0
New postition of Kerbin [x=80000.0, y=0.0]
Well the problem is basically as you can see, that dist is becomming Infinity, and because of this, the other variables are 0
-RoseSlayer