Project Chrono: chrono::ChFunction Class Reference

Public Types | Public Member Functions | List of all members
chrono::ChFunction Class Referenceabstract
Chrono::Engine » Function objects

## Description

Interface base class for scalar functions.

Base class for all Chrono scalar functions. The GetVal() and Clone() methods must be implemented by derived classes.

`#include <ChFunctionBase.h>`

Inheritance diagram for chrono::ChFunction:
[legend]

## Public Types
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.

## Public Member Functions
| ChFunction (const ChFunction &other)
virtual ChFunction * | Clone () const =0
| "Virtual" copy constructor.
virtual Type | GetType () const
| Return the unique function type identifier.
virtual double | GetVal (double x) const =0
| Return the function output for input x.
virtual double | GetDer (double x) const
| Return the first derivative of the function.
virtual double | GetDer2 (double x) const
| Return the second derivative of the function.
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.
virtual void | ArchiveOut (ChArchiveOut &archive_out)
| Method to allow serialization of transient data to archives.
virtual void | ArchiveIn (ChArchiveIn &archive_in)
| Method to allow de-serialization of transient data from archives.

## Member Function Documentation

## ◆ ArchiveIn()

void chrono::ChFunction::ArchiveIn | ( | ChArchiveIn & | archive_in | ) |
| virtual

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

Method to allow de serialization of transient data from archives.

Reimplemented in chrono::ChFunctionBSpline, chrono::ChFunctionConst, chrono::ChFunctionConstAcc, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, chrono::ChFunctionDerivative, chrono::ChFunctionFillet3, chrono::ChFunctionIntegral, chrono::ChFunctionInterp, chrono::ChFunctionMirror, chrono::ChFunctionOperator, chrono::ChFunctionPoly23, chrono::ChFunctionPoly345, chrono::ChFunctionPoly, chrono::ChFunctionRamp, chrono::ChFunctionRepeat, chrono::ChFunctionSequence, chrono::ChFunctionSetpoint, and chrono::ChFunctionSineStep.

## ◆ ArchiveOut()

void chrono::ChFunction::ArchiveOut | ( | ChArchiveOut & | archive_out | ) |
| virtual

Method to allow serialization of transient data to archives.

Reimplemented in chrono::ChFunctionBSpline, chrono::ChFunctionConst, chrono::ChFunctionConstAcc, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, chrono::ChFunctionDerivative, chrono::ChFunctionFillet3, chrono::ChFunctionIntegral, chrono::ChFunctionInterp, chrono::ChFunctionMirror, chrono::ChFunctionOperator, chrono::ChFunctionPoly23, chrono::ChFunctionPoly345, chrono::ChFunctionPoly, chrono::ChFunctionRamp, chrono::ChFunctionRepeat, chrono::ChFunctionSequence, chrono::ChFunctionSetpoint, and chrono::ChFunctionSineStep.

## ◆ Clone()

virtual ChFunction * chrono::ChFunction::Clone | ( |  | ) | const
| pure virtual

"Virtual" copy constructor.

Implemented in chrono::ChFunctionBSpline, chrono::ChFunctionConst, chrono::ChFunctionConstAcc, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, chrono::ChFunctionDerivative, chrono::ChFunctionFillet3, chrono::ChFunctionIntegral, chrono::ChFunctionInterp, chrono::ChFunctionLambda, chrono::ChFunctionMirror, chrono::ChFunctionOperator, chrono::ChFunctionPoly23, chrono::ChFunctionPoly345, chrono::ChFunctionPoly, chrono::ChFunctionRamp, chrono::ChFunctionRepeat, chrono::ChFunctionSequence, chrono::ChFunctionSetpoint, and chrono::ChFunctionSineStep.

## ◆ GetDer()

double chrono::ChFunction::GetDer | ( | double | x | ) | const
| virtual

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 in chrono::ChFunctionBSpline, chrono::ChFunctionConst, chrono::ChFunctionConstAcc, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, chrono::ChFunctionFillet3, chrono::ChFunctionInterp, chrono::ChFunctionPoly23, chrono::ChFunctionPoly345, chrono::ChFunctionPoly, chrono::ChFunctionRamp, chrono::ChFunctionSequence, chrono::ChFunctionSetpoint, and chrono::ChFunctionSineStep.

## ◆ GetDer2()

double chrono::ChFunction::GetDer2 | ( | double | x | ) | const
| virtual

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 in chrono::ChFunctionBSpline, chrono::ChFunctionConst, chrono::ChFunctionConstAcc, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, chrono::ChFunctionFillet3, chrono::ChFunctionInterp, chrono::ChFunctionPoly23, chrono::ChFunctionPoly345, chrono::ChFunctionPoly, chrono::ChFunctionRamp, chrono::ChFunctionSequence, chrono::ChFunctionSetpoint, and chrono::ChFunctionSineStep.

