AGXDynamics  2.31.1.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ollide/Line.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 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
agx::Physics::Geometry::ShapeRef m_entity
Definition: Shape.h:265
T p2
Definition: Line.h:32
static BoundingAABB calculateBound(const agx::AffineMatrix4x4 &transform, const agx::Vec3 &firstPoint, const agx::Vec3 &secondPoint)
Calculate a bounding volume for line shape from parameters.
Definition: ollide/Line.h:163
Base class for a shape.
Definition: Shape.h:53
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
#define AGX_FORCE_INLINE
Definition: Object.h:62
agx::Physics::Geometry::LinePtr getEntity() const
Definition: ollide/Line.h:148
AGXPHYSICS_EXPORT agx::Line & line()
A line shape for intersection tests, mostly for depth sensing and picking.
Definition: ollide/Line.h:55
The geometry representation used by the collision detection engine.
Definition: Geometry.h:88
const T & max() const
Definition: Bound.h:255
T p1
Definition: Line.h:31
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
Pointer to a entity instance of type Physics.Geometry.Line.
Definition: LineEntity.h:160
agx::Vec3 getFirstPoint() const
Returns the first point, in local coordinates.
Definition: ollide/Line.h:153
agx::Vec3 getSecondPoint() const
Returns the second point, in local coordinates.
Definition: ollide/Line.h:158
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.
#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
double Real
Definition: Real.h:42
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:37
const T & min() const
Definition: Bound.h:252
LineT< Vec3 > Line
Definition: Line.h:39
AGX_DECLARE_POINTER_TYPES(SpaceListener)
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.
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.