FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
RigidBodyEnvironmentForces.h
1#ifndef RigidBodyEnvironmentForces_H
2#define RigidBodyEnvironmentForces_H
3
8#include "CRigidBody.h"
9
10#include <fhsim_environment/SeafloorForcesInterface.h>
11
12namespace rigidbody
13{
14namespace soilforces
15{
22inline environment::seabed::RigidMotion<double> RigidMotionOf(const vec6& dX, const vec3& r, const quat& q)
23{
24 environment::seabed::RigidMotion<double> motion;
25 const vec3 velocity = q * dX.head<3>();
26 const vec3 angularVelocity = q * dX.tail<3>();
27 for (int i = 0; i < 3; i++) {
28 motion.pos[i] = r(i);
29 motion.vel[i] = velocity(i);
30 motion.omega[i] = angularVelocity(i);
31 const vec3 axis = q * vec3::Unit(i);
32 for (int j = 0; j < 3; j++)
33 motion.R[3 * i + j] = axis(j);
34 }
35 return motion;
36}
37
39inline vec6 BodyLocalLoad(const environment::seabed::ContactLoad<double>& load, const quat& q)
40{
41 const quat inverse = q.conjugate();
42 vec6 force;
43 force << inverse * vec3(load.force[0], load.force[1], load.force[2]), inverse * vec3(load.moment[0], load.moment[1], load.moment[2]);
44 return force;
45}
46
52{
53 public:
55 void SetSeafloorForces(environment::SeafloorForcesInterface* seafloorForces) { m_seafloorForces = seafloorForces; }
57 bool InSeabedContact() const { return m_inSeabedContact; }
58
59 protected:
60 environment::SeafloorForcesInterface* m_seafloorForces = nullptr;
61 bool m_inSeabedContact = false;
62};
63} // namespace soilforces
64} // namespace rigidbody
65
66#endif
Definition RigidBodyEnvironmentForces.h:52
bool InSeabedContact() const
Whether the element was in contact with the seabed at its last force evaluation (its soil load has no...
Definition RigidBodyEnvironmentForces.h:57
void SetSeafloorForces(environment::SeafloorForcesInterface *seafloorForces)
Sets the resource the soil load is asked from; it must be set before the element's forces are compute...
Definition RigidBodyEnvironmentForces.h:55