## ◆ GetDer3()

double chrono::ChFunction::GetDer3 | ( | double | x | ) | const
| virtual

Return the third 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 in chrono::ChFunctionBSpline, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, and chrono::ChFunctionPoly345.

## ◆ GetDerN()

double chrono::ChFunction::GetDerN | ( | double | x,
|  | int | der_order ) const
| virtual

Return the Nth derivative of the function (up to 3rd derivative).

Alias for other GetDerX functions.

## ◆ GetNegativeAccelerationCoeff()

virtual double chrono::ChFunction::GetNegativeAccelerationCoeff | ( |  | ) | const
| inlinevirtual

Compute the negative acceleration coefficient (inherited classes should override this).

Reimplemented in chrono::ChFunctionConstAcc, chrono::ChFunctionPoly23, and chrono::ChFunctionPoly345.

## ◆ GetPositiveAccelerationCoeff()

virtual double chrono::ChFunction::GetPositiveAccelerationCoeff | ( |  | ) | const
| inlinevirtual

Computes the positive acceleration coefficient (inherited classes should override this).

Reimplemented in chrono::ChFunctionConstAcc, chrono::ChFunctionPoly23, and chrono::ChFunctionPoly345.

## ◆ GetType()

virtual Type chrono::ChFunction::GetType | ( |  | ) | const
| inlinevirtual

Return the unique function type identifier.

Reimplemented in chrono::ChFunctionBSpline, chrono::ChFunctionConst, chrono::ChFunctionConstAcc, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, chrono::ChFunctionDerivative, chrono::ChFunctionFillet3, chrono::ChFunctionIntegral, chrono::ChFunctionInterp, chrono::ChFunctionLambda, chrono::ChFunctionMirror, chrono::ChFunctionOperator, chrono::ChFunctionPoly23, chrono::ChFunctionPoly345, chrono::ChFunctionPoly, chrono::ChFunctionRamp, chrono::ChFunctionRepeat, chrono::ChFunctionSequence, and chrono::ChFunctionSineStep.

## ◆ GetVal()

virtual double chrono::ChFunction::GetVal | ( | double | x | ) | const
| pure virtual

Return the function output for input x.

Must be overridden by specialized classes.

Implemented in chrono::ChFunctionBSpline, chrono::ChFunctionConst, chrono::ChFunctionConstAcc, chrono::ChFunctionConstJerk, chrono::ChFunctionCycloidal, chrono::ChFunctionDerivative, chrono::ChFunctionFillet3, chrono::ChFunctionIntegral, chrono::ChFunctionInterp, chrono::ChFunctionLambda, chrono::ChFunctionMirror, chrono::ChFunctionOperator, chrono::ChFunctionPoly23, chrono::ChFunctionPoly345, chrono::ChFunctionPoly, chrono::ChFunctionRamp, chrono::ChFunctionRepeat, chrono::ChFunctionSequence, chrono::ChFunctionSetpoint, and chrono::ChFunctionSineStep.

## ◆ GetVelocityCoefficient()

virtual double chrono::ChFunction::GetVelocityCoefficient | ( |  | ) | const
| inlinevirtual

Compute the velocity coefficient (inherited classes must override this).

Reimplemented in chrono::ChFunctionConstAcc, chrono::ChFunctionPoly23, and chrono::ChFunctionPoly345.

## ◆ GetWeight()

virtual double chrono::ChFunction::GetWeight | ( | double | x | ) | const
| inlinevirtual

Return the weight of the function (useful for applications where you need to mix different weighted ChFunctions).

Reimplemented in chrono::ChFunctionSequence.

## ◆ OutputToASCIIFile()

void chrono::ChFunction::OutputToASCIIFile | ( | std::ostream & | file,
|  | double | xmin,
|  | double | xmax,
|  | int | samples,
|  | char | delimiter )
| virtual

Store X-Y pairs to an ASCII File.

Values are separated by delimiter (default=','). The function is sampled samples times, from xmin to xmax.

## ◆ SampleUpToDerN()

ChMatrixDynamic chrono::ChFunction::SampleUpToDerN | ( | double | xmin,
|  | double | xmax,
|  | double | step,
|  | int | derN = 0 )
| virtual

Sample function on given interval [xmin, xmax], up to derN derivative (0 being the function ouput itself).

Store interval x=[xmin:step:xmax] and function evaluations as columns into matrix.

## ◆ Update()

virtual void chrono::ChFunction::Update | ( | double | x | ) |
| inlinevirtual

Update could be implemented by children classes, ex. to launch callbacks.

Reimplemented in chrono::ChFunctionSetpoint, and chrono::ChFunctionSetpointCallback.

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

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