AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
WireStabilityController.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. 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
22
24
25
26namespace agxWire {
27
28 class WireParameterController;
29
30 class AGXPHYSICS_EXPORT WireStabilityController : public agx::Referenced
31 {
32 public:
43 static agx::Real getStabilityFactor( const agxWire::Node* node, const agxWire::WireDistanceCompositeConstraint* wire, agx::Real scaleConstant = agx::Real( 1 ), bool smoothed = false );
44
55 static agx::Real getStabilityFactor( agxWire::NodeConstIterator nodeIt, const agxWire::WireDistanceCompositeConstraint* wire, agx::Real scaleConstant = agx::Real( 1 ), bool smoothed = false );
56
67 static bool isStable( agx::Real tensionLeft, agx::Real tensionRight, agx::Real lengthLeft, agx::Real lengthRight, agx::Real lumpMass, agx::Real constant );
68
69 public:
70 WireStabilityController( WireMaterialController* lmc );
71
72 virtual void update( agxWire::WireParameterController* parameterController, agx::Real timeStep );
73
74 void setWire( WireDistanceCompositeConstraint* lDCC )
75 {
76 m_wire = lDCC;
77 }
78
79 bool hasWire( )
80 {
81 return m_wire != nullptr;
82 }
83
90 void changeMass( agx::Real dl, BodyFixedNode* bfnA, BodyFixedNode* bfnB ) const;
91
95 WireMaterialController* getMaterialController() { return m_materialController; }
96 const WireMaterialController* getMaterialController() const { return m_materialController; }
97
101 bool isStable( const agxWire::BodyFixedNode* node ) const;
102
106 bool isGeometricallyStable( NodeConstIterator prevIt, NodeConstIterator nextIt, agx::Real d1, agx::Real d2 ) const;
107
111 agx::Real getTimeStepDependentStabilityConstant() const;
112
120 void removeUnstableNodesNearShapeContacts();
121
129 agx::Real getStabilityFactor( const agxWire::BodyFixedNode* node, agx::Real scaleConstant = agx::Real( 1 ) ) const;
130
138 agx::Real getStabilityFactor( agxWire::NodeConstIterator nodeIt, agx::Real scaleConstant = agx::Real( 1 ) ) const;
139
140 protected:
141 enum MassNodeStatus {
142
143 STABLE = 1,
144 MOVABLE = (1<<2),
145 REMOVABLE = (1<<3),
146 LOW_RESOLUTION = (1<<4)
148 };
149
150 struct InsertNodeData
151 {
152 agx::Real halfRestlengthFromPreviousToNext;
153 agx::Real distanceFromABSegmentMiddle;
154 agx::Real restlengthFromA;
155 agx::Real minLengthFactor;
156 };
157
158 typedef agx::List< InsertNodeData > InsertNodeDataList;
159
167 bool isCollidingSlidingNode( BodyFixedNode* bfn,NodeConstIterator itBefore, NodeConstIterator itAfter ) const;
168
172 bool resolutionHighEnoughForPosition( NodeConstIterator bfnIt, NodeConstIterator prevBfn, NodeConstIterator nextBfn, const agx::Real restlengthToBfn, const agx::Real minDistanceToLump, const agx::Real aroundLumpAngle, const agx::Real eps = agx::Real(1E-6) ) const;
173
184 MassNodeStatus analyze( NodeConstIterator bfnIt, NodeConstIterator prevBfn, NodeConstIterator nextBfn, const agx::Real restlengthToBfn ,const agx::Real minDistanceToLump, const bool lastBfnRemovedByResolution ) const;
185
192 bool isWithinRange( const agx::Vector<WireNodeRange>& insertRanges, const agx::Real distance ) const;
193
194 void insertSorted( InsertNodeDataList& insertData, InsertNodeData ind ) const;
195
206 void findMiddleInsertPositions(
207 NodeConstIterator itA, NodeConstIterator itB, const agx::Real lumpMass, const agx::Real restlengthAB,
208 InsertNodeDataList& insertData, const agx::Real minDistFromStart, const agx::Real minDistanceFromEnd) const;
209
216 agx::Real findRangeEndInsertPosition(const agx::Vector<WireNodeRange>& insertRanges,const InsertNodeDataList& insertData) const;
217
227 agx::Real analyze( NodeConstIterator bfnAIt, NodeConstIterator bfnBIt, const agx::Real restlengthToA, const agx::Real minDistFromStart, const agx::Real minDistanceFromEnd ) const;
228
229 inline agx::Real calculateLengthFactor( agx::Real l1, agx::Real l2 ) const
230 {
231 if ( agx::equalsZero(l1) || agx::equalsZero(l2) )
232 return 0;
233 return ( l1*l2/(l1+l2) );
234 }
235
239 inline agx::Real minimumLengthFactor( agx::Real tension, agx::Real mass, agx::Real constant ) const
240 {
241 return tension / (mass * constant);
242 }
243
249 bool move( BodyFixedNode* bfn );
250
251 protected:
253 agx::Real m_scaleConstant;
254 agx::Real m_timeStep;
256 agx::Real m_noLumpNearDistance;
257 };
258
259 typedef agx::ref_ptr< WireStabilityController > WireStabilityControllerRef;
260
261}
262
#define AGXPHYSICS_EXPORT
The body fixed node is attached to a body at a given offset.
Class defining a node that is part of a wire.
Class to hold specific parameters for the wire - this makes the wires highly configurable.
Base class providing referencing counted objects.
Definition Referenced.h:120
Templated vector class.
Definition agx/Vector.h:53
Smart pointer for observed objects, that automatically set pointers to them to null when they deleted...
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
#define DOXYGEN_END_INTERNAL_BLOCK()
Definition macros.h:97
#define DOXYGEN_START_INTERNAL_BLOCK()
Definition macros.h:96
Implements a Wire model with adaptive resolution.
Definition MergedBody.h:40
NodeContainer::const_iterator NodeConstIterator
AGXPHYSICS_EXPORT agx::Bool equalsZero(const agx::AddedMassInteraction::Matrix6x6 &matrix, agx::Real eps=agx::RealEpsilon)
double Real
Definition Real.h:42