diff options
author | Campbell Barton <ideasman42@gmail.com> | 2013-02-19 17:15:34 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2013-02-19 17:15:34 +0400 |
commit | f7848569063386b5925cb692652b584ea8765572 (patch) | |
tree | 9281014985ef7dedd71b95a7abeff03bf50b833d /source/blender/blenlib/intern/math_vector.c | |
parent | 0528162eb691e9d0de39b5f72c427a4d96542f64 (diff) |
make asserts that check for unit length vectors into a macro.
this was really not nice logic to try to fit into an assert.
Diffstat (limited to 'source/blender/blenlib/intern/math_vector.c')
-rw-r--r-- | source/blender/blenlib/intern/math_vector.c | 19 |
1 files changed, 5 insertions, 14 deletions
diff --git a/source/blender/blenlib/intern/math_vector.c b/source/blender/blenlib/intern/math_vector.c index 490ed2a99fb..58d444f5794 100644 --- a/source/blender/blenlib/intern/math_vector.c +++ b/source/blender/blenlib/intern/math_vector.c @@ -235,11 +235,8 @@ float angle_signed_v2v2(const float v1[2], const float v2[2]) float angle_normalized_v3v3(const float v1[3], const float v2[3]) { /* double check they are normalized */ -#ifdef DEBUG - float test; - BLI_assert(fabsf((test = len_squared_v3(v1)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); - BLI_assert(fabsf((test = len_squared_v3(v2)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); -#endif + BLI_ASSERT_UNIT_V3(v1); + BLI_ASSERT_UNIT_V3(v2); /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */ if (dot_v3v3(v1, v2) < 0.0f) { @@ -258,11 +255,8 @@ float angle_normalized_v3v3(const float v1[3], const float v2[3]) float angle_normalized_v2v2(const float v1[2], const float v2[2]) { /* double check they are normalized */ -#ifdef DEBUG - float test; - BLI_assert(fabsf((test = len_squared_v2(v1)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); - BLI_assert(fabsf((test = len_squared_v2(v2)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); -#endif + BLI_ASSERT_UNIT_V2(v1); + BLI_ASSERT_UNIT_V2(v2); /* this is the same as acos(dot_v3v3(v1, v2)), but more accurate */ if (dot_v2v2(v1, v2) < 0.0f) { @@ -449,10 +443,7 @@ void rotate_normalized_v3_v3v3fl(float r[3], const float p[3], const float axis[ const float sintheta = sin(angle); /* double check they are normalized */ -#ifdef DEBUG - float test; - BLI_assert(fabsf((test = len_squared_v3(axis)) - 1.0f) < 0.0001f || fabsf(test) < 0.0001f); -#endif + BLI_ASSERT_UNIT_V3(axis); r[0] = ((costheta + (1 - costheta) * axis[0] * axis[0]) * p[0]) + (((1 - costheta) * axis[0] * axis[1] - axis[2] * sintheta) * p[1]) + |