AGX Dynamics  2.35.0.1
agxCollide/Line.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 AGXCOLLIDE_LINE_H
18 #define AGXCOLLIDE_LINE_H
19 
20 #include <agx/agxPhysics_export.h>
21 #include <agx/SPDMatrix3x3.h>
23 #include <agxCollide/Shape.h>
24 #include <agxStream/Serializable.h>
25 
26 namespace agxCollide
27 {
55  class AGXPHYSICS_EXPORT Line : public Shape
56  {
57  public:
63  Line( const agx::Vec3 p1, const agx::Vec3 p2 );
64 
69  virtual agx::Real getVolume() const override;
70 
75  void setFirstPoint( const agx::Vec3& p );
76 
81  void setSecondPoint( const agx::Vec3& p );
82 
88  void set(const agx::Vec3& p1, const agx::Vec3& p2);
89 
91  agx::Vec3 getFirstPoint() const;
92 
94  agx::Vec3 getSecondPoint() const;
95 
100  virtual bool hasSupportFunction() const override;
101 
107  virtual agx::Vec3 getSupportPoint( const agx::Vec3& supportDirection ) const override;
108 
114  virtual agx::SPDMatrix3x3 calculateInertia(agx::Real mass) const override;
115 
120  virtual const BoundingAABB& updateBoundingVolume() override;
121 
126  virtual BoundingAABB calculateLocalBound() const override;
127 
135  static BoundingAABB calculateBound(const agx::AffineMatrix4x4& transform, const agx::Vec3& firstPoint, const agx::Vec3& secondPoint);
136 
138 
140 
141  protected:
142  virtual ~Line( void );
143  Line() : Shape(LINE, agx::Physics::Geometry::LineModel::createInstance()) {}
144  };
145 
146 
147  /* Implementation */
149  {
150  return m_entity;
151  }
152 
154  {
155  return getEntity().line().p1;
156  }
157 
159  {
160  return getEntity().line().p2;
161  }
162 
164  {
165  BoundingAABB bound;
166  const agx::Vec3 p0 = firstPoint * transform;
167  const agx::Vec3 p1 = secondPoint * transform;
168  bound.min() = agx::Vec3::componentMin(p0, p1);
169  bound.max() = agx::Vec3::componentMax(p0, p1);
170  return bound;
171  }
172 }
173 
174 #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
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:38
The geometry representation used by the collision detection engine.
Definition: Geometry.h:93
A line shape for intersection tests, mostly for depth sensing and picking.
virtual ~Line(void)
agx::Vec3 getFirstPoint() const
Returns the first point, in local coordinates.
static BoundingAABB calculateBound(const agx::AffineMatrix4x4 &transform, const agx::Vec3 &firstPoint, const agx::Vec3 &secondPoint)
Calculate a bounding volume for line shape from parameters.
Line(const agx::Vec3 p1, const agx::Vec3 p2)
Constructor.
virtual agx::Real getVolume() const override
Volume of line-shape, will return 0.0 for line objects.
void set(const agx::Vec3 &p1, const agx::Vec3 &p2)
Set first and second point, in local coordinates.
virtual const BoundingAABB & updateBoundingVolume() override
Update the bounding volume for shape.
void setFirstPoint(const agx::Vec3 &p)
Set first point (start point), in local coordinates.
virtual agx::Vec3 getSupportPoint(const agx::Vec3 &supportDirection) const override
Gets support point.
virtual bool hasSupportFunction() const override
Checks if line shape has support function, will return true for line object.
virtual BoundingAABB calculateLocalBound() const override
Calculate a local bounding volume for shape.
agx::Vec3 getSecondPoint() const
Returns the second point, in local coordinates.
void setSecondPoint(const agx::Vec3 &p)
Set second point (end point), in local coordinates.
agx::Physics::Geometry::LinePtr getEntity() const
virtual agx::SPDMatrix3x3 calculateInertia(agx::Real mass) const override
Calculate inertia for line shape, will return identity matrix for line object.
Base class for a shape.
Definition: Shape.h:54
agx::Physics::Geometry::ShapeRef m_entity
Definition: Shape.h:266
const T & min() const
Definition: Bound.h:252
const T & max() const
Definition: Bound.h:255
Pointer to a entity instance of type Physics.Geometry.Line.
Definition: LineEntity.h:161
AGXPHYSICS_EXPORT agx::Line & line()
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:49
static Vec3T componentMax(const Vec3T &v1, const Vec3T &v2)
Creates a new vector where each component is the maximum of this and the other vector.
Definition: Vec3Template.h:391
static Vec3T componentMin(const Vec3T &v1, const Vec3T &v2)
Creates a new vector where each component is the minimum of this and the other vector.
Definition: Vec3Template.h:385
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
AGX_DECLARE_POINTER_TYPES(SpaceListener)
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.
void AGXCORE_EXPORT transform(void *target, const Format *targetFormat, const void *source, const Format *sourceFormat, size_t numElements)
Transform data between two buffers.
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:42