AGX Dynamics  2.37.2.0
BeamStiffnessDamping.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. Algoryx Simulation AB.
3 
4 All AGX source code, intellectual property, documentation, sample code,
5 tutorials, scene files and technical white papers, are copyrighted, proprietary
6 and confidential material of Algoryx Simulation AB. You may not download, read,
7 store, distribute, publish, copy or otherwise disseminate, use or expose this
8 material unless having a written signed agreement with Algoryx Simulation AB, or having been
9 advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10 valid commercial license from Algoryx Simulation AB.
11 
12 Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13 from using this software, unless otherwise stated in written agreements with
14 Algoryx Simulation AB.
15 */
16 
17 #pragma once
18 
19 #include <agxModel/export.h>
20 
21 #include <agx/LockJoint.h>
22 
23 namespace agxModel
24 {
30  {
36  static BeamStiffnessDamping createDefault();
37 
43 
49 
55 
61 
68  void apply( agx::LockJoint* lock, agx::Real scale = 1.0 ) const;
69  };
70 
71  inline void BeamStiffnessDamping::apply( agx::LockJoint* lock, agx::Real scale /*= 1.0*/ ) const
72  {
73  if ( lock == nullptr )
74  return;
75 
76  constexpr agx::Real minStiffness = 1.0E-5;
77  constexpr agx::Real minDamping = 0.0;
78 
79  lock->setCompliance( 1.0 / std::max( translationalStiffness.x(), minStiffness ), agx::LockJoint::TRANSLATIONAL_1 );
80  lock->setCompliance( 1.0 / std::max( translationalStiffness.y(), minStiffness ), agx::LockJoint::TRANSLATIONAL_2 );
81  lock->setCompliance( 1.0 / std::max( scale * translationalStiffness.z(), minStiffness ), agx::LockJoint::TRANSLATIONAL_3 );
82 
83  lock->setCompliance( 1.0 / std::max( scale * rotationalStiffness.x(), minStiffness ), agx::LockJoint::ROTATIONAL_1 );
84  lock->setCompliance( 1.0 / std::max( scale * rotationalStiffness.y(), minStiffness ), agx::LockJoint::ROTATIONAL_2 );
85  lock->setCompliance( 1.0 / std::max( scale * rotationalStiffness.z(), minStiffness ), agx::LockJoint::ROTATIONAL_3 );
86 
87  lock->setDamping( std::max( translationalDampingTime.x(), minDamping ), agx::LockJoint::TRANSLATIONAL_1 );
88  lock->setDamping( std::max( translationalDampingTime.y(), minDamping ), agx::LockJoint::TRANSLATIONAL_2 );
89  lock->setDamping( std::max( translationalDampingTime.z(), minDamping ), agx::LockJoint::TRANSLATIONAL_3 );
90 
91  lock->setDamping( std::max( rotationalDampingTime.x(), minDamping ), agx::LockJoint::ROTATIONAL_1 );
92  lock->setDamping( std::max( rotationalDampingTime.y(), minDamping ), agx::LockJoint::ROTATIONAL_2 );
93  lock->setDamping( std::max( rotationalDampingTime.z(), minDamping ), agx::LockJoint::ROTATIONAL_3 );
94  }
95 }
agx::Vec3 translationalDampingTime
Translational damping time where x and y are shear damping and z is stretch.
agx::Vec3 rotationalStiffness
Rotational stiffness where x and y are bend stiffness and z is torsion.
Stiffness and damping data for constraints related to beam models.
Vec3T< T > max(const Vec3T< T > &lhs, const Vec3T< T > &rhs)
Definition: Vec3Template.h:855
virtual void setDamping(agx::Real damping, agx::Int dof)
Set the damping of this constraint for the i:th DOF.
virtual void setCompliance(agx::Real compliance, agx::Int dof)
Set the compliance of this constraint for the i:th DOF.
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:36
Constraint that removes all 6 DOF between two bodies, or one body and the world.
Definition: LockJoint.h:28
Select DOF for the first translational axis.
Definition: LockJoint.h:71
agx::Vec3 translationalStiffness
Translational stiffness where x and y are shear stiffness and z is stretch.
Select DOF corresponding to the first rotational axis.
Definition: LockJoint.h:74
agx::Vec3 rotationalDampingTime
Rotational damping time where x and y are bend damping and z is torsion.
Select DOF corresponding to the second rotational axis.
Definition: LockJoint.h:75
Select DOF for the third translational axis.
Definition: LockJoint.h:73
void apply(agx::LockJoint *lock, agx::Real scale=1.0) const
Apply stiffness as compliance to the given lock joint.
#define AGXMODEL_EXPORT
double Real
Definition: Real.h:42
Select DOF for rotation around Z-axis.
Definition: LockJoint.h:76
Select DOF for the second translational axis.
Definition: LockJoint.h:72