Local Pitch, roll, yaw - SOLVED

sipickles
Posts: 44
Joined: Thu Aug 07, 2008 6:57 am

Local Pitch, roll, yaw - SOLVED

Post by sipickles »

Seeing as rigidBody::applyTorque() acts in world space, how can I rotate an object around its local axes?

Effectively, I am looking for a way to produce Pitch Roll and Yaw movement.

Thanks

Simon
Last edited by sipickles on Tue Sep 02, 2008 7:15 pm, edited 1 time in total.
AxeD
Posts: 36
Joined: Tue Jun 17, 2008 8:28 pm

Re: Another rotation question

Post by AxeD »

Hi,
can You try this?

Code: Select all

btTransform	trans;
	btQuaternion	quat;

	trans.setOrigin(btVector(0.0f, 0.0f, 0.0f)); //translation

	quat.setEuler(0.0f, 0.0f, 0.0f);//rotation
	trans.setRotation(quat);

	btRigidBody* body = new btRigidBody(rbInfo);
	body->setWorldTransform(trans);
Best regards
sipickles
Posts: 44
Joined: Thu Aug 07, 2008 6:57 am

Re: Another rotation question

Post by sipickles »

Thanks for the reply
AxeD wrote:

Code: Select all

	body->setWorldTransform(trans);
This is overriding the position and rotation of the object. I am wanting to apply forces to the object instead, just as ailerons or a rudder might do....
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Another rotation question

Post by sparkprime »

Are you sure torques are in world space? That seems unhelpful. I admit I've only applied forces myself.

I would have applied a force to each wing personally. Then you can simulate what happens when one of the wings is damaged :)
sipickles
Posts: 44
Joined: Thu Aug 07, 2008 6:57 am

Re: Another rotation question

Post by sipickles »

I still think apply forces to the wings would suffer the same problem.

A wing applies a force relative to its local orientation, not the world space.

Perhaps one approach is to get the orientation quaternion of an object and transform the force by this. This converts the force in local space to its XYZ component forces in world space.... i think!

Am I correct here?

Thanks
sparkprime
Posts: 508
Joined: Fri May 30, 2008 2:51 am
Location: Ossining, New York

Re: Another rotation question

Post by sparkprime »

You can convert a vector between a body's model space and world space using the body's btTransform. This includes both the position and orientation of the body.

http://www.continuousphysics.com/Bullet ... sform.html

If you want to convert a quaternion between body and world space, you only need the rotation part of the transform, i.e. the "basis" -- no idea why it's called that.
sipickles
Posts: 44
Joined: Thu Aug 07, 2008 6:57 am

Re: Another rotation question

Post by sipickles »

Thanks Sparkprime, o bullet master.

That is perfect!