AGX Dynamics 2.41.3.0
Loading...
Searching...
No Matches
BeamStiffnessDamping.h
Go to the documentation of this file.
1/*
2Copyright 2007-2025. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#pragma once
18
19#include <agxModel/export.h>
20
21#include <agx/LockJoint.h>
22
23namespace agxModel
24{
30 {
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}
#define AGXMODEL_EXPORT
virtual void setCompliance(agx::Real compliance, agx::Int dof)
Set the compliance of this constraint for the i:th DOF.
virtual void setDamping(agx::Real damping, agx::Int dof)
Set the damping of this constraint for the i:th DOF.
Constraint that removes all 6 DOF between two bodies, or one body and the world.
Definition: LockJoint.h:31
@ TRANSLATIONAL_2
Select DOF for the second translational axis.
Definition: LockJoint.h:74
@ ROTATIONAL_2
Select DOF corresponding to the second rotational axis.
Definition: LockJoint.h:77
@ TRANSLATIONAL_1
Select DOF for the first translational axis.
Definition: LockJoint.h:73
@ ROTATIONAL_1
Select DOF corresponding to the first rotational axis.
Definition: LockJoint.h:76
@ ROTATIONAL_3
Select DOF for rotation around Z-axis.
Definition: LockJoint.h:78
@ TRANSLATIONAL_3
Select DOF for the third translational axis.
Definition: LockJoint.h:75
Contain classes for higher level modeling primitives, such as Tree, Terrain etc.
Definition: FlowUnit.h:37
double Real
Definition: Real.h:42
Stiffness and damping data for constraints related to beam models.
agx::Vec3 translationalStiffness
Translational stiffness where x and y are shear stiffness and z is stretch.
agx::Vec3 translationalDampingTime
Translational damping time where x and y are shear damping and z is stretch.
static BeamStiffnessDamping createDefault()
Sane default values for stiffness and damping that can be used when inputs are invalid but something ...
void apply(agx::LockJoint *lock, agx::Real scale=1.0) const
Apply stiffness as compliance to the given lock joint.
agx::Vec3 rotationalStiffness
Rotational stiffness where x and y are bend stiffness and z is torsion.
agx::Vec3 rotationalDampingTime
Rotational damping time where x and y are bend damping and z is torsion.