Project Chrono: chrono::ChFunctionInterp Class Reference

Public Member Functions | List of all members
chrono::ChFunctionInterp Class Reference
Chrono::Engine » Function objects

## Description

Interpolation function:

Linear interpolation y=f(x) given a list of points (x,y).

`#include <ChFunctionInterp.h>`

Inheritance diagram for chrono::ChFunctionInterp:
[legend]
Collaboration diagram for chrono::ChFunctionInterp:
[legend]

## Public Member Functions
| ChFunctionInterp (const ChFunctionInterp &other)
virtual ChFunctionInterp * | Clone () const override
| "Virtual" copy constructor (covariant return type).
virtual Type | GetType () const override
| Return the unique function type identifier.
virtual double | GetVal (double x) const override
| Return the function output for input x.
virtual double | GetDer (double x) const override
| Return the first derivative of the function.
virtual double | GetDer2 (double x) const override
| Return the second derivative of the function.
void | AddPoint (double x, double y, bool overwrite_if_existing=false)
| Add a point to the table.
void | Reset ()
const std::map< double, double > & | GetTable ()
| Retrieve the underlying table of points.
double | GetStart () const
| Return the smallest value of x in the table.
double | GetEnd () const
| Return the biggest value of x in the table.
void | SetExtrapolate (bool extrapolate)
| Enable linear extrapolation.
virtual void | ArchiveOut (ChArchiveOut &archive_out) override
| Method to allow serialization of transient data to archives.
virtual void | ArchiveIn (ChArchiveIn &archive_in) override
| Method to allow de-serialization of transient data from archives.
Public Member Functions inherited from chrono::ChFunction
| ChFunction (const ChFunction &other)
virtual double | GetDer3 (double x) const
| Return the third derivative of the function.
virtual double | GetDerN (double x, int der_order) const
| Return the Nth derivative of the function (up to 3rd derivative).
virtual double | GetWeight (double x) const
| Return the weight of the function (useful for applications where you need to mix different weighted ChFunctions).
virtual void | Update (double x)
| Update could be implemented by children classes, ex. to launch callbacks.
virtual double | GetMax (double xmin, double xmax, double sampling_step, int der_order) const
| Estimate the maximum of the function (or its der_order derivative) in the range [xmin, xmax], using sampling method.
virtual double | GetMin (double xmin, double xmax, double sampling_step, int der_order) const
| Estimate the minimum of the function (or its der_order derivative) in the range [xmin, xmax], using sampling method.
virtual double | GetMean (double xmin, double xmax, double sampling_step, int der_order) const
| Estimate the mean of the function (or its der_order derivative) in the range [xmin, xmax], using sampling method.
virtual double | GetSquaredMean (double xmin, double xmax, double sampling_step, int der_order) const
| Estimate the squared mean of the function (or its der_order derivative) in the range [xmin, xmax], using sampling method.
virtual double | GetIntegral (double xmin, double xmax, double sampling_step, int der_order) const
| Estimate the integral of the function (or its der_order derivative) over the range [xmin, xmax], using sampling method.
virtual double | GetPositiveAccelerationCoeff () const
| Computes the positive acceleration coefficient (inherited classes should override this).
virtual double | GetNegativeAccelerationCoeff () const
| Compute the negative acceleration coefficient (inherited classes should override this).
virtual double | GetVelocityCoefficient () const
| Compute the velocity coefficient (inherited classes must override this).
virtual void | OutputToASCIIFile (std::ostream &file, double xmin, double xmax, int samples, char delimiter)
| Store X-Y pairs to an ASCII File.
virtual ChMatrixDynamic | SampleUpToDerN (double xmin, double xmax, double step, int derN=0)
| Sample function on given interval [xmin, xmax], up to derN derivative (0 being the function ouput itself).
double | operator() (double arg) const
| Alias operator of the GetVal function.

## Additional Inherited Members
Public Types inherited from chrono::ChFunction
enum class | Type { BSPLINE , CONSTANT , CONSTACC , CONSTJERK , CUSTOM , CYCLOIDAL , DERIVATIVE , FILLET3 , INTEGRAL , INTERP , LAMBDA , MIRROR , OPERATOR , POLY , POLY23 , POLY345 , RAMP , REPEAT , SEQUENCE , SINE , SINE_STEP }
| Enumeration of function types.

## Member Function Documentation

## ◆ AddPoint()

void chrono::ChFunctionInterp::AddPoint | ( | double | x,
|  | double | y,
|  | bool | overwrite_if_existing = false )

Add a point to the table.

By default, adding a point with an x value that already exists in the table will lead to an exception. If overwrite_if_existing is set to `true`, the existing point will be overwritten instead.

## ◆ ArchiveIn()

void chrono::ChFunctionInterp::ArchiveIn | ( | ChArchiveIn & | archive_in | ) |
| overridevirtual

Method to allow de-serialization of transient data from archives.

Reimplemented from chrono::ChFunction.

## ◆ ArchiveOut()

void chrono::ChFunctionInterp::ArchiveOut | ( | ChArchiveOut & | archive_out | ) |
| overridevirtual

Method to allow serialization of transient data to archives.

Reimplemented from chrono::ChFunction.

## ◆ Clone()

virtual ChFunctionInterp * chrono::ChFunctionInterp::Clone | ( |  | ) | const
| inlineoverridevirtual

"Virtual" copy constructor (covariant return type).

Implements chrono::ChFunction.

## ◆ GetDer()

double chrono::ChFunctionInterp::GetDer | ( | double | x | ) | const
| overridevirtual

Return the first derivative of the function.

Default implementation computes a numerical differentiation. Inherited classes may override this method with a more efficient implementation (e.g. analytical solution).

Reimplemented from chrono::ChFunction.

## ◆ GetDer2()

double chrono::ChFunctionInterp::GetDer2 | ( | double | x | ) | const
| overridevirtual

Return the second derivative of the function.

Default implementation computes a numerical differentiation. Inherited classes may override this method with a more efficient implementation (e.g. analytical solution).

Reimplemented from chrono::ChFunction.

## ◆ GetType()

virtual Type chrono::ChFunctionInterp::GetType | ( |  | ) | const
| inlineoverridevirtual

Return the unique function type identifier.

Reimplemented from chrono::ChFunction.

## ◆ GetVal()

double chrono::ChFunctionInterp::GetVal | ( | double | x | ) | const
| overridevirtual

Return the function output for input x.

Must be overridden by specialized classes.

Implements chrono::ChFunction.

## ◆ SetExtrapolate()

void chrono::ChFunctionInterp::SetExtrapolate | ( | bool | extrapolate | ) |
| inline

Enable linear extrapolation.

If enabled, the function will return linear extrapolation for x values outside the domain. while the first derivative will be kept equal to the derivative of the nearest two points. Second derivative in any case will be computed numerically based on first derivative.

The documentation for this class was generated from the following files:

- D:/W/B/src/chrono-9.0.1/src/chrono/functions/ChFunctionInterp.h
- D:/W/B/src/chrono-9.0.1/src/chrono/functions/ChFunctionInterp.cpp