AGXDynamics  2.35.0.2
SleepThreshold.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2022. 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 #ifndef AGX_SleepThreshold_H
18 #define AGX_SleepThreshold_H
19 
20 #include <agx/agxPhysics_export.h>
21 #include <agxStream/Serializable.h>
22 
23 namespace agx
24 {
25 
29  {
30  public:
31 
38  inline SleepThreshold( float velocity=float(0.05),
39  float acceleration=float(0.2),
40  float angularVelocity=float(1E10),
41  float angularAcceleration=1E10
42  );
43 
45  inline float getVelocity() const;
46 
48  inline float getAngularVelocity() const;
49 
51  inline float getAcceleration() const;
52 
54  inline float getAngularAcceleration() const;
55 
56 
57  // Squared
59  inline float getVelocity2() const;
60 
62  inline float getAngularVelocity2() const;
63 
65  inline float getAcceleration2() const;
66 
68  inline float getAngularAcceleration2() const;
69 
70  // Setters
72  inline void setVelocity( float vel );
73 
75  inline void setAngularVelocity( float vel );
76 
78  inline void setAcceleration( float acc );
79 
81  inline void setAngularAcceleration( float acc );
82 
84 
85  protected:
86 
87 
88 
89  float m_velocityThreshold;
93 
94  // float m_velocityThreshold2;
95  // float m_accelerationThreshold2;
96  // float m_angularVelocityThreshold2;
97  // float m_angularAccelerationThreshold2;
98 
99  };
100 
102 
103 
105 
107 
109  {
110  public:
111 
112  AutoSleepThreshold( float velocity=float(0.05),
113  float acceleration=1E10,
114  float angularVelocity=float(0.05),
115  float angularAcceleration=1E10,
116  float time=float(0.8) );
117 
122  inline void setTime( float time );
123 
128  inline float getTime() const;
129 
131 
132  protected:
133  float m_time;
134  };
135 
137 
138 
139  // Implementation
140  inline SleepThreshold::SleepThreshold( float velocity, float acceleration, float angularVelocity, float angularAcceleration ) :
141  m_velocityThreshold(velocity), m_accelerationThreshold(acceleration), m_angularVelocityThreshold( angularVelocity ), m_angularAccelerationThreshold(angularAcceleration)
142  {
143  // m_velocityThreshold2 = m_velocityThreshold*m_velocityThreshold;
144  // m_accelerationThreshold2=m_accelerationThreshold*m_accelerationThreshold;
145  // m_angularVelocityThreshold2=m_angularVelocityThreshold*m_angularVelocityThreshold;
146  // m_angularAccelerationThreshold2=m_angularAccelerationThreshold*m_angularAccelerationThreshold;
147  }
148 
149  inline float SleepThreshold::getVelocity() const { return m_velocityThreshold; }
151 
152  inline void SleepThreshold::setVelocity( float vel ) { m_velocityThreshold = vel; }
153  inline void SleepThreshold::setAcceleration( float acc ) { m_accelerationThreshold = acc; }
155 
158 
161 
164 
166 
167  inline void AutoSleepThreshold::setTime( float time ) { m_time = time; }
168  inline float AutoSleepThreshold::getTime( ) const { return m_time; }
169 
170  inline std::ostream& operator <<(std::ostream& out, const SleepThreshold& t)
171  {
172  out << "Vt: " << t.getVelocity() << " AVt: " << t.getAngularVelocity() << " At: " << t.getAcceleration() << " AAt: " << t.getAngularAcceleration() << std::endl;
173  return out;
174  }
175 }
176 
177 #endif /* AGX_SleepThreshold_H */
agxPhysics_export.h
agx::SleepThreshold::m_accelerationThreshold
float m_accelerationThreshold
Definition: SleepThreshold.h:90
agx::MergeSplitThreshold
SleepThreshold MergeSplitThreshold
Definition: SleepThreshold.h:104
agx::MergeSplitThresholdRef
agx::ref_ptr< MergeSplitThreshold > MergeSplitThresholdRef
Definition: SleepThreshold.h:106
agxStream::out
OutputRef< Serializable > out(const char *name, const Serializable *obj)
Return an object that contain the name and the object that should be serialized to an archive.
Definition: OutputArchive.h:412
agx::SleepThresholdRef
agx::ref_ptr< SleepThreshold > SleepThresholdRef
Definition: SleepThreshold.h:101
agxStream::Serializable
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
agx::SleepThreshold::getAcceleration2
float getAcceleration2() const
Definition: SleepThreshold.h:160
agx::SleepThreshold::getVelocity
float getVelocity() const
Definition: SleepThreshold.h:149
agx::SleepThreshold::m_angularVelocityThreshold
float m_angularVelocityThreshold
Definition: SleepThreshold.h:91
AGXSTREAM_DECLARE_SERIALIZABLE
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
Definition: Serializable.h:207
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::operator<<
std::ostream & operator<<(std::ostream &stream, const AtomicValueT< T > &value)
Definition: AtomicValue.h:109
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agx::SleepThreshold::getAngularAcceleration2
float getAngularAcceleration2() const
Definition: SleepThreshold.h:157
agx::AutoSleepThreshold::setTime
void setTime(float time)
Set the time-window during which the body must be below velocity/acceleration threshold before it is ...
Definition: SleepThreshold.h:167
agx::AutoSleepThreshold::getTime
float getTime() const
Get the time-window during which the body must be below velocity/acceleration threshold before it is ...
Definition: SleepThreshold.h:168
Serializable.h
agx::AutoSleepThreshold
Definition: SleepThreshold.h:108
agx::SleepThreshold::getAngularAcceleration
float getAngularAcceleration() const
Definition: SleepThreshold.h:156
agx::SleepThreshold::SleepThreshold
SleepThreshold(float velocity=float(0.05), float acceleration=float(0.2), float angularVelocity=float(1E10), float angularAcceleration=1E10)
Definition: SleepThreshold.h:140
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
agx::SleepThreshold::getAcceleration
float getAcceleration() const
Definition: SleepThreshold.h:159
agx::SleepThreshold::getAngularVelocity2
float getAngularVelocity2() const
Definition: SleepThreshold.h:163
agx::SleepThreshold
Definition: SleepThreshold.h:28
agx::AutoSleepThreshold::m_time
float m_time
Definition: SleepThreshold.h:130
agx::SleepThreshold::getAngularVelocity
float getAngularVelocity() const
Definition: SleepThreshold.h:162
agx::SleepThreshold::getVelocity2
float getVelocity2() const
Definition: SleepThreshold.h:150
agx::AutoSleepThresholdRef
agx::ref_ptr< AutoSleepThreshold > AutoSleepThresholdRef
Definition: SleepThreshold.h:136
agx::SleepThreshold::setAngularVelocity
void setAngularVelocity(float vel)
Set the threshold of the angular velocity magnitude when a body should be put to sleep.
Definition: SleepThreshold.h:165
agx::SleepThreshold::m_angularAccelerationThreshold
float m_angularAccelerationThreshold
Definition: SleepThreshold.h:92
agx::SleepThreshold::setAcceleration
void setAcceleration(float acc)
set the threshold of the linear acceleration magnitude when a body should be put to sleep
Definition: SleepThreshold.h:153
agx::SleepThreshold::setVelocity
void setVelocity(float vel)
Set the threshold of the linear velocity magnitude when a body should be put to sleep.
Definition: SleepThreshold.h:152
agx::SleepThreshold::setAngularAcceleration
void setAngularAcceleration(float acc)
Set the threshold of the angular acceleration magnitude when a body should be put to sleep.
Definition: SleepThreshold.h:154
agx::SleepThreshold::m_velocityThreshold
float m_velocityThreshold
Definition: SleepThreshold.h:83