Slide 37
Slide 37 text
7.2 PROTON STEPPER
Getters
double physproc TimeStepper getX()
{ return p.position.x; }
Accumulators
std vector x, y, z;
for (int i = 0; i < 1E3; i ) {
ProtonStepper.Step();
if (i % 7 0) {
x.push_back(ProtonStepper.getX());
}
}
py scoped_interpreter guard{};
using namespace py literals;
py dict locals = py dict{
"x"_a = x,
};
py exec(R"(
)",
py globals(), locals);
sha256:59555bc
from mpl_toolkits.mplot3d import Axes3
import matplotlib.pyplot as plt
fig = plt.figure()
ax = fig.add_subplot(111, projection='
ax.scatter(x, y, z, c='r', marker='o')
plt.show()
8 . 4