FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
RigidBodyEnvironmentForces.h
1#ifndef RigidBodyEnvironmentForces_H
2#define RigidBodyEnvironmentForces_H
3#include "CRigidBody.h"
4
5#include <fhsim_environment/SeafloorForcesInterface.h>
6
7namespace rigidbody
8{
9namespace soilforces
10{
17inline environment::seabed::RigidMotion<double> RigidMotionOf(const vec6& dX, const vec3& r, const quat& q)
18{
19 environment::seabed::RigidMotion<double> motion;
20 const vec3 velocity = q * dX.head<3>();
21 const vec3 angularVelocity = q * dX.tail<3>();
22 for (int i = 0; i < 3; i++) {
23 motion.pos[i] = r(i);
24 motion.vel[i] = velocity(i);
25 motion.omega[i] = angularVelocity(i);
26 const vec3 axis = q * vec3::Unit(i);
27 for (int j = 0; j < 3; j++)
28 motion.R[3 * i + j] = axis(j);
29 }
30 return motion;
31}
32
34inline vec6 BodyLocalLoad(const environment::seabed::ContactLoad<double>& load, const quat& q)
35{
36 const quat inverse = q.conjugate();
37 vec6 force;
38 force << inverse * vec3(load.force[0], load.force[1], load.force[2]), inverse * vec3(load.moment[0], load.moment[1], load.moment[2]);
39 return force;
40}
41
47{
48 public:
50 void SetSeafloorForces(environment::SeafloorForcesInterface* seafloorForces) { m_seafloorForces = seafloorForces; }
52 bool InSeabedContact() const { return m_inSeabedContact; }
53
54 protected:
55 environment::SeafloorForcesInterface* m_seafloorForces = nullptr;
56 bool m_inSeabedContact = false;
57};
58} // namespace soilforces
59} // namespace rigidbody
60
61#endif
Definition RigidBodyEnvironmentForces.h:47
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:52
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:50