public void save_state(directional_vector final_state) { string save_double = ""; save_double += final_state.vector.a.ToString() + ";"; save_double += final_state.vector.b.ToString() + ";"; //this.n.real_fraction_value(final_state.vector.b, "10")+";"; save_double += final_state.direction + ";"; //this.n.real_fraction_value(final_state.direction, "10")+";"; foreach (cylinder c in this.cylinders) { save_double += c.phase_offset + ";"; } try { using (StreamWriter sw = new StreamWriter(this.state_file_path, false)) { sw.WriteLine(save_double); sw.Close(); } } catch (Exception e) { Console.WriteLine("The file could not be read:"); Console.WriteLine(e.Message); } }
public directional_vector run_simulation(int index, vector particle_position = null, double?particle_direction = null) { if (index < this.cylinders.Count) { if (particle_position != null) { this.cylinders[index].particle_position = particle_position; } if (particle_direction != null) { this.cylinders[index].particle_direction = Convert.ToDouble(particle_direction); } directional_vector result = this.cylinders[index].calculate_translation(); return(this.run_simulation(++index, result.vector, result.direction)); } this.cylinders[0].particle_position = particle_position; this.cylinders[0].particle_direction = Convert.ToDouble(particle_direction); //Console.WriteLine(particle_position); //Console.WriteLine(particle_direction); return(new directional_vector(particle_position, Convert.ToDouble(particle_direction))); }