AGX Dynamics  2.35.0.1
RegressionPlane.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 AGX_REGRESSIONPLANE_H
18 #define AGX_REGRESSIONPLANE_H
19 
20 #include <agx/agx_vector_types.h>
21 #include <agx/Referenced.h>
22 
23 #include <agx/agxPhysics_export.h>
24 #include <agx/Plane.h>
25 
26 #include <agxData/LocalVector.h>
27 
28 namespace agx {
29  class SPDMatrix3x3;
30 }
31 
32 namespace agxCollide {
33 
40  {
41 
42  public:
48  PLANE
49  };
50 
66 
78  RegressionPlane ( const agx::Vec3& linearCoefficients,
79  const agx::SPDMatrix3x3& quadraticCoefficients,
80  const agx::Vec3& averagePoint,
81  const size_t numPoints);
82 
85 
90  agx::Vec3 getAveragePoint() const;
91 
96  agx::Vec3 getLineDirection() const;
97 
102  agx::Plane getPlane() const;
103 
105  bool isPlane() const;
106 
108  agx::Real getMaxDeterminant() const;
109 
110  private:
111  RegressionPlane();
112 
113 
114  void computeRegressionPlane (
115  agx::Vec3 linearCoefficients,
116  agx::SPDMatrix3x3 quadraticCoefficients,
117  size_t numPoints);
118 
119  private:
120  agx::Plane m_plane;
121  agx::Vec3 m_averagePoint;
122  agx::Vec3 m_lineDirection;
123  DimensionType m_dimensionType;
124 
125  agx::Real m_maxDeterminant;
126  };
127 
128 
129 
130  // implementations
132  {
133  return m_dimensionType;
134  }
135 
137  {
138  return m_maxDeterminant;
139  }
140 
141 
143  {
144  agxAssert ( m_dimensionType != RegressionPlane::EMPTY );
145  return m_averagePoint;
146  }
147 
148 
150  {
151  agxAssert ( m_dimensionType > RegressionPlane::POINT );
152  return m_lineDirection;
153  }
154 
155 
157  {
158  agxAssert ( m_dimensionType == RegressionPlane::PLANE );
159  return m_plane;
160  }
161 
162 
164  {
165  return m_dimensionType == PLANE;
166  }
167 }
168 
169 
170 #endif
#define AGXPHYSICS_EXPORT
A plane created from points using least squares minimization.
agx::Real getMaxDeterminant() const
Returns the maximum determinant from the least squares minimization.
bool isPlane() const
Is the regression plane a plane (and not empty, point or line)?
agx::Vec3 getLineDirection() const
Gets the average point of the plane.
RegressionPlane(const agx::Vec3 &linearCoefficients, const agx::SPDMatrix3x3 &quadraticCoefficients, const agx::Vec3 &averagePoint, const size_t numPoints)
Creates a RegressionPlane from the coefficients precomputed from a number of 3D points.
DimensionType
Dimension type of the sub-space resulted by the regression.
agx::Plane getPlane() const
Gets the average point of the plane.
RegressionPlane(const agx::Vec3Vector &points)
DimensionType getDimensionType() const
Gets the dimension type of the plane.
agx::Vec3 getAveragePoint() const
Gets the average point of the plane.
RegressionPlane(const agxData::LocalVector< agx::Vec3 > &points)
Creates a RegressionPlane from a number of 3D-points.
Local scope vector.
Definition: LocalVector.h:44
Class representing the mathematical concept of a plane, also called a half- space.
Definition: agx/Plane.h:32
Specialized type of matrices for holding symmetric positive definite matrices.
Definition: SPDMatrix3x3.h:49
#define agxAssert(expr)
Definition: debug.h:143
#define AGX_FORCE_INLINE
Definition: macros.h:58
This namespace consists of a set of classes for handling geometric intersection tests including boole...
AGXMODEL_EXPORT agxPowerLine::PhysicalDimension::Type getDimensionType(const std::string &dimensionName)
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
double Real
Definition: Real.h:42