Skip to content

Commit c46edd6

Browse files
Update to Google Style
1 parent 041790b commit c46edd6

1 file changed

Lines changed: 28 additions & 31 deletions

File tree

src/struct/particle.h

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,56 +2,53 @@
22
// it under the terms of the GNU General Public License as published by
33
// the Free Software Foundation, either version 3 of the License, or
44
// (at your option) any later version.
5-
65
// This program is distributed in the hope that it will be useful,
76
// but WITHOUT ANY WARRANTY; without even the implied warranty of
87
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
98
// GNU General Public License for more details.
10-
119
// You should have received a copy of the GNU General Public License
1210
// along with this program. If not, see <http://www.gnu.org/licenses/>.
1311

1412
#pragma once
15-
#include <cmath>
16-
#include "floatdef.h"
1713
#include "dt/softening.h"
14+
#include "floatdef.h"
15+
#include <cmath>
1816

1917
struct alignas(32) Particle {
20-
real x, y, z;
21-
real vx, vy, vz;
22-
real m;
23-
int type;
18+
real x, y, z;
19+
real vx, vy, vz;
20+
real m;
21+
int type;
2422
};
2523

26-
inline void Gravity(Particle& a, Particle& b, real dt)
27-
{
28-
constexpr real G = real(1.0);
24+
inline void Gravity(Particle &a, Particle &b, real dt) {
25+
constexpr real G = real(1.0);
2926

30-
real eps = pairSoftening(a.m, b.m);
27+
real eps = pairSoftening(a.m, b.m);
3128

32-
real dx = b.x - a.x;
33-
real dy = b.y - a.y;
34-
real dz = b.z - a.z;
29+
real dx = b.x - a.x;
30+
real dy = b.y - a.y;
31+
real dz = b.z - a.z;
3532

36-
real r2 = dx*dx + dy*dy + dz*dz + eps*eps;
33+
real r2 = dx * dx + dy * dy + dz * dz + eps * eps;
3734

38-
real invR2 = real(1.0) / r2;
39-
real invR = std::sqrt(invR2);
40-
real invR3 = invR * invR2;
35+
real invR2 = real(1.0) / r2;
36+
real invR = std::sqrt(invR2);
37+
real invR3 = invR * invR2;
4138

42-
real ax = G * b.m * dx * invR3;
43-
real ay = G * b.m * dy * invR3;
44-
real az = G * b.m * dz * invR3;
39+
real ax = G * b.m * dx * invR3;
40+
real ay = G * b.m * dy * invR3;
41+
real az = G * b.m * dz * invR3;
4542

46-
real bx = -G * a.m * dx * invR3;
47-
real by = -G * a.m * dy * invR3;
48-
real bz = -G * a.m * dz * invR3;
43+
real bx = -G * a.m * dx * invR3;
44+
real by = -G * a.m * dy * invR3;
45+
real bz = -G * a.m * dz * invR3;
4946

50-
a.vx += ax * dt;
51-
a.vy += ay * dt;
52-
a.vz += az * dt;
47+
a.vx += ax * dt;
48+
a.vy += ay * dt;
49+
a.vz += az * dt;
5350

54-
b.vx += bx * dt;
55-
b.vy += by * dt;
56-
b.vz += bz * dt;
51+
b.vx += bx * dt;
52+
b.vy += by * dt;
53+
b.vz += bz * dt;
5754
}

0 commit comments

Comments
 (0)