AGX Dynamics  2.37.2.0
LookupTables.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 #ifndef AGX_LOOKUP_TABLES_H
18 #define AGX_LOOKUP_TABLES_H
19 
20 #include <agx/agxPhysics_export.h>
21 #include <agx/Referenced.h>
22 #include <agx/List.h>
23 #include <agxStream/Serializable.h>
25 
26 namespace agx
27 {
30 
31 
41  {
42  public:
46  LookupTable();
47 
51  virtual void clear();
52 
58  virtual void insertValue( const agx::Real x, const agx::Real y );
59 
63  size_t getNumValues() const;
64 
65 
69  virtual agx::Real lookup( const agx::Real x ) const = 0;
70 
74  void setDefaultValue( agx::Real defaultValue );
75 
79  agx::Real getDefaultValue() const;
80 
84  virtual void setValues( RealPairVector const& values );
85 
90  virtual agx::Real resultScalerFunction() const;
91 
92 
93  RealPairList::const_iterator getValueIterator() const;
94  RealPairList::const_iterator getValueEndIterator() const;
95 
96  protected:
97  virtual ~LookupTable();
99  RealPairList m_xyPair;
100  };
101 
102 
107  class AGXPHYSICS_EXPORT LinearLookupTable : virtual public LookupTable // virtual inheritance due to diamond
108  {
109  public:
114 
118  virtual agx::Real lookup( const agx::Real x ) const override;
119 
121  protected:
122  virtual ~LinearLookupTable();
123  };
125 
126  class Point2D : public agx::Vec3
127  {
128  public:
129  Point2D() {}
131  {
132  x() = xxx;
133  y() = yyy;
134  z() = dy;
135  }
137  {
138  x() = point.x();
139  y() = point.y();
140  z() = point.z();
141  }
142  agx::Real yp() { return z(); }
143  };
145 
147  {
148  public:
150 
151  virtual void add(agx::Real x, agx::Real y, agx::Real dy);
152 
153  virtual agx::Real evaluate(agx::Real x);
154 
155  virtual agx::Real evaluateDerivative(agx::Real x);
156 
157  virtual void clear() { m_points.clear(); }
158 
159  virtual const Point2DVector& getPoints() { return m_points; }
160 
162 
163  private:
164  Point2DVector::iterator getIteratorAfter(const agx::Real x);
165  Point2DVector m_points;
166  };
168 
173  {
174  public:
176 
180  virtual agx::Real lookup(const agx::Real x) const override;
181 
182  virtual agx::Real lookupDerivative(const agx::Real x) const;
183 
184  virtual void insertValue(const agx::Real x, const agx::Real y) override;
185 
186  virtual void clear() override;
187 
188 
192  virtual bool store(agxStream::StorageStream& str) const;
193 
197  virtual bool restore(agxStream::StorageStream& str);
198 
200  protected:
202  CubicFunction2DRef m_spline;
203  };
205 
206 }
207 
208 #endif // AGX_LOOKUP_TABLES_H
AGXTERRAIN_EXPORT void clear()
agx::ref_ptr< CubicSplineLookupTable > CubicSplineLookupTableRef
Definition: LookupTables.h:204
agx::ref_ptr< LinearLookupTable > LinearLookupTableRef
Definition: LookupTables.h:124
Linear interpolation between the inserted variable/value pairs.
Definition: LookupTables.h:107
#define AGXPHYSICS_EXPORT
Point2D(agx::Real xxx, agx::Real yyy, agx::Real dy)
Definition: LookupTables.h:130
Base class for spline interpolation between the inserted variable/value pairs.
Definition: LookupTables.h:172
Base class providing referencing counted objects.
Definition: Referenced.h:119
Templated vector class.
Definition: Vector.h:52
Point2D(agx::Vec3 point)
Definition: LookupTables.h:136
agx::List< std::pair< agx::Real, agx::Real > > RealPairList
Definition: LookupTables.h:28
agx::ref_ptr< CubicFunction2D > CubicFunction2DRef
Definition: LookupTables.h:167
virtual void clear()
Definition: LookupTables.h:157
Return a value of y given any value of x.
Definition: LookupTables.h:40
agx::Real yp()
Definition: LookupTables.h:142
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::Vector< std::pair< agx::Real, agx::Real > > RealPairVector
Definition: LookupTables.h:29
RealPairList m_xyPair
Definition: LookupTables.h:99
Abstract base class for storing/restoring a line/drums with version control.
Definition: StorageStream.h:48
#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
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Definition: Serializable.h:44
double Real
Definition: Real.h:42
virtual const Point2DVector & getPoints()
Definition: LookupTables.h:159
agx::Real m_defaultValue
Definition: LookupTables.h:98
CubicFunction2DRef m_spline
Definition: LookupTables.h:202
agx::Vector< Point2D > Point2DVector
Definition: LookupTables.h:144