AGX Dynamics  2.35.0.1
ConstraintAngle.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_CONSTRAINTANGLE_H
18 #define AGX_CONSTRAINTANGLE_H
19 
20 #include <agx/Vec3.h>
21 
22 #include <agxStream/Serializable.h>
23 
24 namespace agx
25 {
26  class AttachmentPair;
27 
32  {
33  public:
37  enum Axis
38  {
39  U,
40  V,
41  N
42  };
43 
47  enum Type
48  {
50  ROTATIONAL
51  };
52 
53  public:
57  virtual void transform( const agx::AttachmentPair& );
58 
63 
68 
72  const agx::Real& getValue() const;
73 
79  virtual const agx::Vec3& getDir( const agx::AttachmentPair& ap, agx::UInt index ) const;
80 
84  virtual void store( agxStream::OutputArchive& out ) const override;
85 
89  virtual void restore( agxStream::InputArchive& in ) override;
90 
92 
96  virtual void storeLightData( agxStream::StorageStream& str ) const override;
97 
101  virtual void restoreLightData( agxStream::StorageStream& str ) override;
102 
103  protected:
107  Angle( agx::Angle::Axis axis, agx::Angle::Type type, agx::Real initialAngle = agx::Real( 0 ) );
108 
112  virtual ~Angle();
113 
114  protected:
118  };
119 
122 
127  {
128  public:
132  static agx::RotationalAngle* safeCast( const agx::Angle* angle );
133 
134  public:
138  RotationalAngle( agx::Angle::Axis axis, agx::Real initialAngle = agx::Real( 0 ) );
139 
143  virtual void transform( const agx::AttachmentPair& ap ) override;
144 
149 
155  void setWindingNumber( agx::Int windingNumber );
156 
161 
166  void setLastAngle(agx::Real lastAngle);
167 
173 
175 
179  virtual void storeLightData( agxStream::StorageStream& str ) const override;
180 
184  virtual void restoreLightData( agxStream::StorageStream& str ) override;
185 
186  protected:
191 
195  virtual ~RotationalAngle();
196 
197  protected:
200  };
201 
203 
208  {
209  public:
213  static agx::SeparationAngle* safeCast( const agx::Angle* angle );
214 
215  public:
219  SeparationAngle( agx::Angle::Axis axis, agx::Real initialAngle = agx::Real( 0 ) );
220 
224  virtual void transform( const agx::AttachmentPair& ap ) override;
225 
227 
228  protected:
233 
237  virtual ~SeparationAngle();
238  };
239 
241 
243  {
244  return m_value;
245  }
246 } //namespace agx
247 
248 #endif
#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
#define AGXPHYSICS_EXPORT
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:52
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:45
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:49
Constraint angle class.
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(agx::Angle)
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
Angle(agx::Angle::Axis axis, agx::Angle::Type type, agx::Real initialAngle=agx::Real(0))
Construct given axis and initial angle.
virtual void restore(agxStream::InputArchive &in) override
Restore given stream.
virtual const agx::Vec3 & getDir(const agx::AttachmentPair &ap, agx::UInt index) const
virtual ~Angle()
Reference counted object, protected destructor.
agx::Angle::Type getType() const
agx::Real m_value
const agx::Real & getValue() const
virtual void transform(const agx::AttachmentPair &)
Transform method to update the value of this angle.
Type
Type, i.e., defines Axis as 'along' or 'about'.
@ TRANSLATIONAL
Axis is along U, V or N.
Axis
Axis this constraint angle is defined about or along.
@ V
Constraint y axis.
@ U
Constraint x axis.
agx::Angle::Axis getAxis() const
virtual void store(agxStream::OutputArchive &out) const override
Store given stream.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
Constraint attachment pair class.
Base class providing referencing counted objects.
Definition: Referenced.h:114
Implementation of constraint angle ABOUT an axis.
virtual void storeLightData(agxStream::StorageStream &str) const override
Store structural independent data to stream.
virtual ~RotationalAngle()
Reference counted object, protected destructor.
RotationalAngle(agx::Angle::Axis axis, agx::Real initialAngle=agx::Real(0))
Construct given axis and initial angle.
void setWindingNumber(agx::Int windingNumber)
Use with caution since each values of windingNumber represent plus or minus 360 degrees of the joint ...
static agx::RotationalAngle * safeCast(const agx::Angle *angle)
Utility cast method.
agx::Real getLastAngle() const
virtual void transform(const agx::AttachmentPair &ap) override
Update value given constraint pair.
virtual void restoreLightData(agxStream::StorageStream &str) override
Restore structural independent data from stream.
RotationalAngle()
Default constructor used during restore.
agx::Int getWindingNumber() const
void setLastAngle(agx::Real lastAngle)
Set the last angle bewteen (-pi, +pi) (winding number NOT included)
agx::Real calculateCurrentAngle(const AttachmentPair &ap) const
Implementation of constraint angle ALONG an axis.
static agx::SeparationAngle * safeCast(const agx::Angle *angle)
Utility cast method.
virtual ~SeparationAngle()
Reference counted object, protected destructor.
SeparationAngle()
Default constructor used during restore.
SeparationAngle(agx::Angle::Axis axis, agx::Real initialAngle=agx::Real(0))
Construct given axis and initial angle.
virtual void transform(const agx::AttachmentPair &ap) override
Update value given constraint pair.
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:30
#define AGX_FORCE_INLINE
Definition: macros.h:58
InputRef< T > in(const char *name, T &obj)
Create an object with a name and a reference to the object that should be restored (usually a pointer...
Definition: InputArchive.h:400
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.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::ref_ptr< RotationalAngle > RotationalAngleRef
int32_t Int
Definition: Integer.h:35
uint32_t UInt
Definition: Integer.h:34
double Real
Definition: Real.h:42
agx::Vector< AngleRef > AngleContainer
agx::ref_ptr< Angle > AngleRef
agx::ref_ptr< SeparationAngle > SeparationAngleRef