Torque around an axle

Official forum for the Chipmunk2D Physics Library.
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Torque around an axle

Post 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.
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Torque around an axle

Post 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.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Torque around an axle

Post 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.
supertommy
Posts: 56
Joined: Tue Sep 11, 2007 2:30 pm
Contact:

Re: Torque around an axle

Post 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.
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Torque around an axle

Post 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.
supertommy
Posts: 56
Joined: Tue Sep 11, 2007 2:30 pm
Contact:

Re: Torque around an axle

Post 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?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Torque around an axle

Post 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)
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Torque around an axle

Post 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.
supertommy
Posts: 56
Joined: Tue Sep 11, 2007 2:30 pm
Contact:

Re: Torque around an axle

Post 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;
}
maximile
Posts: 157
Joined: Mon Aug 20, 2007 12:53 pm
Location: London, UK
Contact:

Re: Torque around an axle

Post by maximile »

just tried, seems to work great! I'll post videos when I get my computer back on the net.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 8 guests