GteOdeEuler.h
Go to the documentation of this file.
1 // David Eberly, Geometric Tools, Redmond WA 98052
2 // Copyright (c) 1998-2017
3 // Distributed under the Boost Software License, Version 1.0.
4 // http://www.boost.org/LICENSE_1_0.txt
5 // http://www.geometrictools.com/License/Boost/LICENSE_1_0.txt
6 // File Version: 3.0.0 (2016/06/19)
7 
8 #pragma once
9 
11 
12 // The TVector template parameter allows you to create solvers with
13 // Vector<N,Real> when the dimension N is known at compile time or
14 // GVector<Real> when the dimension N is known at run time. Both classes
15 // have 'int GetSize() const' that allow OdeSolver-derived classes to query
16 // for the dimension.
17 
18 namespace gte
19 {
20 
21 template <typename Real, typename TVector>
22 class OdeEuler : public OdeSolver<Real,TVector>
23 {
24 public:
25  // Construction and destruction.
26  virtual ~OdeEuler();
27  OdeEuler(Real tDelta,
28  std::function<TVector(Real, TVector const&)> const& F);
29 
30  // Estimate x(t + tDelta) from x(t) using dx/dt = F(t,x). You may allow
31  // xIn and xOut to be the same object.
32  virtual void Update(Real tIn, TVector const& xIn, Real& tOut,
33  TVector& xOut);
34 };
35 
36 
37 template <typename Real, typename TVector>
39 {
40 }
41 
42 template <typename Real, typename TVector>
44  std::function<TVector(Real, TVector const&)> const& F)
45  :
46  OdeSolver<Real, TVector>(tDelta, F)
47 {
48 }
49 
50 template <typename Real, typename TVector>
51 void OdeEuler<Real, TVector>::Update(Real tIn, TVector const& xIn,
52  Real& tOut, TVector& xOut)
53 {
54  TVector fVector = this->mFunction(tIn, xIn);
55  tOut = tIn + this->mTDelta;
56  xOut = xIn + this->mTDelta * fVector;
57 }
58 
59 
60 }
OdeEuler(Real tDelta, std::function< TVector(Real, TVector const &)> const &F)
Definition: GteOdeEuler.h:43
virtual void Update(Real tIn, TVector const &xIn, Real &tOut, TVector &xOut)
Definition: GteOdeEuler.h:51
virtual ~OdeEuler()
Definition: GteOdeEuler.h:38
std::function< TVector(Real, TVector const &)> mFunction
Definition: GteOdeSolver.h:46


geometric_tools_engine
Author(s): Yijiang Huang
autogenerated on Thu Jul 18 2019 04:00:01