AGXDynamics  2.35.0.3
ollide/Plane.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_PLANE_H
18 #define AGXCOLLIDE_PLANE_H
19 
20 #include <agx/Vec4.h>
21 #include <agxCollide/Shape.h>
23 
24 namespace agxCollide
25 {
26 
34  class AGXPHYSICS_EXPORT Plane : public Shape
35  {
36  public:
37 
41  Plane();
42 
46  Plane( agx::Real const a, agx::Real const b, agx::Real const c, agx::Real d );
47 
53  Plane( const agx::Vec3 normal, agx::Real d );
54 
60  Plane( const agx::Vec3 normal, const agx::Vec3 point );
61 
62  Plane( const agx::Vec4 plane);
63 
67  Plane( const agx::Vec3 p1, const agx::Vec3 p2, const agx::Vec3 p3);
68 
69  void set( const agx::Vec4& plane );
70  void set(const agx::Vec3& p1, const agx::Vec3& p2, const agx::Vec3& p3);
71 
72  virtual agx::Real getVolume() const override;
73 
74  agx::Vec4 asVec4() const;
75 
77  const agx::Vec3 getNormal() const;
78 
80  agx::Real getDistance() const;
81 
83  void setNormal( const agx::Vec3& normal );
84 
86  void setDistance( agx::Real distance );
87 
88  agx::Vec4 calculatePlane( const agx::AffineMatrix4x4& transform ) const;
89 
93  agx::Real signedDistanceToPoint( const agx::Vec3& point ) const;
94 
95  virtual agx::SPDMatrix3x3 calculateInertia(agx::Real mass) const override;
96  virtual const BoundingAABB& updateBoundingVolume() override;
97  virtual BoundingAABB calculateLocalBound() const override;
98 
99  static BoundingAABB calculateBound(const agx::AffineMatrix4x4& transform, const agx::Plane& plane);
100 
104  virtual Shape *clone() const override;
105 
107 
109 
110  protected:
111  Plane& operator=(const Plane&) { return *this; }
112  virtual ~Plane();
113 
114  private:
115  void init(const agx::Vec3& normal, agx::Real distance);
116  };
117 
118 
119  /* Implementation */
121 
124 
126  {
127  return ( getNormal() * point ) + getDistance();
128  }
129 
130 
132  {
133  BoundingAABB localbound;
134 
135  localbound.max() = agx::Vec3( agx::RealMax - 1, agx::RealMax - 1, agx::RealMax - 1 );
136  localbound.min() = agx::Vec3( -agx::RealMax + 1, -agx::RealMax + 1, -agx::RealMax + 1 );
137 
138  /*
139  Disabled, until #1935 is fixed.
140 
141  // make bounding box smaller in case the normal is aligned to natural axis
142  for (int i = 0; i < 3; ++i) {
143  if (plane.getNormal()[i] == 1) {
144  localbound.max[i] = -plane.getDistance();
145  break;
146  }
147  else if (plane.getNormal()[i] == -1) {
148  localbound.min[i] = -plane.getDistance();
149  break;
150  }
151  }
152  */
153 
154  return BoundingAABB(localbound, transform);
155  }
156 }
157 
158 
159 #endif
Shape.h
agx::PlaneT::getNormal
agx::Vec3T< T > getNormal() const
/return The normal of the plane.
Definition: Plane.h:191
agx::Real
double Real
Definition: Real.h:42
agxCollide::Plane::operator=
Plane & operator=(const Plane &)
Definition: ollide/Plane.h:111
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.
agxCollide::Plane::getDistance
agx::Real getDistance() const
Get the distance d (from plane equation ax+by+cz+d=0).
Definition: ollide/Plane.h:123
agxCollide::Plane::getEntity
agx::Physics::Geometry::PlanePtr getEntity() const
Definition: ollide/Plane.h:120
agxCollide::Plane::getNormal
const agx::Vec3 getNormal() const
Get the normal (a, b, c) from plane equation ax+by+cz+d=0.
Definition: ollide/Plane.h:122
agxCollide::Plane
Definition: ollide/Plane.h:34
agx::AffineMatrix4x4T< Real >
agx::RealMax
const AGXCORE_EXPORT Real RealMax
agx::Vec4T
A class holding 4 dimensional vectors and providing basic arithmetic.
Definition: Vec4Template.h:34
agxCollide::Plane::calculateBound
static BoundingAABB calculateBound(const agx::AffineMatrix4x4 &transform, const agx::Plane &plane)
Definition: ollide/Plane.h:131
agxCollide::BoundingAABB
Axis aligned bounding box implementation.
Definition: BoundingAABB.h:37
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
agxCollide::Shape::m_entity
agx::Physics::Geometry::ShapeRef m_entity
Definition: Shape.h:266
AGXPHYSICS_EXPORT
#define AGXPHYSICS_EXPORT
Vec4.h
agx::PlaneT
Class representing the mathematical concept of a plane, also called a half- space.
Definition: Plane.h:31
agxCollide::Shape
Base class for a shape.
Definition: Shape.h:53
agx::PlaneT::getDistance
T getDistance() const
Definition: Plane.h:194
agx::Vec3
Vec3T< Real > Vec3
The object holding 3 dimensional vectors and providing basic arithmetic.
Definition: Vec3.h:36
agx::BoundT::max
const T & max() const
Definition: Bound.h:255
agx::BoundT::min
const T & min() const
Definition: Bound.h:252
agx::SPDMatrix3x3
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:48
agxCollide
This namespace consists of a set of classes for handling geometric intersection tests including boole...
Definition: ContactForceFilterParticipant.h:22
agxCollide::AGX_DECLARE_POINTER_TYPES
AGX_DECLARE_POINTER_TYPES(SpaceListener)
agx::init
void AGXPHYSICS_EXPORT init()
Initialize agx.
agx::Physics::Geometry::PlanePtr::plane
AGXPHYSICS_EXPORT agx::Plane & plane()
agx::Vec3T< Real >
agx::Physics::Geometry::PlanePtr
Pointer to a entity instance of type Physics.Geometry.Plane.
Definition: PlaneEntity.h:160
PlaneEntity.h
AGX_FORCE_INLINE
#define AGX_FORCE_INLINE
Definition: macros.h:58
agx::Plane
PlaneT< agx::Real > Plane
Definition: Plane.h:121
agxCollide::Plane::signedDistanceToPoint
agx::Real signedDistanceToPoint(const agx::Vec3 &point) const
Calculates the distance from the plane to a point.
Definition: ollide/Plane.h:125
agxData::getEntity
AGXCORE_EXPORT EntityModel * getEntity(const agx::Path &path)
Get a entity with a specified path.