diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-09-03 02:53:59 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-09-03 02:53:59 +0400 |
commit | 04a2eb2e4e95c1d87c384e69f4c3ed3a6b3552f3 (patch) | |
tree | 1312fdd3394cbac2b39b290fdd2840b0ff74b7de /source/blender/blenlib/intern | |
parent | b1c30dff885aa31417ec0389c479570ad0394967 (diff) |
adding 2 new functions
Mat3ToScalef and Mat4ToScalef
These return a floating point scale value which is the average of the 3 axies.
Use this to adjust curve radius when applying scale/rot
Diffstat (limited to 'source/blender/blenlib/intern')
-rw-r--r-- | source/blender/blenlib/intern/arithb.c | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/source/blender/blenlib/intern/arithb.c b/source/blender/blenlib/intern/arithb.c index 72e18b3f1da..d93f4b9c009 100644 --- a/source/blender/blenlib/intern/arithb.c +++ b/source/blender/blenlib/intern/arithb.c @@ -2866,6 +2866,25 @@ void Mat4ToSize( float mat[][4], float *size) size[2]= VecLength(mat[2]); } +/* this gets the average scale of a matrix, only use when your scaling + * data that has no idea of scale axis, examples are bone-envelope-radius + * and curve radius */ +float Mat3ToScalef(float mat[][3]) +{ + /* unit length vector */ + float unit_vec[3] = {0.577350269189626, 0.577350269189626, 0.577350269189626}; + Mat3MulVecfl(mat, unit_vec); + return VecLength(unit_vec); +} + +float Mat4ToScalef(float mat[][4]) +{ + float tmat[3][3]; + Mat3CpyMat4(tmat, mat); + return Mat3ToScalef(tmat); +} + + /* ************* SPECIALS ******************* */ void triatoquat( float *v1, float *v2, float *v3, float *quat) @@ -3581,4 +3600,3 @@ void LocQuatSizeToMat4(float mat[][4], float loc[3], float quat[4], float size[3 mat[3][1] = loc[1]; mat[3][2] = loc[2]; } - |