asmatic
- 2
- 0
Hi everyone!
Despite I have not too much knowledge of ODE's I'm trying to implement a more or less general 3D physics simulator.
By now, the simulator (only kinematics and simple rotations of a body rigid, at the moment) works with euler integrator but I'd like to move to some more advanced integrators, like Runge-Kutta 4 (RK4)
The problem is at the moment of applying the teorethical equations to the code:
for example to the simplest kinematics equations:
\vec{v_n_+_1} = \vec{v_n} + \vec{a} \Delta t
\vec{s_n_+_1} = \vec{s_n} + \vec{v} \Delta t
\vec{a} = \frac {\vec{F}} {m}
and
\vec{a} = \frac {d \vec{v}}{dt}
\vec{v} = \frac {d \vec{s}}{dt}
ok, the RK4 says that
y(x+\Delta x) = y(x) + \frac{1}{6} (k_1 + 2k_2 + 2k_3 + k4)
where
k_1 = (\Delta x) y'(x,y)
k_2 = (\Delta x) y'(x + \frac {\Delta x}{2}, y + \frac {k_1}{2})
k_3 = (\Delta x) y'(x + \frac {\Delta x}{2}, y + \frac {k_3}{2})
k_4 = (\Delta x) y'(x + \Delta x,y + k_3)
(x is time, and y is the function speed for example and later y is space)
I have searched for the web and in some articles but I' can't find any example appliet to this equations.
Also I'm working with 3d vectors (and quaternions in the future) and I don't know i this may represent a problem at the moment of using the integrator
I think that k_1 must have the form (changing x for time and y for speed)
k_1 = (\Delta t) y'(t,\vec{v}) = \Delta t \frac{d\vec{v}}{dt} = \Delta t \cdot \vec{a}
a is a vetor that can be easily calculated from the net force applied and the mass.
So I can translate k1 easily into C# code
However, I'm confused with k_2 I'm suposed to convert this
k_2 = (\Delta t) y'(t + \frac {\Delta t}{2}, \vec{v} + \frac {k_1}{2})
into this?
k_2 = (\Delta t) \frac{d(\vec{v}+\frac{k_1}{2})}{d(t+\frac{\Delta t}{2})}
any clue in how to interpret the k2, and k3 terms will be very much appreciated
regards
Despite I have not too much knowledge of ODE's I'm trying to implement a more or less general 3D physics simulator.
By now, the simulator (only kinematics and simple rotations of a body rigid, at the moment) works with euler integrator but I'd like to move to some more advanced integrators, like Runge-Kutta 4 (RK4)
The problem is at the moment of applying the teorethical equations to the code:
for example to the simplest kinematics equations:
\vec{v_n_+_1} = \vec{v_n} + \vec{a} \Delta t
\vec{s_n_+_1} = \vec{s_n} + \vec{v} \Delta t
\vec{a} = \frac {\vec{F}} {m}
and
\vec{a} = \frac {d \vec{v}}{dt}
\vec{v} = \frac {d \vec{s}}{dt}
ok, the RK4 says that
y(x+\Delta x) = y(x) + \frac{1}{6} (k_1 + 2k_2 + 2k_3 + k4)
where
k_1 = (\Delta x) y'(x,y)
k_2 = (\Delta x) y'(x + \frac {\Delta x}{2}, y + \frac {k_1}{2})
k_3 = (\Delta x) y'(x + \frac {\Delta x}{2}, y + \frac {k_3}{2})
k_4 = (\Delta x) y'(x + \Delta x,y + k_3)
(x is time, and y is the function speed for example and later y is space)
I have searched for the web and in some articles but I' can't find any example appliet to this equations.
Also I'm working with 3d vectors (and quaternions in the future) and I don't know i this may represent a problem at the moment of using the integrator
I think that k_1 must have the form (changing x for time and y for speed)
k_1 = (\Delta t) y'(t,\vec{v}) = \Delta t \frac{d\vec{v}}{dt} = \Delta t \cdot \vec{a}
a is a vetor that can be easily calculated from the net force applied and the mass.
So I can translate k1 easily into C# code
However, I'm confused with k_2 I'm suposed to convert this
k_2 = (\Delta t) y'(t + \frac {\Delta t}{2}, \vec{v} + \frac {k_1}{2})
into this?
k_2 = (\Delta t) \frac{d(\vec{v}+\frac{k_1}{2})}{d(t+\frac{\Delta t}{2})}

any clue in how to interpret the k2, and k3 terms will be very much appreciated
regards