diff options
author | Ton Roosendaal <ton@blender.org> | 2005-10-30 23:56:19 +0300 |
---|---|---|
committer | Ton Roosendaal <ton@blender.org> | 2005-10-30 23:56:19 +0300 |
commit | 41c5328dd4efdb8d75843b118c79a165831a4762 (patch) | |
tree | 136021ebb5c1ff6aff71d17d4e66b90918f12755 /source/blender/blenlib | |
parent | 99753a423f62172a2000f01b9988d34c3d9618cd (diff) |
Two half working commits!
- Python Drivers
In Ipo Window "transform properties" Panel, added the buttons, and the
initial handling (now only printing text). Willian makes it work!
- Better Matrix to Eul, code submitted by Brecht. No time yet to do it
really nice (like a Mat3ToEulCompat(mat, eul, eulc))
Diffstat (limited to 'source/blender/blenlib')
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index ad2d5c1e458..0cc98a3b429 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2170,9 +2170,24 @@ void Mat3ToEul(float tmat[][3], float *eul) cy = (float)sqrt(mat[0][0]*mat[0][0] + mat[0][1]*mat[0][1]); if (cy > 16.0*FLT_EPSILON) { - eul[0] = (float)atan2(mat[1][2], mat[2][2]); - eul[1] = (float)atan2(-mat[0][2], cy); - eul[2] = (float)atan2(mat[0][1], mat[0][0]); + float eul1[3], eul2[3]; + + eul1[0] = (float)atan2(mat[1][2], mat[2][2]); + eul1[1] = (float)atan2(-mat[0][2], cy); + eul1[2] = (float)atan2(mat[0][1], mat[0][0]); + + eul2[0] = (float)atan2(-mat[1][2], -mat[2][2]); + eul2[1] = (float)atan2(-mat[0][2], -cy); + eul2[2] = (float)atan2(-mat[0][1], -mat[0][0]); + + /* return best, which is just the one with lowest values it in */ + if( fabs(eul1[0])+fabs(eul1[1])+fabs(eul1[2]) > fabs(eul2[0])+fabs(eul2[1])+fabs(eul2[2])) { + VecCopyf(eul, eul2); + } + else { + VecCopyf(eul, eul1); + } + } else { eul[0] = (float)atan2(-mat[2][1], mat[1][1]); eul[1] = (float)atan2(-mat[0][2], cy); |