AGXDynamics  2.35.0.3
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 
62  agx::Angle::Axis getAxis() const;
63 
67  agx::Angle::Type getType() const;
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 
148  agx::Int getWindingNumber() const;
149 
155  void setWindingNumber( agx::Int windingNumber );
156 
160  agx::Real getLastAngle() const;
161 
166  void setLastAngle(agx::Real lastAngle);
167 
172  agx::Real calculateCurrentAngle(const AttachmentPair& ap) const;
173 
175 
179  virtual void storeLightData( agxStream::StorageStream& str ) const override;
180 
184  virtual void restoreLightData( agxStream::StorageStream& str ) override;
185 
186  protected:
190  RotationalAngle();
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:
232  SeparationAngle();
233 
237  virtual ~SeparationAngle();
238  };
239 
241 
243  {
244  return m_value;
245  }
246 } //namespace agx
247 
248 #endif
agx::Angle::m_axis
Axis m_axis
Definition: ConstraintAngle.h:115
agx::Real
double Real
Definition: Real.h:42
agxData::transform
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
agx::Vector< AngleRef >
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::SeparationAngle
Implementation of constraint angle ALONG an axis.
Definition: ConstraintAngle.h:207
agx::RotationalAngle::m_lastAngle
agx::Real m_lastAngle
Definition: ConstraintAngle.h:199
agx::AngleContainer
agx::Vector< AngleRef > AngleContainer
Definition: ConstraintAngle.h:121
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
agxData::getType
AGXCORE_EXPORT Type * getType(const agx::String &name)
agx::RotationalAngle
Implementation of constraint angle ABOUT an axis.
Definition: ConstraintAngle.h:126
agx::Int
int32_t Int
Definition: Integer.h:35
agxStream::StorageStream
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE
#define AGXSTREAM_DECLARE_ABSTRACT_SERIALIZABLE(T)
Use this in a pure abstract Serializable class to add the required methods Important: Use full namesp...
Definition: Serializable.h:221
agx::Angle::getValue
const agx::Real & getValue() const
Definition: ConstraintAngle.h:242
agx::Angle::Type
Type
Type, i.e., defines Axis as 'along' or 'about'.
Definition: ConstraintAngle.h:47
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::SeparationAngleRef
agx::ref_ptr< SeparationAngle > SeparationAngleRef
Definition: ConstraintAngle.h:240
agx::AttachmentPair
Constraint attachment pair class.
Definition: Attachment.h:300
agx
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Definition: AddedMassInteraction.h:22
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
agx::Angle::Axis
Axis
Axis this constraint angle is defined about or along.
Definition: ConstraintAngle.h:37
agxStream::in
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
agx::RotationalAngle::m_windingNumber
agx::Int m_windingNumber
Definition: ConstraintAngle.h:198
Vec3.h
agx::ref_ptr
Smart pointer for handling referenced counted objects.
Definition: ref_ptr.h:29
agx::Angle::m_type
Type m_type
Definition: ConstraintAngle.h:116
agxStream::OutputArchive
Class for writing serialized data in binary format to a stream.
Definition: OutputArchive.h:56
Serializable.h
agxStream::InputArchive
Class for reading a binary stream of serialized data.
Definition: InputArchive.h:51
agx::Angle::m_value
agx::Real m_value
Definition: ConstraintAngle.h:117
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:113
agx::UInt
uint32_t UInt
Definition: Integer.h:34
agx::Angle::V
@ V
Constraint y axis.
Definition: ConstraintAngle.h:40
agx::AngleRef
agx::ref_ptr< Angle > AngleRef
Definition: ConstraintAngle.h:120
agx::Angle
Constraint angle class.
Definition: ConstraintAngle.h:31
agx::Angle::TRANSLATIONAL
@ TRANSLATIONAL
Axis is along U, V or N.
Definition: ConstraintAngle.h:49
agx::Vec3T< Real >
agx::RotationalAngleRef
agx::ref_ptr< RotationalAngle > RotationalAngleRef
Definition: ConstraintAngle.h:202
agx::Angle::U
@ U
Constraint x axis.
Definition: ConstraintAngle.h:39
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58