So I have a program where, ideally, I can roll a ball around by applying a torque around the axis.
So I have two functions:
EDIT: It should be noted that "^" is my cross-product operator.
void AddForce(const CEVector3 &f, const CEVector3 &point)
{
m_forces += f;
m_torques += (point - m_center) ^ f;
}
void AddTorque(const CEVector3 &axis, float amount)
{
m_torques += axis * amount;
}
Adding torque about the axis (Through the center of mass, always) doesn't affect the linear force (consider it two forces on opposite ends of the sphere, pointing in opposite directions orthogonal to the axis of rotation)
I currently assume an infinite coefficient of static friction (no slip. Ever.) So to get the amount of friction to apply, I need to know how much force is being applied tangentially to the surface:
CEVector3 GetForceAtPoint(const CEVector3 &pt)
{
CEVector3 dir = pt-m_center;
return m_forces + (m_torques ^ dir) / dir.LengthSquared();
}
So this gets the force at a given point on the ball (I'm doing points instead of radius because I'm going to generalize this for non-ball objects eventually).
I can't remember the logic behind how I came to that little equation, but it seems to do the trick. So the friction pushes back on the ball in the opposite direction at that point.
However, if I simply call:
AddForce(-GetForceAtPoint(pt), pt)
the ball moves the correct direction at the correct speed, but the addition of the force cancels out the rotation. Now, if I only apply the force to the linear force (it doesn't affect the torque, or it's not added to m_torques), then it works correctly.
Either I have a concept wrong, or this friction really shouldn't affect the torque. Can anyone explain this to me? I'm immensely confused.
[Edited by - Drilian on December 25, 2004 12:13:34 AM]