Geophysical Inversion and Modelling Library v1.5.4
Loading...
Searching...
No Matches
spline.h
1/******************************************************************************
2 * Copyright (C) 2006-2024 by the GIMLi development team *
3 * Carsten Rücker carsten@resistivity.net *
4 * *
5 * Licensed under the Apache License, Version 2.0 (the "License"); *
6 * you may not use this file except in compliance with the License. *
7 * You may obtain a copy of the License at *
8 * *
9 * http://www.apache.org/licenses/LICENSE-2.0 *
10 * *
11 * Unless required by applicable law or agreed to in writing, software *
12 * distributed under the License is distributed on an "AS IS" BASIS, *
13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
14 * See the License for the specific language governing permissions and *
15 * limitations under the License. *
16 * *
17 ******************************************************************************/
18
19#ifndef _GIMLI_SPLINE__H
20#define _GIMLI_SPLINE__H
21
22#include "gimli.h"
23#include "pos.h"
24
25#include <vector>
26
27namespace GIMLI{
28
29class DLLEXPORT CubicFunct{
30public:
32 CubicFunct( const double a = 0.0, const double b = 0.0, const double c = 0.0, const double d = 0.0)
33 : a_( a ), b_( b ), c_( c ), d_( d ) {}
34
35 CubicFunct( const CubicFunct & C ) : a_( C.a_ ), b_( C.b_ ), c_( C.c_ ), d_( C.d_ ) {}
36
37 CubicFunct operator = ( const CubicFunct & C ) {
38 if ( this != & C ){
39 a_ = C.a_; b_ = C.b_; c_ = C.c_; d_ = C.d_;
40 } return *this;
41 }
42
43 inline double operator()( double t ) const { return t * (t * (t * a_ + b_) + c_) + d_; }
44
45 inline double val( double t ) const { return (*this)( t ); }
46
47 friend bool operator == ( const CubicFunct & a , const CubicFunct & b );
48
49 double a_, b_, c_, d_;
50};
51
52inline bool operator == ( const CubicFunct & a , const CubicFunct & b ){
53 if ( std::fabs( a.a_ - b.a_ ) < TOLERANCE &&
54 std::fabs( a.b_ - b.b_ ) < TOLERANCE &&
55 std::fabs( a.c_ - b.c_ ) < TOLERANCE &&
56 std::fabs( a.d_ - b.d_ ) < TOLERANCE ) return true; else return false;
57}
58
59DLLEXPORT std::vector < CubicFunct > calcNaturalCubic( const std::vector < double > & x );
60DLLEXPORT std::vector < CubicFunct > calcNaturalCubicClosed( const std::vector < double > & x );
61
63DLLEXPORT std::vector < RVector3 > createSpline( const std::vector < RVector3 > & input, int nSegments, bool close );
64
66DLLEXPORT std::vector < RVector3 > createSplineLocalDX( const std::vector < RVector3 > & input, double localDX, bool close );
67
68} // namespace GIMLI
69
70#endif // _GIMLI_SPLINE__H
71
Definition spline.h:29
CubicFunct(const double a=0.0, const double b=0.0, const double c=0.0, const double d=0.0)
Definition spline.h:32
GIMLi main namespace for the Geophyiscal Inversion and Modelling Library.
Definition baseentity.h:24
std::vector< RVector3 > createSpline(const std::vector< RVector3 > &input, int nSegments, bool close)
Definition spline.cpp:23
RVector x(const R3Vector &rv)
Definition pos.cpp:107
std::vector< CubicFunct > calcNaturalCubicClosed(const std::vector< double > &x)
Definition spline.cpp:86
std::vector< RVector3 > createSplineLocalDX(const std::vector< RVector3 > &input, double localDX, bool close)
Definition spline.cpp:51