rsys

Basic data structures and low-level features
git clone git://git.meso-star.fr/rsys.git
Log | Files | Refs | README | LICENSE

commit 08765974b090c1c46b4edaf51b1738354aa5c303
parent 33f1ae10ae8455f4733b0ec25b43f704c35a3b30
Author: vaplv <vaplv@free.fr>
Date:   Mon, 14 Dec 2015 11:19:59 +0100

Fix the f33_basis function

An error may occur if the returned basis aliased the submitted normal.

Diffstat:
Msrc/float33.h | 8++++----
Msrc/test_float22.c | 12++++++------
Msrc/test_float33.c | 14+++++++-------
Msrc/test_float44.c | 12++++++------
4 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/src/float33.h b/src/float33.h @@ -19,7 +19,6 @@ #include "float3.h" #include <math.h> - /* Generate common floatXY funcs */ #define FLOATX_DIMENSION__ 3 #define FLOATY_DIMENSION__ 3 @@ -154,10 +153,11 @@ f33_rotation_roll(float dst[9], const float roll/* in radian */) } static INLINE float* -f33_basis(float dst[9], const float normal[3]) +f33_basis(float dst[9], const float N[3]) { - float a[3], b[3], x[3], y[3], len; - ASSERT(normal); + float a[3], b[3], x[3], y[3], normal[3], len; + ASSERT(N); + f3_set(normal, N); f3_cross(a, f3(a, 1.f, 0.f, 0.f), normal); f3_cross(b, f3(b, 0.f, 1.f, 0.f), normal); len = f3_normalize(x, f3_dot(a, a) > f3_dot(b, b) ? a : b); diff --git a/src/test_float22.c b/src/test_float22.c @@ -21,17 +21,17 @@ { \ const float* a__ = (A); \ const float* b__ = (B); \ - int i__; \ - FOR_EACH(i__, 0, 2) \ - CHECK(a__[i__], b__[i__]); \ + int i__; \ + FOR_EACH(i__, 0, 2) \ + CHECK(a__[i__], b__[i__]); \ } (void)0 #define CHECK_F22(A, B) \ { \ const float* a__ = (A); \ const float* b__ = (B); \ - int i__; \ - FOR_EACH(i__, 0, 4) \ - CHECK(a__[i__], b__[i__]); \ + int i__; \ + FOR_EACH(i__, 0, 4) \ + CHECK(a__[i__], b__[i__]); \ } (void)0 int diff --git a/src/test_float33.c b/src/test_float33.c @@ -21,17 +21,17 @@ { \ const float* a__ = (A); \ const float* b__ = (B); \ - int i__; \ - FOR_EACH(i__, 0, 3) \ - CHECK(a__[i__], b__[i__]); \ + int i__; \ + FOR_EACH(i__, 0, 3) \ + CHECK(a__[i__], b__[i__]); \ } (void)0 #define CHECK_F33(A, B) \ { \ const float* a__ = (A); \ const float* b__ = (B); \ - int i__; \ - FOR_EACH(i__, 0, 9) \ - CHECK(a__[i__], b__[i__]); \ + int i__; \ + FOR_EACH(i__, 0, 9) \ + CHECK(a__[i__], b__[i__]); \ } (void)0 int @@ -173,7 +173,7 @@ main(int argc, char** argv) f3(c, 0.666667f, 0.333333f, 0.666667f); f33_rotation_axis_angle(a, c, 0.349066f); - CHECK(f33_eq_eps(a, f33(c, + CHECK(f33_eq_eps(a, f33(c, 0.966496f, 0.241415f, -0.0872034f, -0.214612f, 0.946393f, 0.241415f, 0.14081f, -0.214612f, 0.966496f), 1.e-6f), 1); diff --git a/src/test_float44.c b/src/test_float44.c @@ -21,17 +21,17 @@ { \ const float* a__ = (A); \ const float* b__ = (B); \ - int i__; \ - FOR_EACH(i__, 0, 4) \ - CHECK(a__[i__], b__[i__]); \ + int i__; \ + FOR_EACH(i__, 0, 4) \ + CHECK(a__[i__], b__[i__]); \ } (void)0 #define CHECK_F44(A, B) \ { \ const float* a__ = (A); \ const float* b__ = (B); \ - int i__; \ - FOR_EACH(i__, 0, 16) \ - CHECK(a__[i__], b__[i__]); \ + int i__; \ + FOR_EACH(i__, 0, 16) \ + CHECK(a__[i__], b__[i__]); \ } (void)0 int