Page 1 of 2

Torque around an axle

Posted: Wed May 28, 2008 3:46 am
by maximile
Is there any way to apply torque around a point? Does that make sense in real-life physics? For example, in the moon buggy tutorial, when torque is applied to the wheel and the opposite is applied to the body isn't it wrong for the body? Shouldn't it be applied around the axle? And can this be accomplished in Chipmunk?

I'm trying to make an easy way for pivot joints to become motors.

Re: Torque around an axle

Posted: Wed May 28, 2008 12:33 pm
by slembcke
Hmm. Never thought about that before actually. Now that I am thinking about it, it might be more correct to adjust the torque according to the moment of inertia around the point the torque is applied to.

Re: Torque around an axle

Posted: Sat May 31, 2008 9:36 am
by maximile
Thanks for the reply. It's good to know I wasn't missing something obvious.

Just to clarify, this isn't something I can currently do in Chipmunk? Can anyone think of a way to fake it? I was thinking of trying to apply forces perpendicular to the vector between the pivot and the object, and relative to the mass of the other object. But I don't think that's right, because it could result in an acceleration of the whole construct.

Re: Torque around an axle

Posted: Mon Jun 02, 2008 5:40 am
by supertommy
Do you think it would work to apply a regular force on both sides of the pivot? One force upwards and the other downwards, for example. I've unleashed my inkscape skillz and created a potentially illustrative attachment.

Re: Torque around an axle

Posted: Mon Jun 02, 2008 9:51 pm
by maximile
I was thinking about that, but that seemed wrong because at times both forces would be pointing in the same direction, which would accelerate the whole construct.

Re: Torque around an axle

Posted: Tue Jun 03, 2008 7:20 am
by supertommy
I actually intended both the forces in the drawing to be applied to just one of the bodies. (And an inverse pair of forces to be applied to the other body.) I haven't tested this out, but if I have time, I will. I'm thinking something like this:

Code: Select all

static inline void
cpBodyApplyInstantTorque(cpBody *body, float torque, cpVect r)
{
    cpBodyApplyImpulse(cpBody *body, cpv(torque, 0.0), cpv(r.x - 1.0f, r.y));
    cpBodyApplyImpulse(cpBody *body, cpv(-torque, 0.0), cpv(r.x + 1.0f, r.y));
}
And

Code: Select all

cpBodyApplyInstantTorque(wheel, 10.0, wheelPosition);
cpBodyApplyInstantTorque(car, -10.0, wheelPosition);
It's not pretty, but maybe it would work?

Re: Torque around an axle

Posted: Tue Jun 03, 2008 10:42 am
by slembcke
Oh, forgot to post last night. Applying forces like was suggested would work just fine. Though the math behind it is very simple and easy to show that it's exactly the same as adding directly to the torque.

So to answer the original post, there is no such thing as applying torque around an axis. Torque is just torque. (apparently)

Re: Torque around an axle

Posted: Tue Jun 03, 2008 1:09 pm
by maximile
supertommy: Ah, thanks for clarifying that. Yeah, looks like it would work.

slembcke: Ok, thanks. Thinking about it, I can see how this would be true, even though my brain wants to tell me it's not.

Re: Torque around an axle

Posted: Wed Jun 04, 2008 1:19 am
by supertommy
slembcke wrote:So to answer the original post, there is no such thing as applying torque around an axis. Torque is just torque. (apparently)
So, in order to make a "cpMotorJoint" could you just extend the pivot joint and give it this simple function?

Code: Select all

void
cpMotorJointSetTorque(cpMotorJoint *joint, float torque)
{
    joint->joint->a->t -= joint->torque;
    joint->joint->b->t += joint->torque;

    joint->torque = torque;

    joint->joint->a->t += joint->torque;
    joint->joint->b->t -= joint->torque;
}

Re: Torque around an axle

Posted: Sun Jun 08, 2008 3:29 pm
by maximile
just tried, seems to work great! I'll post videos when I get my computer back on the net.