import java.lang.Math;
public class Euler {
public static void main(String[] args) {
//data needed
int n = 3; //the 3 circles thingys
float mass[] = null;
float t = 0;
float delta_t = 0;
Vector3D cur_S[] = null;
Vector3D prior_S[] = null;
Vector3D s_derives[] = null;
Vector3D initialV[] = null;//Initial velocity
Vector3D initialP[] = null;//initial position
Vector3D postionC[] = null; //current position of object
boolean gameOn = true; //keep game sim going
//set current state to initial conditions
for(int i = 0; i < n; i++){
mass[i] = 50;
cur_S[2*i] = initialV[i];
cur_S[2*i+1] = initialP[i];
}
while(gameOn == true){
physicSim(delta_t, null, null, null, n, n, postionC);
for (int i = 0; i < n; i ++){
postionC[i] = cur_S[2*i +1];
}
}
//do physic method
ExplicitEuler(2*n, cur_S, prior_S, s_derives, delta_t, n);
t = t + delta_t;
}
private static void ExplicitEuler(int i, Vector3D[] curS,
Vector3D[] prior_S, Vector3D[] s_derives, float delta_t, int n) {
for(int g =0; g < n; g++){
curS[i] = prior_S[i] + delta_t * s_derives[i];
}
}
private static void physicSim(float delta_t,Vector3D cur_S, Vector3D prior_S, Vector3D s_derives, float mass, int n, Vector3D[] postionC ) {
prior_S = cur_S;
//calculate the state derivative vector
for(int i = 0; i < n; i++){
s_derives[2*i] = CalcForce(i);
s_derives[2*i+1] = prior_S[2*i]/mass;
}
}
}