mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-05-02 05:04:08 +08:00
Formatting.
This commit is contained in:
parent
42f2e60b24
commit
787606b6b8
@ -6,21 +6,21 @@ namespace matrix {
|
||||
|
||||
template<typename Type, size_t M>
|
||||
int integrate_rk4(
|
||||
Vector<Type, M> (*f)(Type, Vector<Type, M>),
|
||||
Vector<Type, M> (*f)(Type, Vector<Type, M>),
|
||||
Vector<Type, M> & y,
|
||||
Type & t,
|
||||
Type h
|
||||
)
|
||||
Type h
|
||||
)
|
||||
{
|
||||
// https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods
|
||||
Vector<Type, M> k1, k2, k3, k4;
|
||||
k1 = f(t, y);
|
||||
k2 = f(t + h/2, y + k1*h/2);
|
||||
k3 = f(t + h/2, y + k2*h/2);
|
||||
k4 = f(t + h, y + k3*h);
|
||||
y += (k1 + k2*2 + k3*2 + k4)*(h/6);
|
||||
t += h;
|
||||
return 0;
|
||||
// https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods
|
||||
Vector<Type, M> k1, k2, k3, k4;
|
||||
k1 = f(t, y);
|
||||
k2 = f(t + h/2, y + k1*h/2);
|
||||
k3 = f(t + h/2, y + k2*h/2);
|
||||
k4 = f(t + h, y + k3*h);
|
||||
y += (k1 + k2*2 + k3*2 + k4)*(h/6);
|
||||
t += h;
|
||||
return 0;
|
||||
}
|
||||
|
||||
}; // namespace matrix
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user