Question about the Code in btRaycastVehicle
Posted: Mon Jul 28, 2014 8:33 am
Hi,
I'm currently trying to get started with a vehicle simulation using Bullet. I want to start with a raycast vehicle and am currently looking at the btRaycastVehicle code. I have some questions about parts of this code and I hope someone can explain the maths and/or physics to me.
First off, there is this code in btRaycastVehicle::rayCast(btWheelInfo& wheel):
I don't really understand what this code means. I mean, projVel is the projection of the velocity at the wheel-ground contact point onto the contact normal. This means, it points in the direction of the contact normal. The denominator supposedly is the cosine of the angle between contact normal and wheel direction, and as the contact normal is normally "opposed" (kind of) to the wheel direction, the usual case is the "else" clause. But what exactly is this "inv" variable supposed to mean, and why do you multiply projVel by it? I guess m_suspensionRelativeVelocity should be the velocity in the direction of the suspension spring, but that's not the direction in which projVel points.
Maybe I will find some other parts that are unclear to me. But for now, it would be great if someone could enlighten me on this one.
Thanks in advance!
I'm currently trying to get started with a vehicle simulation using Bullet. I want to start with a raycast vehicle and am currently looking at the btRaycastVehicle code. I have some questions about parts of this code and I hope someone can explain the maths and/or physics to me.
First off, there is this code in btRaycastVehicle::rayCast(btWheelInfo& wheel):
Code: Select all
btScalar denominator= wheel.m_raycastInfo.m_contactNormalWS.dot( wheel.m_raycastInfo.m_wheelDirectionWS );
btVector3 chassis_velocity_at_contactPoint;
btVector3 relpos = wheel.m_raycastInfo.m_contactPointWS-getRigidBody()->getCenterOfMassPosition();
chassis_velocity_at_contactPoint = getRigidBody()->getVelocityInLocalPoint(relpos);
btScalar projVel = wheel.m_raycastInfo.m_contactNormalWS.dot( chassis_velocity_at_contactPoint );
if ( denominator >= btScalar(-0.1))
{
wheel.m_suspensionRelativeVelocity = btScalar(0.0);
wheel.m_clippedInvContactDotSuspension = btScalar(1.0) / btScalar(0.1);
}
else
{
btScalar inv = btScalar(-1.) / denominator;
wheel.m_suspensionRelativeVelocity = projVel * inv;
wheel.m_clippedInvContactDotSuspension = inv;
}
Maybe I will find some other parts that are unclear to me. But for now, it would be great if someone could enlighten me on this one.
Thanks in advance!