Files
Extern/C3d/Include/func_mono_smooth_function.h
T
Dario Sassi 45803fb2d7 Extern :
- C3d aggiornamento delle librerie.
2020-12-24 11:59:30 +00:00

160 lines
14 KiB
C++
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
////////////////////////////////////////////////////////////////////////////////
/**
\file
\brief \ru Монотонная сплайн интерполяция класса c2 на основе
однопараметрических групп диффеоморфизмов (Н.В.Осадченко).
\en Monotone spline interpolation class c2 based
one-parameter groups of diffeomorphisms (N.V. Osadchenko). \~
*/
////////////////////////////////////////////////////////////////////////////////
#ifndef __FUNC_MONO_SMOOTH_FUNCTION_H
#define __FUNC_MONO_SMOOTH_FUNCTION_H
#include <function.h>
#include <templ_s_array.h>
//------------------------------------------------------------------------------
/** \brief \ru Монотонная сплайн интерполяция класса c2 на основе
однопараметрических групп диффеоморфизмов (Н.В.Осадченко).
\en Monotone spline interpolation class c2 based
one-parameter groups of diffeomorphisms (N.V. Osadchenko). \~
\details \ru Класс описывает сплайн-функцию, которая строится по возрастающему \n
набору параметров и монотонно возрастающему/убывающему набору значений. \n
Функция гарантирует однозначное соответствие параметр-значение. При этом \n
аналичиские функции, описывающие сплайн на каждом участке, стыкуются \n
между собой с сохранением непрерывности первой и второй производной. \n
(Если от функции не требуется второй порядок непрерывности, то монотонную функцию \n
можно построить с помощью кубической функции MbCubicFunction через инициализацию \n
InitMonotonic). Данная функция может быть использована, как функция репараметризации. \n
При этом, если репараметризуемый объект обладает свойством замкнутости, то \n
функция может учесть это свойство, обеспечив также второй порядок непрерывности \n
через шов. Функция принимает на вход при инициализации массив параметров и \n
значений, имеющих одинаковую размерность вне зависимости от параметра \n
замкнутости. Репараметризующая функция построена в виде 3х вложенных друг в друга \n
рациональных функций y(x)=y1+(y2-y1)*Fb(Fg(Fb((x-x1)/(x2-x1)))). Подробно ознакомится \n
с данным типом сплайна можно по ссылке.
http://www.stfi.ru/journal/STFI_2017_03/STFI_2017_03_Osadchenko.pdf
\en The class describes a spline function, which is built from an increasing set \n
of parameters and a monotonically increasing / decreasing set of values. The \n
function guarantees a one-to-one parameter-value match. In this case, the \n
analytical functions describing the spline in each section are joined together \n
while maintaining the continuity of the first and second derivatives. (If the \n
function does not require the second order of continuity, then a monotonic \n
function can be built using the MbCubicFunction cubic function through the \n
InitMonotonic initialization). This function can be used as a reparameterization \n
function. Moreover, if the reparameterizable object has the property of being \n
closed, then the function can take this property into account, providing also \n
the second order of continuity through the seam. During initialization, the \n
function accepts an array of parameters and values that have the same dimension, \n
regardless of the closure parameter. The reparametrizing function is built in \n
the form of 3 nested rational functions \n
y (x) = y1 + (y2-y1) * Fb (Fg (Fb ((x-x1) / (x2-x1)))). \n
You can learn more about this type of spline here. \n
http://www.stfi.ru/journal/STFI_2017_03/STFI_2017_03_Osadchenko.pdf \~
\ingroup Functions
*/
// ---
class MATH_CLASS MbMonoSmoothFunction : public MbFunction {
protected:
c3d::DoubleVector x; ///< \ru Возрастающий набор параметров. \en Increasing set of parameters.
c3d::DoubleVector y; ///< \ru Монотонный набор значений. \en Monotonic set of values.
c3d::DoubleVector bet; ///< \ru Параметры beta-функций. \en Parameters of beta functions.
c3d::DoubleVector gam; ///< \ru Параметры gamma-функций. \en Parameters of gamma functions.
bool cls; ///< \ru Периодичность набора значений.\en Periodicity of the set of values.
private:
/// \ru Конструктор. \en Constructor.
MbMonoSmoothFunction();
/// \ru Конструктор копии. \en Copy constructor.
MbMonoSmoothFunction( const MbMonoSmoothFunction & );
public :
virtual ~MbMonoSmoothFunction();
public:
/// \ru Создание объекта. \en Object creation.
static MbFunction * Create( const c3d::DoubleVector & pars, const c3d::DoubleVector & vals, bool yCls );
/** \brief \ru Инициализация сплайна.
\en Spline initialization. \~
\param[in] pars - \ru Возрастающий набор параметров.
\en Increasing set of parameters. \~
\param[in] vals - \ru Монотонный набор значений.
\en Monotonic set of values. \~
\param[in] valCls - \ru Периодичность набора значений.
\en Periodicity of the set of values. \~
\return \ru Статус операции.
\en Operation status. \~
*/
bool Init ( const c3d::DoubleVector & pars, const c3d::DoubleVector & vals, bool valCls );
public:
// \ru Общие функции математического объекта \en Common functions of mathematical object
virtual MbeFunctionType IsA () const; // \ru Тип элемента \en A type of element
virtual MbFunction & Duplicate() const; // \ru Сделать копию элемента \en Create a copy of the element
virtual bool IsSame ( const MbFunction & other, double accuracy = LENGTH_EPSILON ) const; // \ru Являются ли объекты равными \en Determine whether objects are equal
virtual bool SetEqual ( const MbFunction & ); // \ru Сделать равным \en Make equal
virtual void GetProperties( MbProperties & ); // \ru Выдать свойства объекта \en Get properties of object
virtual void SetProperties( const MbProperties & ); // \ru Записать свойства объекта \en Set properties of object
virtual double GetTMax () const; // \ru Вернуть максимальное значение параметра \en Get the maximum value of parameter
virtual double GetTMin () const; // \ru Вернуть минимальное значение параметра \en Get the minimum value of parameter
virtual bool IsClosed () const; // \ru Замкнутость кривой \en A curve closeness
virtual void SetClosed( bool ); // \ru Замкнутость функции \en A function closeness
virtual double Value ( double & t ) const; // \ru Значение функции для t \en The value of function for a given t
virtual double FirstDer ( double & t ) const; // \ru Первая производная по t \en The first derivative with respect to t
virtual double SecondDer ( double & t ) const; // \ru Вторая производная по t \en The second derivative with respect to t
virtual double ThirdDer ( double & t ) const; // \ru Третья производная по t \en The third derivative with respect to t
virtual double _Value ( double t ) const; // \ru Значение функции для t \en The value of function for a given t
virtual double _FirstDer ( double t ) const; // \ru Первая производная по t \en The first derivative with respect to t
virtual double _SecondDer ( double t ) const; // \ru Вторая производная по t \en The second derivative with respect to t
virtual double _ThirdDer ( double t ) const; // \ru Третья производная по t \en The third derivative with respect to t
// \ru Вычислить значение и производные. \en Calculate value and derivatives of object for given parameter. \~
virtual void Explore( double & t, bool ext, double & val, double & fir, double * sec, double * thr ) const;
size_t GetListCount() const { return x.size(); } // \ru Количество точек в наборе \en Number of points in a set.
double GetValue(size_t ind ) const { return y[ind]; } // \ru Получить значение по индексу. \en Get value by index.
double GetParam(size_t ind ) const { return x[ind]; } // \ru Получить параметр по индексу. \en Get parameter by index.
virtual void Inverse( MbRegTransform * iReg = c3d_null ); // \ru Изменить направление \en Change direction
virtual double Step( double t, double sag ) const;
virtual double DeviationStep( double t, double angle ) const;
virtual double MinValue ( double & t ) const; // \ru Минимальное значение функции \en The minimum value of function
virtual double MaxValue ( double & t ) const; // \ru Максимальное значение функции \en The maximum value of function
virtual double MidValue () const; // \ru Среднее значение функции \en The middle value of function
virtual bool IsGood () const; // \ru Корректность функции \en Correctness of function
virtual bool IsConst() const;
virtual bool IsLine () const;
virtual void SetOffsetFunc( double distOld, double distNew ); // \ru Сместить функцию \en Shift a function
virtual bool SetLimitParam( double, double ); // \ru Установить область изменения параметра \en Set range of parameter
virtual void SetLimitValue( size_t n, double); // \ru Установить значение на конце ( 1 - в начале, 2 - в конце) \en Set the value at the end (1 - at start point, 2 - at end point)
virtual double GetLimitValue( size_t n ) const; // \ru Дать значение на конце ( 1 - в начале, 2 - в конце) \en Get the value at the end (1 - at start point, 2 - at end point)
virtual bool InsertValue( double x, double y); // \ru Установить значение для параметра t. \en Set the value for the pdrdmeter t.
// \ru Создать функцию из части функции между параметрами t1 и t2 c выбором направления sense. \en Create a function in part of the function between the parameters t1 and t2 choosing the direction.
virtual MbFunction * Trimmed( double t1, double t2, int sense ) const;
// \ru Разбить функцию точкой с параметром t и вернуть отрезанную часть. \en Function break by the parameter t, and cut off part of the function: begs == true - save the initial half, beg == false - save the final half.
virtual MbFunction * BreakFunction( double t, bool beg );
MbFunction * Break( double t1, double t2 ) const; ///< \ru Выделить часть функции. \en Select a part of a function.
private:
void CheckParam( double & t ) const; // \ru Установить параметр в область определения. \en Set the parameter to the domain.
void DivExplore( size_t ord, double( &P )[4], double( &T )[4], double( &res )[4] ) const; // \ru Найти производные частного P/T. \en Find the derivatives of the quotient P / T.
void ExploreBet( double b, size_t ord, double( &res )[4] ) const; // \ru Расчитать производные beta функции. \en Calculate the derivatives of the beta function.
void ExploreGam( double b, size_t ord, double( &res )[4] ) const;// \ru Расчитать производные gamma функции. \en Calculate the derivatives of the gamma function.
void Explore( double x, size_t ord, double( &res )[4] ) const;// \ru Расчитать производные сплайна. \en Calculate the derivatives of the spline.
void operator = ( const MbMonoSmoothFunction & ); // \ru Не реализовано \en Not implemented
DECLARE_PERSISTENT_CLASS_NEW_DEL( MbMonoSmoothFunction )
};
IMPL_PERSISTENT_OPS( MbCubicSplineFunction )
#endif // __FUNC_MONO_SMOOTH_FUNCTION_H