|
|
> The only problem is that *now* you can't say
>
> p1 = p0 * dt v0
>
> without sprinkling it with typecasts.
>
> Actually, what you'd *probably* do is define
>
> step :: TimeStep -> Velocity -> Position
> step dt (Velocity v) = Position (dt * v)
>
> and then have
>
> p1 = p0 + step dt v0
Couldn't you just define a * function that takes a velocity and a time and
returns a position? You can do the same for one that takes an acceleration
and a time and returns velocity. Then you wouldn't need to change the code,
and * looks better than "step".
In fact, maybe it's possible to do all this automatically if you keep track
of the units somehow? Could you do this in Haskell? Somehow tell it that
distance is units L, velocity is units L*T, etc, and then it would work it
all out automatically when you did multiplication and division. Would be
pretty cool for phyical simulations.
Post a reply to this message
|
|