AGX Dynamics 2.38.0.2
Loading...
Searching...
No Matches
LookupTables.h
Go to the documentation of this file.
1/*
2Copyright 2007-2024. Algoryx Simulation AB.
3
4All AGX source code, intellectual property, documentation, sample code,
5tutorials, scene files and technical white papers, are copyrighted, proprietary
6and confidential material of Algoryx Simulation AB. You may not download, read,
7store, distribute, publish, copy or otherwise disseminate, use or expose this
8material unless having a written signed agreement with Algoryx Simulation AB, or having been
9advised so by Algoryx Simulation AB for a time limited evaluation, or having purchased a
10valid commercial license from Algoryx Simulation AB.
11
12Algoryx Simulation AB disclaims all responsibilities for loss or damage caused
13from using this software, unless otherwise stated in written agreements with
14Algoryx Simulation AB.
15*/
16
17#ifndef AGX_LOOKUP_TABLES_H
18#define AGX_LOOKUP_TABLES_H
19
21#include <agx/Referenced.h>
22#include <agx/List.h>
25
26namespace agx
27{
30
31
41 {
42 public:
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
80
84 virtual void setValues( RealPairVector const& values );
85
91
92
93 RealPairList::const_iterator getValueIterator() const;
94 RealPairList::const_iterator getValueEndIterator() const;
95
96 protected:
97 virtual ~LookupTable();
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:
123 };
125
126 class Point2D : public agx::Vec3
127 {
128 public:
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
154
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
198
200 protected:
203 };
205
206}
207
208#endif // AGX_LOOKUP_TABLES_H
#define AGXSTREAM_DECLARE_SERIALIZABLE(T)
Use this in a Serializable class to add the required methods Important: Use full namespace in the dec...
#define AGXPHYSICS_EXPORT
This class is an abstract base class for all classes that can be stored and retrieved from an Archive...
Abstract base class for storing/restoring a line/drums with version control.
virtual void add(agx::Real x, agx::Real y, agx::Real dy)
virtual agx::Real evaluateDerivative(agx::Real x)
virtual void clear()
virtual const Point2DVector & getPoints()
virtual agx::Real evaluate(agx::Real x)
Base class for spline interpolation between the inserted variable/value pairs.
CubicFunction2DRef m_spline
virtual void insertValue(const agx::Real x, const agx::Real y) override
insert a value to the lookup table.
virtual void clear() override
clear all data
virtual agx::Real lookupDerivative(const agx::Real x) const
virtual agx::Real lookup(const agx::Real x) const override
Lookup a specific value.
virtual bool store(agxStream::StorageStream &str) const
Stores internal data into stream.
virtual bool restore(agxStream::StorageStream &str)
Restores internal data from stream.
Linear interpolation between the inserted variable/value pairs.
virtual ~LinearLookupTable()
virtual agx::Real lookup(const agx::Real x) const override
Lookup a specific value.
LinearLookupTable()
Constructor.
Return a value of y given any value of x.
virtual agx::Real lookup(const agx::Real x) const =0
Lookup a specific value.
LookupTable()
Create a lookup table.
void setDefaultValue(agx::Real defaultValue)
Set the default return value, if the table has been cleared.
agx::Real getDefaultValue() const
RealPairList m_xyPair
virtual agx::Real resultScalerFunction() const
Scale the found value.
RealPairList::const_iterator getValueIterator() const
virtual void clear()
clear all data
agx::Real m_defaultValue
RealPairList::const_iterator getValueEndIterator() const
virtual ~LookupTable()
virtual void insertValue(const agx::Real x, const agx::Real y)
insert a value to the lookup table.
size_t getNumValues() const
return the number of values in the lookup table
virtual void setValues(RealPairVector const &values)
Set all lookup values at the same time (all previous will be removed.)
Point2D(agx::Real xxx, agx::Real yyy, agx::Real dy)
agx::Real yp()
Point2D(agx::Vec3 point)
Base class providing referencing counted objects.
Definition Referenced.h:120
Templated vector class.
Definition agx/Vector.h:53
Smart pointer for handling referenced counted objects.
Definition ref_ptr.h:30
The agx namespace contains the dynamics/math part of the AGX Dynamics API.
agx::List< std::pair< agx::Real, agx::Real > > RealPairList
agx::Vector< std::pair< agx::Real, agx::Real > > RealPairVector
agx::ref_ptr< LinearLookupTable > LinearLookupTableRef
agx::ref_ptr< CubicFunction2D > CubicFunction2DRef
agx::Vector< Point2D > Point2DVector
double Real
Definition Real.h:42
agx::ref_ptr< CubicSplineLookupTable > CubicSplineLookupTableRef