more work on PyBullet implementation of DeepMimic humanoid mimic of motion capture.

b3Quaternion, deal with zero-length axis (in axis,angle constructor)
This commit is contained in:
erwincoumans
2018-11-21 11:09:10 -08:00
parent f93e4e4553
commit 121cdc91b0
3 changed files with 300 additions and 79 deletions

View File

@@ -96,9 +96,16 @@ public:
{
b3Scalar d = axis.length();
b3Assert(d != b3Scalar(0.0));
b3Scalar s = b3Sin(_angle * b3Scalar(0.5)) / d;
setValue(axis.getX() * s, axis.getY() * s, axis.getZ() * s,
b3Cos(_angle * b3Scalar(0.5)));
if (d < B3_EPSILON)
{
setValue(0, 0, 0, 1);
}
else
{
b3Scalar s = b3Sin(_angle * b3Scalar(0.5)) / d;
setValue(axis.getX() * s, axis.getY() * s, axis.getZ() * s,
b3Cos(_angle * b3Scalar(0.5)));
}
}
/**@brief Set the quaternion using Euler angles
* @param yaw Angle around Y