Bouncing ball example
const double g = 9.81;
class Ball : ConditionDown {
Integrator v,y;
unsigned count;
void Action() {
Print(
"# Bounce#%u:\n", ++count);
Out();
v = -0.8 * v.Value();
y = 0;
if(count>=20)
}
public:
Ball(double initialposition) :
ConditionDown(y),
v(-g),
y(v, initialposition),
count(0) {}
void Out() {
Print(
"%-9.3f % -9.3g % -9.3g\n",
T.
Value(), y.Value(), v.Value());
}
};
Ball m1(1.0);
Print(
"# Ball --- model of bouncing ball\n");
}