32const Float_t kBX = 40, kBY = 30, kBZ = 40;
42class Boinger :
public TTimer {
50 std::chrono::steady_clock::time_point fLast{std::chrono::steady_clock::now()};
51 std::chrono::steady_clock::time_point fT0{std::chrono::steady_clock::now()};
54 static constexpr Double_t kGrav = -160;
55 static constexpr Double_t kTilt = 0.30;
56 static constexpr Double_t kSpinRate = 2.4;
71 linear(fX, fVx, kBX - kR);
72 linear(fZ, fVz, kBZ - kR);
99 }
else if (
p < -lim) {
108 int GetSent()
const {
return fSent; }
120 auto now = std::chrono::steady_clock::now();
121 Double_t dt = std::chrono::duration<double>(now - fLast).count();
129 if (fSent % 100 == 0) {
130 Double_t el = std::chrono::duration<double>(now - fT0).count();
131 ::Info(
"boing",
"%d ticks, %.1f/s over %.1f s", fSent, fSent / el, el);
146 Bounce(fX, fVx, kBX - kR);
147 Bounce(fY, fVy, kBY - kR);
148 Bounce(fZ, fVz, kBZ - kR);
150 fSpin += kSpinRate *
h;
166 Double_t e2[3] = { -st * cs, ct * cs, sn };
167 Double_t e3[3] = { st * sn, -ct * sn, cs };
173 t.SetBaseVec(1, kR * e1[0], kR * e1[1], kR * e1[2]);
174 t.SetBaseVec(2, kR * e2[0], kR * e2[1], kR * e2[2]);
175 t.SetBaseVec(3, kR * e3[0], kR * e3[1], kR * e3[2]);
176 t.SetPos(fX, fY, fZ);
177 fBall->SetTransMatrix(t.Array());
191 fBall->RefMainTrans().SetMotion(vel, acc, spin_axis, kSpinRate, TimeToNextBounce());
207 sh.SetBaseVec(1, 0, 0.02 * kR, 0);
208 sh.SetBaseVec(2, s, 0, 0);
209 sh.SetBaseVec(3, 0, 0, s);
213 sh.SetPos(fX, -kBY + 0.02 * kR, fZ);
214 fShadow->SetTransMatrix(sh.Array());
221void boing(
Long_t period_ms = 40)
223 auto eveMng = REveManager::Create();
224 eveMng->AllowMultipleRemoteConnections(
false,
false);
227 auto viewer = eveMng->GetDefaultViewer();
228 viewer->SetAxesType(REveViewer::kAxesEdge);
230 viewer->SetAxesUpAxis(1);
233 viewer->SetAxesBBox(-kBX, -kBY, -kBZ, kBX, kBY, kBZ);
235 auto scene = eveMng->GetEventScene();
240 ball->SetTexture(
"checker_8.png");
241 ball->SetMainColor(
kWhite);
242 ball->SetPickable(
kTRUE);
246 scene->AddElement(ball);
249 shadow->SetTLevel(6);
250 shadow->SetPLevel(32);
251 shadow->SetThetaMax(0.5);
252 shadow->SetMainColor(
kBlack);
255 shadow->SetMainTransparency(20);
256 shadow->SetPickable(
kFALSE);
257 scene->AddElement(shadow);
261 (
new Boinger(ball, shadow, period_ms))->TurnOn();
bool Bool_t
Boolean (0=false, 1=true) (bool)
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
float Float_t
Float 4 bytes (float)
double Double_t
Double 8 bytes.
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
RAII guard for locking Eve manager (ctor) and processing changes (dtor).
A parametric, texture-mapped surface of spherical topology: a sphere that can be twisted,...
REveTrans is a 4x4 transformation matrix for homogeneous coordinates stored internally in a column-ma...
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
Handles synchronous and a-synchronous timer events.
void Reset()
Reset the timer.
Bool_t Notify() override
Notify when timer times out.
Namespace for ROOT features in testing.
constexpr Double_t PiOver2()
Double_t Sqrt(Double_t x)
Returns the square root of x.
Short_t Min(Short_t a, Short_t b)
Returns the smallest of a and b.
Double_t Cos(Double_t)
Returns the cosine of an angle of x radians.
Double_t Sin(Double_t)
Returns the sine of an angle of x radians.
Short_t Abs(Short_t d)
Returns the absolute value of parameter Short_t d.