-
Notifications
You must be signed in to change notification settings - Fork 0
/
trajectory.h
79 lines (51 loc) · 2.19 KB
/
trajectory.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/* Copyright (c) 2017 By the Authors
*
* This file is part of Orbit Simulator.
Orbit Simulator is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Orbit Simulator is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Orbit Simulator. If not, see <http://www.gnu.org/licenses/>.
*
* */
#ifndef ORBIT3D_TRAJECTORY_H
#define ORBIT3D_TRAJECTORY_H
#include "vector3.h"
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <boost/lexical_cast.hpp>
class Trajectory{
long m_n_trajectories;
const std::string m_trajectory_dir = "trajectory/";
const std::string m_vel_dir = m_trajectory_dir + "vel/";
const std::string m_pos_dir = m_trajectory_dir + "pos/";
const std::string m_file_extension = ".csv";
std::vector<std::vector<Vector3>> m_positions;
std::vector<std::vector<Vector3>> m_velocities;
std::vector<std::ofstream> m_pos_ofstreams;
std::vector<std::ofstream> m_vel_ofstreams;
std::vector<std::string> m_names;
public:
void setup(long n_trajectories, std::vector<std::string> names );
void open_ofstreams();
void close_ofstreams();
void set_position(const std::vector<Vector3>& pos, const std::vector<Vector3> &vel);
void clear_coordinates();
void save_to_file();
void read_from_csv(int skip);
std::vector<Vector3> get_trajectory_positions(int body) const;
std::vector<Vector3> get_trajectory_velocities(int body) const;
std::vector<Vector3> get_positions_at_index(int index) const;
std::vector<Vector3> get_velocities_at_index(int index) const;
long get_number_of_rows() const { return m_positions[0].size(); }
long get_number_of_trajectories(){ return m_n_trajectories; }
};
#endif //ORBIT3D_TRAJECTORY_H