AGXDynamics  2.31.1.0
ObserverFrame.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2021. 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_OBSERVERFRAME_H
18 #define AGX_OBSERVERFRAME_H
19 
20 #include <agx/agx.h>
21 #include <agx/RigidBody.h>
22 #include <agx/Frame.h>
23 
24 #ifdef _MSC_VER
25 # pragma warning(push)
26 # pragma warning(disable:4355) //Disable 'this' : used in base member initializer list warning
27 #endif
28 
29 namespace agx
30 {
31  class DynamicsSystem;
32  class AutoSleep;
33  class MergeSplitBodyStorage;
34 
37 
43  {
44  public:
45 
46 
47  public:
54  ObserverFrame( const agx::Name& name = "", agx::RigidBody* rb = nullptr, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4());
61 
67  agx::Frame* getFrame();
68 
74  const agx::Frame* getFrame() const;
75 
83  void setTransform( const agx::AffineMatrix4x4& matrix );
84 
88  const agx::AffineMatrix4x4& getLocalTransform() const;
89 
94  void setLocalTransform( const agx::AffineMatrix4x4& matrix );
95 
99  agx::Vec3 getLocalPosition() const;
100 
105  void setLocalPosition( const agx::Vec3& p );
106 
113  void setLocalPosition( agx::Real x, agx::Real y, agx::Real z );
114 
119  void setRotation( const agx::Quat& q );
120 
125  void setRotation( const agx::EulerAngles& e);
126 
131  void setRotation( const agx::OrthoMatrix3x3& m );
132 
136  agx::Quat getLocalRotation() const;
137 
142  void setLocalRotation( const agx::Quat& q );
143 
148  void setLocalRotation( const agx::EulerAngles& e );
149 
153  agx::Frame* getParentFrame();
154 
158  const agx::Frame* getParentFrame() const;
159 
169  bool setParentFrame( agx::Frame* frame );
170 
175  void setPosition( const agx::Vec3& p );
176 
183  void setPosition( agx::Real x, agx::Real y, agx::Real z );
184 
190  void setEnable( bool enable );
191 
196  bool getEnable() const;
197 
202  bool isEnabled() const;
203 
207  agx::DynamicsSystem* getSystem();
208 
212  const agx::DynamicsSystem* getSystem() const;
213 
214 
219  agx::Vec3 getPosition() const;
220 
225  agx::Quat getRotation() const;
226 
230  agx::Vec3 transformVectorToWorld(const agx::Vec3& vectorLocal) const;
231  agx::Vec3 transformVectorToLocal(const agx::Vec3& vectorWorld) const;
232  agx::Vec3 transformPointToWorld(const agx::Vec3& pointLocal) const;
233  agx::Vec3 transformPointToLocal(const agx::Vec3& pointWorld) const;
234 
238  agx::Vec3 getVelocity() const;
239 
243  agx::Vec3 getAngularVelocity() const;
244 
248  agx::Vec3 getAcceleration() const;
249 
253  agx::Vec3 getAngularAcceleration() const;
254 
258  agx::Vec3 getRelativeVelocity(const agx::RigidBody* rb) const;
259 
263  agx::Vec3 getRelativeAngularVelocity(const agx::RigidBody* rb) const;
264 
268  agx::Vec3 getRelativeAcceleration(const agx::RigidBody* rb) const;
269 
273  agx::Vec3 getRelativeAngularAcceleration(const agx::RigidBody* rb) const;
274 
278  agx::Vec3 getRelativeVelocity(const agx::ObserverFrame* obs) const;
279 
283  agx::Vec3 getRelativeAngularVelocity(const agx::ObserverFrame* obs) const;
284 
288  agx::Vec3 getRelativeAcceleration(const agx::ObserverFrame* obs) const;
289 
293  agx::Vec3 getRelativeAngularAcceleration(const agx::ObserverFrame* obs) const;
294 
298  agx::Vec3 getRelativePosition(const agx::ObserverFrame* obs) const;
299 
303  agx::Vec3 getRelativePosition(const agx::RigidBody* body) const;
304 
311 
317  void attachWithWorldTransform(agx::RigidBody* rb, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4());
318 
322  void detach();
323 
324  agx::RigidBody* getAttachment() const;
325 
329  agx::Name getName() const;
330 
334  const agx::RigidBody* getRigidBody() const;
335 
339  agx::RigidBody* getRigidBody();
340 
345  void setName( const agx::Name& name );
346 
354  bool setCmAndInertiaInObserver(agx::RigidBody* rb, const agx::SPDMatrix3x3& inertia);
355 
357 
358  protected:
359  friend class DynamicsSystem;
360 
361  virtual ~ObserverFrame();
362 
367  void setSystem( agx::DynamicsSystem* system );
368 
369  private:
371 
372  private:
373  DynamicsSystem* m_mainSystem;
374 
375  FrameRef m_frame;
376  bool m_enabled;
377  agx::Name m_name;
378  agx::RigidBodyRef m_rigidBody;
379  };
380 
382  {
383  return m_enabled;
384  }
385 
387  {
388  return m_enabled;
389  }
390 
392  {
393  return m_frame.get();
394  }
395 
397  {
398  return m_frame.get();
399  }
400 
402  {
403  return m_rigidBody.get();
404  }
405 
407  {
408  return m_rigidBody.get();
409  }
410 
411 } // namespace agx
412 
413 #ifdef _MSC_VER
414 # pragma warning(pop)
415 #endif
416 
417 #endif
void AGXPHYSICS_EXPORT init()
Initialize agx.
bool getEnable() const
Access the state enable flag.
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
#define AGXPHYSICS_EXPORT
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position...
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:248
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:63
const agx::RigidBody * getRigidBody() const
Base class providing referencing counted objects.
Definition: Referenced.h:113
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
Definition: EulerAngles.h:72
Namespace agx contains the dynamics/math part of the AGX Dynamics API.
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:52
bool isEnabled() const
Access the state enable flag.
#define CALLABLE
Definition: Object.h:77
The complete physical system with bodies, interactions, data layout, time stepper, and solver.
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
#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:206
static agx::Vec3 transformVectorToWorld(const agx::Vec3 &v, const agxCollide::Geometry *g)
Transforms a vector given in shape coordinates to world coordinates given geometry g...
Definition: WireUtils.h:57
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
double Real
Definition: Real.h:42
static agx::Vec3 transformPointToWorld(const agx::Vec3 &p, const agxCollide::Geometry *g)
Transforms a point given in shape coordinates to world given geometry g.
Definition: WireUtils.h:81
Specialized types of matrices for holding orthogonal transformation matrices.
AGX_DECLARE_VECTOR_TYPES(Clock)
With this class you can attach an ObserverFrame object relative to a RigidBody.
Definition: ObserverFrame.h:42