[ODE] Forward-correcting force
Jean-Sebastien Guay
jean-sebastien.guay at polymtl.ca
Tue Apr 11 07:22:21 MST 2006
Could anyone please help me out with this?
Thanks in advance,
J-S
> Hello,
>
> I'm having trouble refining the idea of forward-correcting force that Jon
> Watte
> gave me the first time I asked about modeling the movement of a submarine
> underwater.
>
> What I would like is that if the sub currently has a nonzero linear velocity,
> but that I turn it a bit so that its direction vector is no longer lined up
> with the linear velocity's direction, the linear velocity should come back
> gradually (quite quickly in fact) to line back up onto the sub's direction
> vector.
>
> It isn't that hard, normally I would think a quick dot product and then a
> force
> in relation to that would work. But I'm still having trouble with it. Here's
> what I have:
>
> Vector right = m_Direction .Cross(m_Up);
>
> // '*' between 2 vectors is dot product in (GetLinearVelocity() * right)
> Vector fcf = m_Direction *
> (GetLinearVelocity() * right) * -1.0f * m_Mass;
> GetPhysicsObject()->AddForce(fcf);
>
> The problem with this is that it does bring back the orientation to the
> direction (not fast enough yet, but I can tweak that later), but it
> introduces
> too much new speed. My sub is supposed to have a given max speed (m_MaxSpeed)
> and after a few turns with this force enabled, I'm going really a lot faster
> than that.
>
> Just for reference, my acceleration function goes roughly like this:
>
> if (GetLinearVelocity().GetLength() < GetMaxSpeed())
> {
> Vector force = m_Direction * m_Mass * m_Acceleration;
> GetPhysicsObject()->AddForce(force);
> }
>
> Perhaps there's a better way of bounding the linear velocity of an object?
>
> Can anyone point me in the right direction please?
--
______________________________________________________
Jean-Sebastien Guay jean-sebastien.guay at polymtl.ca
http://whitestar02.webhop.org
More information about the ODE
mailing list