Fix for bug #5250: inaccurate conversion between edit and pose mode bones.

Using acos(dot(u, v)) to find the angle between two vectors is quite
inaccurate, and there's a better way to do it, as explained here:
http://www.plunk.org/~hatch/rightway.php

Also changed the use of atan for computing roll to atan2 in some places,
the latter avoids accuracy and division by zero issues.
This commit is contained in:
2006-11-18 23:07:32 +00:00
parent 904dfcc6a2
commit 2bb9d5471e
5 changed files with 46 additions and 16 deletions

View File

@@ -69,7 +69,7 @@ static double boneRoll_ToArmatureSpace(struct Bone *bone)
Mat3Inv(imat, postmat);
Mat3MulMat3(difmat, imat, premat);
roll = atan(difmat[2][0] / difmat[2][2]);
roll = atan2(difmat[2][0], difmat[2][2]);
if (difmat[0][0] < 0.0){
roll += M_PI;
}