diff options
author | Campbell Barton <ideasman42@gmail.com> | 2014-11-22 20:11:46 +0300 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2014-11-22 20:21:52 +0300 |
commit | 25c5542fe78abe79cdf9d2ec46607de01762f32e (patch) | |
tree | fd88140b57603458ca6251d1f1dcb3d6b0e40c26 | |
parent | 789eaa0f5bda185d78e25d4fd252054c9f39e955 (diff) |
Math Lib: add constant: M_SQRT1_3 1/sqrt(3)
-rw-r--r-- | source/blender/blenlib/BLI_math_base.h | 9 | ||||
-rw-r--r-- | source/blender/blenlib/intern/math_matrix.c | 4 | ||||
-rw-r--r-- | source/blender/bmesh/tools/bmesh_bevel.c | 7 |
3 files changed, 10 insertions, 10 deletions
diff --git a/source/blender/blenlib/BLI_math_base.h b/source/blender/blenlib/BLI_math_base.h index 5711d09b530..13718e83621 100644 --- a/source/blender/blenlib/BLI_math_base.h +++ b/source/blender/blenlib/BLI_math_base.h @@ -48,13 +48,16 @@ #define M_PI_2 1.57079632679489661923 #endif #ifndef M_SQRT2 -#define M_SQRT2 1.41421356237309504880 +#define M_SQRT2 1.41421356237309504880 /* sqrt(2) */ #endif #ifndef M_SQRT1_2 -#define M_SQRT1_2 0.70710678118654752440 +#define M_SQRT1_2 0.70710678118654752440 /* 1/sqrt(2) */ #endif #ifndef M_SQRT3 -#define M_SQRT3 1.7320508075688772 +#define M_SQRT3 1.73205080756887729352 /* sqrt(3) */ +#endif +#ifndef M_SQRT1_3 +#define M_SQRT1_3 0.57735026918962576450 /* 1/sqrt(3) */ #endif #ifndef M_1_PI #define M_1_PI 0.318309886183790671538 diff --git a/source/blender/blenlib/intern/math_matrix.c b/source/blender/blenlib/intern/math_matrix.c index 0204c3bc86c..2da1f225034 100644 --- a/source/blender/blenlib/intern/math_matrix.c +++ b/source/blender/blenlib/intern/math_matrix.c @@ -1448,7 +1448,7 @@ float mat3_to_scale(float mat[3][3]) { /* unit length vector */ float unit_vec[3]; - copy_v3_fl(unit_vec, (float)(1.0 / M_SQRT3)); + copy_v3_fl(unit_vec, (float)M_SQRT1_3); mul_m3_v3(mat, unit_vec); return len_v3(unit_vec); } @@ -1457,7 +1457,7 @@ float mat4_to_scale(float mat[4][4]) { /* unit length vector */ float unit_vec[3]; - copy_v3_fl(unit_vec, (float)(1.0 / M_SQRT3)); + copy_v3_fl(unit_vec, (float)M_SQRT1_3); mul_mat3_m4_v3(mat, unit_vec); return len_v3(unit_vec); } diff --git a/source/blender/bmesh/tools/bmesh_bevel.c b/source/blender/bmesh/tools/bmesh_bevel.c index 99ff6996b71..c3d1ca86fbf 100644 --- a/source/blender/bmesh/tools/bmesh_bevel.c +++ b/source/blender/bmesh/tools/bmesh_bevel.c @@ -2229,7 +2229,6 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) BoundVert *bndv; int i, j, k, ns2; float co[3], coc[3]; - float w; if (r == PRO_SQUARE_R) return make_cube_corner_straight(mem_arena, nseg); @@ -2262,10 +2261,8 @@ static VMesh *make_cube_corner_adj_vmesh(BevelParams *bp) bndv = bndv->next; } /* center vertex */ - w = (float)(1.0 / M_SQRT3); - co[0] = w; - co[1] = w; - co[2] = w; + copy_v3_fl(co, M_SQRT1_3); + if (nseg > 2) { if (r > 1.5f) mul_v3_fl(co, 1.4f); |