How does setEulerZYX function work?

Post Reply
Manish Bista
Posts: 6
Joined: Wed Feb 11, 2015 2:04 am

How does setEulerZYX function work?

Post by Manish Bista »

I have been looking into the RagdollDemo and have kind of got stuck in the part where setEulerZYX() is used in basis matrix.

Code: Select all

transform.setIdentity();
		transform.setOrigin(btVector3(btScalar(-0.35), btScalar(1.45), btScalar(0.)));
		transform.getBasis().setEulerZYX(0,0,M_PI_2);
		m_bodies[BODYPART_LEFT_UPPER_ARM] = localCreateRigidBody(btScalar(1.), offset*transform, m_shapes[BODYPART_LEFT_UPPER_ARM]);
I did some research, yet couldn`t understand what exactly does this function do and why it is needed. Any help would be very nice.
User avatar
drleviathan
Posts: 849
Joined: Tue Sep 30, 2014 6:03 pm
Location: San Francisco

Re: How does setEulerZYX function work?

Post by drleviathan »

The code is using btMatrix3::setEulterZYX(x, y, z) to build a 3x3 matric whose values represent a rotation of PI/2 (aka 90 degrees) about the z-axis. The rotation is being used to initialize the transform of the btRigidBody that corredponds to the upper left arm.

The upper left arm is probably using a btCapsule shape, which means by default its axis lies parallel to the y-axis (up). After a 90 degree rotation about the z-axis (using the right hand rule) the capsule should lie parallel to the x-axis, pointing in the negative direction.

Try changing the angle value from 1.0 * M_PI_2 to be 0.5 * M_PI_2 or 0.25 * M_PI_2 to see how it changes the position of the left arm.
Post Reply