[ODE] Fwd: Forward-correcting force

Russel russel at appliedminds.net
Tue Apr 11 08:05:59 MST 2006


Try This:
You want to remove energy from your sub (It loses energy to the  
water).  You want this energy to be lost in such a way that linear  
velocity eventually agrees with direction.  What this simulates is an  
object with a different coefficient of drag in two orientations.  Try  
pretending that drag is constant*speed^2.  Add one drag term for the  
sub moving forward through the water, and a second for sideways  
drift.  Play with FrontalDrag and SideDrag to see if you can get the  
effect you want.
Russel

float ParallelSpeedSq = (m_Direction * GetLinearVelocity())**2;
Vector right = m_Direction.Cross(m_Up);
float  PerpSpeedSq =  (right * GetLinearVelocity())**2;
Vector dragforce = - FrontalDrag*ParallelSpeedSq*m_Direction -  
SideDrag*PerpSpeedSq*right;
GetPhysicsObject()->AddForce(dragforce)

On Apr 11, 2006, at 7:22 AM, Jean-Sebastien Guay wrote:

> 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
> _______________________________________________
> ODE mailing list
> ODE at q12.org
> http://q12.org/mailman/listinfo/ode




More information about the ODE mailing list