Page 1 of 1

How does setEulerZYX function work?

Posted: Thu Feb 12, 2015 6:02 pm
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.

Re: How does setEulerZYX function work?

Posted: Fri Feb 13, 2015 12:45 am
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.