Program listing for file mechanics/src/collision/native/bodies/DiskMovingPlanR.hpp#
Return to documentation for this file
1#ifndef DiskMovingPlanR_h
2#define DiskMovingPlanR_h
3
4#include "MechanicsFwd.hpp"
5#include "LagrangianRheonomousR.hpp"
6#include "PluggedObject.hpp"
7
8typedef double(*FTime)(double);
9
10
11#define COMPUTE(X) \
12 { if (_##X##Function->fPtr) _##X=((FTime)(_##X##Function->fPtr))(t); else _##X=0.; }
13
14
15
16class DiskMovingPlanR : public LagrangianRheonomousR,
17 public std::enable_shared_from_this<DiskMovingPlanR>
18{
19private:
20
21 ACCEPT_SERIALIZATION(DiskMovingPlanR);
22
23 double _time, _A, _B, _C, _ADot, _BDot, _CDot, _sqrA2pB2, _r, _AADot, _BBDot, _cubsqrA2pB2;
24
25
26 SP::PluggedObject _AFunction{nullptr};
27 SP::PluggedObject _BFunction{nullptr};
28 SP::PluggedObject _CFunction{nullptr};
29
30 SP::PluggedObject _ADotFunction{nullptr};
31 SP::PluggedObject _BDotFunction{nullptr};
32 SP::PluggedObject _CDotFunction{nullptr};
33
34 DiskMovingPlanR() : LagrangianRheonomousR() {};
35
36public:
37
38 DiskMovingPlanR(FTime, FTime, FTime, FTime, FTime, FTime, double);
39
40 ~DiskMovingPlanR() noexcept = default;
41
42 void init(double);
43
44
45 void computeh(double time, const BlockVector& q, BlockVector& z, SiconosVector& y);
46
47
48 void computeJachq(double time, const BlockVector& q, BlockVector& z);
49
50
51 void computehDot(double time, const BlockVector& q, BlockVector& z);
52
53 double distance(double, double, double);
54
55 void setComputeAFunction(FTime f)
56 {
57 _AFunction.reset(new PluggedObject());
58 _AFunction->setComputeFunction((void*) f);
59 }
60
61 void setComputeBFunction(FTime f)
62 {
63 _BFunction.reset(new PluggedObject());
64 _BFunction->setComputeFunction((void*) f);
65 }
66
67 void setComputeCFunction(FTime f)
68 {
69 _CFunction.reset(new PluggedObject());
70 _CFunction->setComputeFunction((void*) f);
71 }
72
73 void setComputeADotFunction(FTime f)
74 {
75 _ADotFunction.reset(new PluggedObject());
76 _ADotFunction->setComputeFunction((void*) f);
77 }
78
79 void setComputeBDotFunction(FTime f)
80 {
81 _BDotFunction.reset(new PluggedObject());
82 _BDotFunction->setComputeFunction((void*) f);
83 }
84
85 void setComputeCDotFunction(FTime f)
86 {
87 _CDotFunction.reset(new PluggedObject());
88 _CDotFunction->setComputeFunction((void*) f);
89 }
90
91 bool equal(FTime, FTime, FTime, double) const;
92
93
94 void computeA(double t)
95 COMPUTE(A)
96
97
98 void computeB(double t)
99 COMPUTE(B)
100
101
102 void computeC(double t)
103 COMPUTE(C)
104
105
106 inline void computeADot(double t)
107 COMPUTE(ADot)
108
109
110 inline void computeBDot(double t)
111 COMPUTE(BDot)
112
113
114
115 inline void computeCDot(double t)
116 COMPUTE(CDot)
117
118 ACCEPT_VISITORS();
119
120
121};
122#undef COMPUTE
123
124#endif