forked from kidrigger/N-Body-Simulator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInput.hpp
38 lines (34 loc) · 838 Bytes
/
Input.hpp
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
//
// Input.hpp
// nbody_bh
//
// Created by Anish Bhobe on 8/18/17.
// Copyright © 2017 Anish Bhobe. All rights reserved.
//
#ifndef Input_hpp
#define Input_hpp
#include <iostream>
#include <vector>
#include <array>
#include "Body.hpp"
namespace Celestial {
class NBodySimInput {
public:
std::vector<Body> GetBodyInput() {
int n;
std::cin >> n;
std::vector<Body> bodies(n);
for(int i = 0; i != n; ++i) {
bodies[i].Create(getArrayInput());
}
return bodies;
}
private:
std::array<double,7> getArrayInput() {
double m,x,y,z,vx,vy,vz;
std::cin >> m >> x >> y >> z >> vx >> vy >> vz;
return std::array<double,7>{m,x,y,z,vx,vy,vz};
}
};
}
#endif /* Input_hpp */