WarpTwin
Documentation for WarpTwin models and classes.
Loading...
Searching...
No Matches
ForwardEulerIntegrator.hpp
Go to the documentation of this file.
1/******************************************************************************
2* Copyright (c) ATTX LLC 2024. All Rights Reserved.
3*
4* This software and associated documentation (the "Software") are the
5* proprietary and confidential information of ATTX, LLC. The Software is
6* furnished under a license agreement between ATTX and the user organization
7* and may be used or copied only in accordance with the terms of the agreement.
8* Refer to 'license/attx_license.adoc' for standard license terms.
9*
10* EXPORT CONTROL NOTICE: THIS SOFTWARE MAY INCLUDE CONTENT CONTROLLED UNDER THE
11* INTERNATIONAL TRAFFIC IN ARMS REGULATIONS (ITAR) OR THE EXPORT ADMINISTRATION
12* REGULATIONS (EAR99). No part of the Software may be used, reproduced, or
13* transmitted in any form or by any means, for any purpose, without the express
14* written permission of ATTX, LLC.
15******************************************************************************/
16/*
17Forward Euler header file
18-------------------------
19
20
21Author: Alex Reynolds
22*/
23#ifndef UTILS_FORWARD_EULER_HPP
24#define UTILS_FORWARD_EULER_HPP
25
26#include <array>
27
29#include "Integrator.hpp"
30
31namespace warpos {
32
33 template <uint32 N>
35 public:
37
44 int16 step(floating_point start_time,
45 floating_point end_time,
46 const std::array<floating_point, N> &start_state,
47 std::array<floating_point, N> &out_state) override;
48 protected:
50 floating_point _step_size = 1.0;
51
54
55 std::array<floating_point, N> _rates;
56 };
57
58 template <uint32 N>
60 : Integrator<N>(rate_calculator) {
61 _step_size = 0.0;
62 for(uint32 i = 0; i < N; i++) {
63 _rates[i] = 0.0;
64 }
65 }
66
67 template <uint32 N>
68 int16 ForwardEulerIntegrator<N>::step(floating_point start_time, floating_point end_time,
69 const std::array<floating_point, N> &start_state,
70 std::array<floating_point, N> &out_state) {
72 _error = Integrator<N>::_rate_calculator.calculateRates(start_time, start_state, _rates);
73
75 _step_size = end_time - start_time;
76 for(uint32 i = 0; i < N; i++) {
77 out_state[i] = start_state[i] + _step_size*_rates[i];
78 }
79 return _error;
80 }
81
82}
83
84#endif
int16 _error
Error code.
Definition ForwardEulerIntegrator.hpp:53
std::array< floating_point, N > _rates
Definition ForwardEulerIntegrator.hpp:55
int16 step(floating_point start_time, floating_point end_time, const std::array< floating_point, N > &start_state, std::array< floating_point, N > &out_state) override
Definition ForwardEulerIntegrator.hpp:68
ForwardEulerIntegrator(Rates< N > &rate_calculator)
Definition ForwardEulerIntegrator.hpp:59
floating_point _step_size
Step size for integrator.
Definition ForwardEulerIntegrator.hpp:50
Integrator(Rates< N > &rate_calculator)
Constructor for the integrator.
Definition Integrator.hpp:60
Rates< N > & _rate_calculator
Reference to dynamics object that calculates rates.
Definition Integrator.hpp:56
Definition Rates.hpp:28
#define NO_ERROR
Error code in the case where matrix math executed successfully.
Definition clockwerkerrors.h:34
Definition DeadReckon.cpp:20