Rigid Body Dynamics Library
Function_< T >::Step Class Reference

#include <Function.h>

+ Inheritance diagram for Function_< T >::Step:

Public Member Functions

 Step (const T &y0, const T &y1, double x0, double x1)
 
calcValue (const RigidBodyDynamics::Math::VectorNd &xin) const
 
calcDerivative (const std::vector< int > &derivComponents, const RigidBodyDynamics::Math::VectorNd &xin) const
 
virtual int getArgumentSize () const
 
int getMaxDerivativeOrder () const
 
- Public Member Functions inherited from Function_< T >
virtual ~Function_ ()
 
virtual T calcValue (const RigidBodyDynamics::Math::VectorNd &x) const =0
 
virtual T calcDerivative (const std::vector< int > &derivComponents, const RigidBodyDynamics::Math::VectorNd &x) const =0
 
virtual int getArgumentSize () const =0
 
virtual int getMaxDerivativeOrder () const =0
 

Private Member Functions

double step01 (double x0, double x1, double x)
 
double dstep01 (double x0, double x1, double x)
 
double d2step01 (double x0, double x1, double x)
 
double d3step01 (double x0, double x1, double x)
 

Private Attributes

const T m_y0
 
const T m_y1
 
const T m_yr
 
const T m_zero
 
const double m_x0
 
const double m_x1
 
const double m_ooxr
 
const double m_sign
 

Detailed Description

template<class T>
class RigidBodyDynamics::Addons::Geometry::Function_< T >::Step

This is a Function_ subclass whose output value y=f(x) is smoothly stepped from y=y0 to y1 as its input argument goes from x=x0 to x1. This is an S-shaped function with first and second derivatives y'(x0)=y'(x1)=0 and y''(x0)=y''(x1)==0. The third derivative y''' exists and is continuous but we cannot guarantee anything about it at the end points.

Definition at line 377 of file Function.h.

Constructor & Destructor Documentation

◆ Step()

Step ( const T &  y0,
const T &  y1,
double  x0,
double  x1 
)
inline

Create a Function_::Step object that smoothly interpolates its output through a given range as its input moves through its range.

Parameters
y0Output value when (x-x0)*sign(x1-x0) <= 0.
y1Output value when (x-x1)*sign(x1-x0) >= 0.
x0Start of switching interval.
x1End of switching interval.
Template Parameters
TThe template type is the type of y0 and y1. This must be a type that supports subtraction and scalar multiplication by a double so that we can compute an expression like y=y0 + f*(y1-y0) for some double scalar f.

Note that the numerical values of x0 and x1 can be in either order x0 < x1 or x0 > x1.

Definition at line 396 of file Function.h.

Member Function Documentation

◆ calcDerivative()

T calcDerivative ( const std::vector< int > &  derivComponents,
const RigidBodyDynamics::Math::VectorNd x 
) const
inlinevirtual

Calculate a partial derivative of this function at a particular point.
Which derivative to take is specified by listing the input components with which to take it. For example, if derivComponents=={0}, that indicates a first derivative with respective to component 0. If derivComponents=={0, 0, 0}, that indicates a third derivative with respective to component 0. If derivComponents=={4, 7}, that indicates a partial second derivative with respect to components 4 and 7.

Parameters
derivComponents
The input components with respect to which the derivative should be taken. Its size must be less than or equal to the value returned by getMaxDerivativeOrder().
x
The RigidBodyDynamics::Math::VectorNd of input arguments. Its size must equal the value returned by getArgumentSize().
Returns
The value of the selected derivative, which is of type T.

Implements Function_< T >.

Definition at line 431 of file Function.h.

References MX_Xd_dynamic::size().

◆ calcValue()

T calcValue ( const RigidBodyDynamics::Math::VectorNd x) const
inlinevirtual

Calculate the value of this function at a particular point.

Parameters
xthe RigidBodyDynamics::Math::VectorNd of input arguments. Its size must equal the value returned by getArgumentSize().

Implements Function_< T >.

Definition at line 411 of file Function.h.

References MX_Xd_dynamic::size().

◆ d2step01()

double d2step01 ( double  x0,
double  x1,
double  x 
)
inlineprivate

Definition at line 499 of file Function.h.

◆ d3step01()

double d3step01 ( double  x0,
double  x1,
double  x 
)
inlineprivate

Definition at line 508 of file Function.h.

◆ dstep01()

double dstep01 ( double  x0,
double  x1,
double  x 
)
inlineprivate

Definition at line 491 of file Function.h.

◆ getArgumentSize()

virtual int getArgumentSize ( ) const
inlinevirtual

This provides compatibility with std::vector without requiring any copying. Get the number of components expected in the input vector.

Implements Function_< T >.

Definition at line 468 of file Function.h.

◆ getMaxDerivativeOrder()

int getMaxDerivativeOrder ( ) const
inlinevirtual

Get the maximum derivative order this Function_ object can calculate.

Implements Function_< T >.

Definition at line 469 of file Function.h.

◆ step01()

double step01 ( double  x0,
double  x1,
double  x 
)
inlineprivate

Definition at line 484 of file Function.h.

Field Documentation

◆ m_ooxr

const double m_ooxr
private

Definition at line 481 of file Function.h.

◆ m_sign

const double m_sign
private

Definition at line 482 of file Function.h.

◆ m_x0

const double m_x0
private

Definition at line 481 of file Function.h.

◆ m_x1

const double m_x1
private

Definition at line 481 of file Function.h.

◆ m_y0

const T m_y0
private

This provides compatibility with std::vector without requiring any copying.

Definition at line 479 of file Function.h.

◆ m_y1

const T m_y1
private

Definition at line 479 of file Function.h.

◆ m_yr

const T m_yr
private

Definition at line 479 of file Function.h.

◆ m_zero

const T m_zero
private

Definition at line 480 of file Function.h.


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