AGX Dynamics  2.38.0.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 
35 
36 
42  {
43  public:
44 
45 
46  public:
53  ObserverFrame( const agx::Name& name = "", agx::RigidBody* body = nullptr, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4());
60 
66  agx::Frame* getFrame();
67 
73  const agx::Frame* getFrame() const;
74 
82  void setTransform( const agx::AffineMatrix4x4& matrix );
83 
87  const agx::AffineMatrix4x4& getLocalTransform() const;
88 
93  void setLocalTransform( const agx::AffineMatrix4x4& matrix );
94 
98  agx::Vec3 getLocalPosition() const;
99 
104  void setLocalPosition( const agx::Vec3& p );
105 
112  void setLocalPosition( agx::Real x, agx::Real y, agx::Real z );
113 
118  void setRotation( const agx::Quat& q );
119 
124  void setRotation( const agx::EulerAngles& e);
125 
130  void setRotation( const agx::OrthoMatrix3x3& m );
131 
135  agx::Quat getLocalRotation() const;
136 
141  void setLocalRotation( const agx::Quat& q );
142 
147  void setLocalRotation( const agx::EulerAngles& e );
148 
152  agx::Frame* getParentFrame();
153 
157  const agx::Frame* getParentFrame() const;
158 
168  bool setParentFrame( agx::Frame* frame );
169 
174  void setPosition( const agx::Vec3& p );
175 
182  void setPosition( agx::Real x, agx::Real y, agx::Real z );
183 
189  void setEnable( bool enable );
190 
195  bool getEnable() const;
196 
201  bool isEnabled() const;
202 
206  agx::DynamicsSystem* getSystem();
207 
211  const agx::DynamicsSystem* getSystem() const;
212 
213 
218  agx::Vec3 getPosition() const;
219 
224  agx::Quat getRotation() const;
225 
229  agx::Vec3 transformVectorToWorld(const agx::Vec3& vectorLocal) const;
230 
234  agx::Vec3 transformVectorToLocal(const agx::Vec3& vectorWorld) const;
235 
239  agx::Vec3 transformPointToWorld(const agx::Vec3& pointLocal) const;
240 
244  agx::Vec3 transformPointToLocal(const agx::Vec3& pointWorld) const;
245 
249  agx::Vec3 getVelocity() const;
250 
254  agx::Vec3 getAngularVelocity() const;
255 
259  agx::Vec3 getAcceleration() const;
260 
264  agx::Vec3 getAngularAcceleration() const;
265 
269  agx::Vec3 getRelativeVelocity(const agx::RigidBody* body) const;
270 
274  agx::Vec3 getRelativeAngularVelocity(const agx::RigidBody* body) const;
275 
279  agx::Vec3 getRelativeAcceleration(const agx::RigidBody* body) const;
280 
284  agx::Vec3 getRelativeAngularAcceleration(const agx::RigidBody* body) const;
285 
289  agx::Vec3 getRelativeVelocity(const agx::ObserverFrame* obs) const;
290 
294  agx::Vec3 getRelativeAngularVelocity(const agx::ObserverFrame* obs) const;
295 
299  agx::Vec3 getRelativeAcceleration(const agx::ObserverFrame* obs) const;
300 
304  agx::Vec3 getRelativeAngularAcceleration(const agx::ObserverFrame* obs) const;
305 
309  agx::Vec3 getRelativePosition(const agx::ObserverFrame* obs) const;
310 
314  agx::Vec3 getRelativePosition(const agx::RigidBody* body) const;
315 
319  agx::Quat getRelativeRotation(const agx::ObserverFrame* obs) const;
320 
324  agx::Quat getRelativeRotation(const agx::RigidBody* body) const;
325 
331  void attach(agx::RigidBody* body, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4());
332 
338  void attachWithWorldTransform(agx::RigidBody* body, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4());
339 
343  void detach();
344 
345  agx::RigidBody* getAttachment() const;
346 
350  agx::Name getName() const;
351 
355  const agx::RigidBody* getRigidBody() const;
356 
360  agx::RigidBody* getRigidBody();
361 
366  void setName( const agx::Name& name );
367 
375  bool setCmAndInertiaInObserver(agx::RigidBody* body, const agx::SPDMatrix3x3& inertia);
376 
378 
379  protected:
380  friend class DynamicsSystem;
381 
382  virtual ~ObserverFrame();
383 
388  void setSystem( agx::DynamicsSystem* system );
389 
390  private:
391  void init(const agx::Name& name, agx::RigidBody* body, const agx::AffineMatrix4x4& transform = agx::AffineMatrix4x4() );
392 
393  private:
394  DynamicsSystem* m_mainSystem;
395 
396  FrameRef m_frame;
397  bool m_enabled;
398  agx::Name m_name;
399  agx::RigidBodyRef m_rigidBody;
400  };
401 
403  {
404  return m_enabled;
405  }
406 
408  {
409  return m_enabled;
410  }
411 
413  {
414  return m_frame.get();
415  }
416 
418  {
419  return m_frame.get();
420  }
421 
423  {
424  return m_rigidBody.get();
425  }
426 
428  {
429  return m_rigidBody.get();
430  }
431 
432 } // namespace agx
433 
434 #ifdef _MSC_VER
435 # pragma warning(pop)
436 #endif
437 
agxWire::transformPointToWorld
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
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::OrthoMatrix3x3
Specialized types of matrices for holding orthogonal transformation matrices.
Definition: OrthoMatrix3x3.h:33
agx::ObserverFrame::getEnable
bool getEnable() const
Access the state enable flag.
Definition: ObserverFrame.h:402
agx::RigidBody
The rigid body class, combining a geometric model and a frame of reference.
Definition: RigidBody.h:51
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
CALLABLE
#define CALLABLE
Definition: macros.h:72
agx::AffineMatrix4x4T< Real >
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_DECLARE_VECTOR_TYPES
#define AGX_DECLARE_VECTOR_TYPES(type)
Definition: Vector.h:34
agx::ObserverFrame
With this class you can attach an ObserverFrame object relative to a RigidBody.
Definition: ObserverFrame.h:41
agx::ref_ptr< Frame >
agx::SetVector< ObserverFrameRef >
agx::ObserverFrame::getRigidBody
const agx::RigidBody * getRigidBody() const
Definition: ObserverFrame.h:422
agx::Name
Representation of a name string.
Definition: Name.h:32
agx::ObserverFrame::getFrame
agx::Frame * getFrame()
Returns the model frame containing model the transformation and utilities to manipulate position,...
Definition: ObserverFrame.h:412
Frame.h
agx::SPDMatrix3x3
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
agx::EulerAngles
This class provides conversion services between Euler angles in any of the 24 conventions and corresp...
Definition: EulerAngles.h:69
agx::QuatT< Real >
agx.h
RigidBody.h
agx::Referenced
Base class providing referencing counted objects.
Definition: Referenced.h:119
AGX_DECLARE_POINTER_TYPES
#define AGX_DECLARE_POINTER_TYPES(type)
Definition: Referenced.h:254
agx::init
void AGXPHYSICS_EXPORT init()
Initialize AGX Dynamics API including thread resources and must be executed before using the AGX API.
agx::Vec3T< Real >
agx::ObserverFrameRefSetVector
agx::SetVector< ObserverFrameRef > ObserverFrameRefSetVector
Definition: ObserverFrame.h:34
agx::DynamicsSystem
The complete physical system with bodies, interactions, data layout, time stepper,...
Definition: DynamicsSystem.h:63
agx::Frame
The object defining a frame of reference and providing transformations operations.
Definition: Frame.h:67
agxWire::transformVectorToWorld
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
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::ref_ptr::get
T * get() const
Definition: ref_ptr.h:256
agx::ObserverFrame::isEnabled
bool isEnabled() const
Access the state enable flag.
Definition: ObserverFrame.h:407