protected void updateZ(Moon first, Moon second) { if (first.pos.z < second.pos.z) { first.vel.z += 1; second.vel.z -= 1; } else if (first.pos.z > second.pos.z) { first.vel.z -= 1; second.vel.z += 1; } }
protected void updateY(Moon first, Moon second) { if (first.pos.y < second.pos.y) { first.vel.y += 1; second.vel.y -= 1; } else if (first.pos.y > second.pos.y) { first.vel.y -= 1; second.vel.y += 1; } }
protected void updateX(Moon first, Moon second) { if (first.pos.x < second.pos.x) { first.vel.x += 1; second.vel.x -= 1; } else if (first.pos.x > second.pos.x) { first.vel.x -= 1; second.vel.x += 1; } }
private int energy(Moon moon) { var potential = System.Math.Abs(moon.pos.x) + System.Math.Abs(moon.pos.y) + System.Math.Abs(moon.pos.z); var kinetic = System.Math.Abs(moon.vel.x) + System.Math.Abs(moon.vel.y) + System.Math.Abs(moon.vel.z); return(potential * kinetic); }
public Moon(Moon copy) { pos = new Point3d(copy.pos.x, copy.pos.y, copy.pos.z); vel = new Point3d(copy.vel.x, copy.vel.y, copy.vel.z); }