AGX Dynamics  2.37.3.2
ObserverFrame.h
Go to the documentation of this file.
1 /*
2 Copyright 2007-2024. 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 #pragma once
18 
19 #include <agx/agx.h>
20 #include <agx/RigidBody.h>
21 #include <agx/Frame.h>
22 
23 #ifdef _MSC_VER
24 # pragma warning(push)
25 # pragma warning(disable:4355) //Disable 'this' : used in base member initializer list warning
26 #endif
27 
28 namespace agx
29 {
30  class DynamicsSystem;
31  class AutoSleep;
32  class MergeSplitBodyStorage;
33 
37 
38 
44  {
45  public:
46 
47 
48  public:
55  ObserverFrame( const agx::Name& name = "", agx::RigidBody* rb = nullptr, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4());
62 
68  agx::Frame* getFrame();
69 
75  const agx::Frame* getFrame() const;
76 
84  void setTransform( const agx::AffineMatrix4x4& matrix );
85 
89  const agx::AffineMatrix4x4& getLocalTransform() const;
90 
95  void setLocalTransform( const agx::AffineMatrix4x4& matrix );
96 
100  agx::Vec3 getLocalPosition() const;
101 
106  void setLocalPosition( const agx::Vec3& p );
107 
114  void setLocalPosition( agx::Real x, agx::Real y, agx::Real z );
115 
120  void setRotation( const agx::Quat& q );
121 
126  void setRotation( const agx::EulerAngles& e);
127 
132  void setRotation( const agx::OrthoMatrix3x3& m );
133 
137  agx::Quat getLocalRotation() const;
138 
143  void setLocalRotation( const agx::Quat& q );
144 
149  void setLocalRotation( const agx::EulerAngles& e );
150 
154  agx::Frame* getParentFrame();
155 
159  const agx::Frame* getParentFrame() const;
160 
170  bool setParentFrame( agx::Frame* frame );
171 
176  void setPosition( const agx::Vec3& p );
177 
184  void setPosition( agx::Real x, agx::Real y, agx::Real z );
185 
191  void setEnable( bool enable );
192 
197  bool getEnable() const;
198 
203  bool isEnabled() const;
204 
208  agx::DynamicsSystem* getSystem();
209 
213  const agx::DynamicsSystem* getSystem() const;
214 
215 
220  agx::Vec3 getPosition() const;
221 
226  agx::Quat getRotation() const;
227 
231  agx::Vec3 transformVectorToWorld(const agx::Vec3& vectorLocal) const;
232  agx::Vec3 transformVectorToLocal(const agx::Vec3& vectorWorld) const;
233  agx::Vec3 transformPointToWorld(const agx::Vec3& pointLocal) const;
234  agx::Vec3 transformPointToLocal(const agx::Vec3& pointWorld) const;
235 
239  agx::Vec3 getVelocity() const;
240 
244  agx::Vec3 getAngularVelocity() const;
245 
249  agx::Vec3 getAcceleration() const;
250 
254  agx::Vec3 getAngularAcceleration() const;
255 
259  agx::Vec3 getRelativeVelocity(const agx::RigidBody* rb) const;
260 
264  agx::Vec3 getRelativeAngularVelocity(const agx::RigidBody* rb) const;
265 
269  agx::Vec3 getRelativeAcceleration(const agx::RigidBody* rb) const;
270 
274  agx::Vec3 getRelativeAngularAcceleration(const agx::RigidBody* rb) const;
275 
279  agx::Vec3 getRelativeVelocity(const agx::ObserverFrame* obs) const;
280 
284  agx::Vec3 getRelativeAngularVelocity(const agx::ObserverFrame* obs) const;
285 
289  agx::Vec3 getRelativeAcceleration(const agx::ObserverFrame* obs) const;
290 
294  agx::Vec3 getRelativeAngularAcceleration(const agx::ObserverFrame* obs) const;
295 
299  agx::Vec3 getRelativePosition(const agx::ObserverFrame* obs) const;
300 
304  agx::Vec3 getRelativePosition(const agx::RigidBody* body) const;
305 
312 
318  void attachWithWorldTransform(agx::RigidBody* rb, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4());
319 
323  void detach();
324 
325  agx::RigidBody* getAttachment() const;
326 
330  agx::Name getName() const;
331 
335  const agx::RigidBody* getRigidBody() const;
336 
340  agx::RigidBody* getRigidBody();
341 
346  void setName( const agx::Name& name );
347 
355  bool setCmAndInertiaInObserver(agx::RigidBody* rb, const agx::SPDMatrix3x3& inertia);
356 
358 
359  protected:
360  friend class DynamicsSystem;
361 
362  virtual ~ObserverFrame();
363 
368  void setSystem( agx::DynamicsSystem* system );
369 
370  private:
372 
373  private:
374  DynamicsSystem* m_mainSystem;
375 
376  FrameRef m_frame;
377  bool m_enabled;
378  agx::Name m_name;
379  agx::RigidBodyRef m_rigidBody;
380  };
381 
383  {
384  return m_enabled;
385  }
386 
388  {
389  return m_enabled;
390  }
391 
393  {
394  return m_frame.get();
395  }
396 
398  {
399  return m_frame.get();
400  }
401 
403  {
404  return m_rigidBody.get();
405  }
406 
408  {
409  return m_rigidBody.get();
410  }
411 
412 } // namespace agx
413 
414 #ifdef _MSC_VER
415 # pragma warning(pop)
416 #endif
417 
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API...
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:254
Representation of a name string.
Definition: Name.h:32
#define AGX_FORCE_INLINE
Definition: Object.h:59
const agx::RigidBody * getRigidBody() const
Base class providing referencing counted objects.
Definition: Referenced.h:119
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
Definition: EulerAngles.h:69
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
agx::SetVector< ObserverFrameRef > ObserverFrameRefSetVector
Definition: ObserverFrame.h:36
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:54
bool isEnabled() const
Access the state enable flag.
#define CALLABLE
Definition: Object.h:73
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:207
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
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
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.
With this class you can attach an ObserverFrame object relative to a RigidBody.
Definition: ObserverFrame.h:43