-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCOG.cpp
More file actions
60 lines (51 loc) · 974 Bytes
/
COG.cpp
File metadata and controls
60 lines (51 loc) · 974 Bytes
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
#include "COG.h"
void COG::init()
{
numParticles = 0;
}
void COG::updateCenter()
{
Vec3 acc;
acc.x = 0;
acc.y = 0;
acc.z = 0;
for (int i = 0; i < numParticles; i++)
{
acc.x += particles[i] -> position.x;
acc.y += particles[i] -> position.y;
acc.z += particles[i] -> position.z;
}
acc.x = acc.x / particles.size();
acc.y = acc.y / particles.size();
acc.z = acc.z / particles.size();
center = acc;
}
void COG::addParticle(Particle *p)
{
if(particles.size() <= 0)
{
particles.resize(100);
}
else if(particles[particles.size() - 1] != 0L) // Check if null
{
particles.resize(particles.size() * 2);
}
particles[numParticles] = p;
numParticles++;
}
/*void COG::rotateCOG(Vec3 rotation)
{
//TODO: Etan
}
void COG::translateCOG(Vec3 translation)
{
//TODO: Etan
}
int COG::getSize()
{
return numParticles;
}
double COG::getMass()
{
//TODO: Etan
}*/