AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
ElementaryWireConstraints.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
19
20#include <agxWire/Node.h>
21
23
26
28
29namespace agxWire
30{
31 struct BendJacobian
32 {
33 static agx::Quat calculate( const agx::Vec3& p1, const agx::Vec3& p2, const agx::Vec3& p3, agx::Vec3* G1, agx::Vec3* G2 );
34 };
35
36 class ElementaryWireDistanceConstraint : public agx::ElementaryConstraintN< 1 >
37 {
38 public:
40#if HASH_FOR_WIRE == HASH_NEW
42#elif HASH_FOR_WIRE == HASH_OLD
44#else
45 #error
46#endif
47
48 public:
49 ElementaryWireDistanceConstraint();
50
54 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* /*G*/, agx::UInt /*numBlocks*/, agx::UInt /*row*/, agx::GWriteState::Enum /*writeState*/ ) override { return 0; }
55
59 agx::UInt getJacobian( agx::Jacobian6DOFElement* G, const IndexTable& bodyToIndexTable, NodeConstIterator begin, NodeConstIterator end );
60
64 virtual agx::UInt getViolation( agx::Real* /*g*/, agx::UInt /*row*/ ) override { return 1; }
65
70 inline agx::Real getCurrentLength() const { return m_currentLength; }
71
72 protected:
73 virtual ~ElementaryWireDistanceConstraint() {}
74
75 private:
76 agx::Real m_currentLength;
77 };
78
79 typedef agx::ref_ptr< ElementaryWireDistanceConstraint > ElementaryWireDistanceConstraintRef;
80
81 class ElementaryWireBendConstraint : public agx::ElementaryConstraint
82 {
83 public:
85#if HASH_FOR_WIRE == HASH_NEW
87#elif HASH_FOR_WIRE == HASH_OLD
89#else
90 #error
91#endif
92
93 public:
94 ElementaryWireBendConstraint( agx::UInt numRows );
95
102 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override = 0;
103
107 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, const Node* first, const Node* second, const Node* third, const IndexTable& bodyToIndexTable ) = 0;
108
112 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* /*G*/, agx::UInt /*numBlocks*/, agx::UInt /*row*/, agx::GWriteState::Enum /*writeState*/ ) override { return 0; }
113
119 inline void setComplianceAndDamping( agx::Real compliance, agx::Real damping );
120
121 protected:
122 virtual ~ElementaryWireBendConstraint() {}
123
124 protected:
125 agx::RegularizationParameters m_regParams[2];
126 agx::Real m_forces[2];
127 agx::RangeReal m_bounds[2];
128 };
129
130 inline void ElementaryWireBendConstraint::setComplianceAndDamping( agx::Real compliance, agx::Real damping )
131 {
132 getRegularizationParameters()->setCompliance( compliance );
133 getRegularizationParameters()->setDamping( damping );
134 if ( getNumRows() > 1 ) {
135 getRegularizationParameters( 1 )->setCompliance( compliance );
136 getRegularizationParameters( 1 )->setDamping( damping );
137 }
138 }
139
143 class ElementaryWireBendConstraintAngle : public ElementaryWireBendConstraint
144 {
145 public:
146 ElementaryWireBendConstraintAngle();
147
148 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, const Node* first, const Node* second, const Node* third, const IndexTable& bodyToIndexTable ) override;
149 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
150
151 protected:
152 virtual ~ElementaryWireBendConstraintAngle() {}
153
154 private:
155 using ElementaryWireBendConstraint::getJacobian;
156
157 protected:
158 agx::Real m_angle;
159 };
160
161 typedef agx::ref_ptr< ElementaryWireBendConstraintAngle > ElementaryWireBendConstraintAngleRef;
162
163 class ElementaryQuaternionBendConstraint : public agxWire::ElementaryWireBendConstraint
164 {
165 public:
166 ElementaryQuaternionBendConstraint();
167
174 virtual agx::UInt getViolation( agx::Real* g, agx::UInt row ) override;
175
185 virtual agx::UInt getJacobian( agx::Jacobian6DOFElement* G, const Node* first, const Node* second, const Node* third, const IndexTable& bodyToIndexTable ) override;
186
187 protected:
188 virtual ~ElementaryQuaternionBendConstraint() {}
189
190 private:
191 using agxWire::ElementaryWireBendConstraint::getJacobian;
192
193 protected:
194 agx::Real m_violation[2];
195 };
196
197 typedef agx::ref_ptr< ElementaryQuaternionBendConstraint > ElementaryQuaternionBendConstraintRef;
198}
199
Helper class to hold data that is general for elementary constraints.
Elementary constraint base class with interface and global constraint functionality.
virtual agx::UInt getJacobian(agx::Jacobian6DOFElement *G, agx::UInt numBlocks, agx::UInt row, agx::GWriteState::Enum writeState)
Returns the Jacobian of this elementary constraint.
virtual agx::UInt getViolation(agx::Real *g, agx::UInt row)
Returns the violation of this elementary constraint.
Inheritance with partial specialization due to bug with ref_ptr containers.
Inheritance with partial specialization due to bug with ref_ptr containers.
All ghost variables have compliance and damping attributes.
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
uint64_t UInt
Definition Integer.h:27
double Real
Definition Real.h:42