-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbodies.cpp
54 lines (44 loc) · 831 Bytes
/
bodies.cpp
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
#include <iostream>
#include <math.h>
#include <fstream>
#include "vect.h"
#include "consts.h"
#include "kepcart.h"
#include "bodies.h"
#include "galaxy.h"
extern int elements;
Body **GetMassiveBodies(Body **B)
{
int bodyCount = GetMassiveBodyCount(B);
Body **massiveBodies = new Body *[bodyCount];
bodyCount = 0;
for (int i = 0; i < elements; i++)
{
if (B[i]->IsMassive())
{
massiveBodies[bodyCount++] = B[i];
}
}
return massiveBodies;
}
int GetMassiveBodyCount(Body **B)
{
int bodyCount = 0;
Body *MassiveBodies;
for (int i = 0; i < elements; i++)
{
if (B[i]->IsMassive())
bodyCount++;
}
return bodyCount;
}
ostream &operator<<(ostream &O, Body &B)
{
O << B.r << "\t" << B.parent;
return O;
}
ostream &operator<<(ostream &O, Vect &B)
{
O << B.x << "\t" << B.y << "\t" << B.z;
return O;
}