physical systems using Yampa.
1. get the velocity using the formula,
where v0 is the previous velocity.
2. calculate the new position as follows,
and some other steps that are not relevant here.
integralCoordSF :: Force -> Mass -> SF (Pos,Vel) (Pos,Vel)
integralCoordSF force mass = proc (x0,v0) -> do
v <- integralVelSF force mass -< v0
vdt2 <- integral -< v
let x = x0 + vdt2
returnA -< (x,v)
integralVelSF :: Force -> Mass -> SF Double Double
integralVelSF force mass = proc v0 -> do
t1 <- integral -< 0.5 * (force/mass)
returnA -< v0 + t1
Now, let's the speed (velocity), force and the mass equal 1.0. And
the initial potion equal zero. Then using the "embed" function we get that,
*Main> embed (integralCoordSF 1.0 1.0) ((0.0,1.0),[(0.1,Nothing),(0.1,Nothing)])
[(0.0,1.0),(0.1,1.05),(0.20500000000000002,1.1)]
According to the algorithm, if dt = 0.1 then
v = 1.0 + integral (0.5 * 1.0 * recip 1.0) = 1.05
in agreement with the algorithm. But let's see about the position
x = 0 + integral (v)
Using the formula of step 2, the position should be equal to 0.105,
but the result given by embed is 0.1.
As a beginner certainly and missing a lot of concepts and details,
can someone please explain me what's going on here?
Thank you for your help!
Felipe Z