28 #define dot_Vec2(v) ((v)[0]*(v)[0] + (v)[1]*(v)[1]) 29 #define dot_Vec3(v) ((v)[0]*(v)[0] + (v)[1]*(v)[1] + (v)[2]*(v)[2]) 30 #define dot_Vec4(v) ((v)[0]*(v)[0] + (v)[1]*(v)[1] + (v)[2]*(v)[2] + (v)[3]*(v)[3]) 33 #define mag_Vec2(v) (_SQRT(dot_Vec2(v))) 34 #define mag_Vec3(v) (_SQRT(dot_Vec3(v))) 35 #define mag_Vec4(v) (_SQRT(dot_Vec4(v))) 36 #define mag_Vec2d(v) (sqrt(dot_Vec2(v))) 37 #define mag_Vec3d(v) (sqrt(dot_Vec3(v))) 38 #define mag_Vec4d(v) (sqrt(dot_Vec4(v))) 41 # define recipNorm_Vec2(v) (1.0f/mag_Vec2(v)) 42 # define recipNorm_Vec3(v) (1.0f/mag_Vec3(v)) 43 # define recipNorm_Vec4(v) (1.0f/mag_Vec4(v)) 44 #else // Use fast inverse square root. 0.175% less accurate 45 # define recipNorm_Vec2(v) (invSqrt(dot_Vec2(v))) 46 # define recipNorm_Vec3(v) (invSqrt(dot_Vec3(v))) 47 # define recipNorm_Vec4(v) (invSqrt(dot_Vec4(v))) 49 # define recipNorm_Vec3d(v) (1.0/mag_Vec3d(v)) 50 # define recipNorm_Vec4d(v) (1.0/mag_Vec4d(v)) 52 #define unwrap_Vec3(v) {UNWRAP_RAD_F32(v[0]); UNWRAP_RAD_F32(v[1]); UNWRAP_RAD_F32(v[2]) } 54 #define Vec3_OneLessThan_X(v,x) ( ((v[0])<(x)) || ((v[1])<(x)) || ((v[2])<(x)) ) 55 #define Vec3_OneGrtrThan_X(v,x) ( ((v[0])>(x)) || ((v[1])>(x)) || ((v[2])>(x)) ) 56 #define Vec3_AllLessThan_X(v,x) ( ((v[0])<(x)) && ((v[1])<(x)) && ((v[2])<(x)) ) 57 #define Vec3_AllGrtrThan_X(v,x) ( ((v[0])>(x)) && ((v[1])>(x)) && ((v[2])>(x)) ) 58 #define Vec3_IsAllZero(v) ( ((v[0])==(0.0f)) && ((v[1])==(0.0f)) && ((v[2])==(0.0f)) ) 59 #define Vec3_IsAnyZero(v) ( ((v[0])==(0.0f)) || ((v[1])==(0.0f)) || ((v[2])==(0.0f)) ) 60 #define Vec3_IsAnyNonZero(v) ( ((v[0])!=(0.0f)) || ((v[1])!=(0.0f)) || ((v[2])!=(0.0f)) ) 62 #define set_Vec3_X(v,x) { (v[0])=(x); (v[1])=(x); (v[2])=(x); } 63 #define set_Vec4_X(v,x) { (v[0])=(x); (v[1])=(x); (v[2])=(x); (v[3])=(x); } 94 const unsigned int * x = (
const unsigned int*) f;
105 static __inline
float invSqrt(
float number)
109 volatile const float f = 1.5F;
113 i = * ((
long * ) &y);
114 i = 0x5f375a86 - ( i >> 1 );
115 y = * ((
float * ) &i);
116 y = y * ( f - ( x * y * y ) );
134 void mul_MatMxN(
void * result,
const void * A_ptr,
const void * B_ptr,
i_t m,
i_t n,
i_t p,
char transpose_B,
char add );
367 result[0] =
_MIN(v1[0], v2[0]);
368 result[1] =
_MIN(v1[1], v2[1]);
369 result[2] =
_MIN(v1[2], v2[2]);
377 result[0] =
_MAX(v1[0], v2[0]);
378 result[1] =
_MAX(v1[1], v2[1]);
379 result[2] =
_MAX(v1[2], v2[2]);
411 memset( v, 0,
sizeof(
f_t )*n );
419 memset( M, 0,
sizeof(
f_t )*m*n );
436 result[0] = (double)v[0];
437 result[1] = (double)v[1];
438 result[2] = (double)v[2];
442 result[0] = (
f_t)v[0];
443 result[1] = (
f_t)v[1];
444 result[2] = (
f_t)v[2];
452 memcpy( result, v,
sizeof(
f_t )*n );
468 result[0] = (double)v[0];
469 result[1] = (double)v[1];
470 result[2] = (double)v[2];
471 result[3] = (double)v[3];
475 result[0] = (
f_t)v[0];
476 result[1] = (
f_t)v[1];
477 result[2] = (
f_t)v[2];
478 result[3] = (
f_t)v[3];
486 memcpy( result, M,
sizeof(
f_t )*m*n );
620 for( i=0; i<size; i++ )
637 for( i=0; i<size; i++ )
646 #if defined(PLATFORM_IS_WINDOWS) 647 #pragma warning( push ) 648 #pragma warning( disable : 4723) 659 f_t inf = 1.0f / ( tmp - 1.0f);
661 for( i=0; i<size; i++ )
679 double inf = 1.0f / (tmp - 1.0f);
681 for (i = 0; i<size; i++)
690 #if defined(PLATFORM_IS_WINDOWS) 691 #pragma warning( pop )
void mul_Vec4_X(ixVector4 result, const ixVector4 v, const f_t x)
static __inline void cpy_Vec3d_Vec3d(ixVector3d result, const ixVector3d v)
#define recipNorm_Vec4d(v)
void mul_Mat4x4_Trans_Vec4x1(ixVector4 result, const ixMatrix4 m, const ixVector4 v)
static __inline void cpy_Vec3d_Vec3(ixVector3d result, const ixVector3 v)
void abs_Vec2(ixVector2 result, const ixVector2 v)
void mul_Mat3x3_Trans_Vec3x1(ixVector3 result, const ixMatrix3 m, const ixVector3 v)
void mul_Vec2d_X(ixVector2d result, const ixVector2d v, const double x)
static __inline int isFinite_array_d(double *a, int size)
void add_Vec3_Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2)
void abs_Vec4(ixVector4 result, const ixVector4 v)
static __inline int is_equal_Vec2(const ixVector2 v1, const ixVector2 v2)
static __inline void zero_MatMxN(f_t *M, i_t m, i_t n)
void sub_Vec3d_Vec3d(ixVector3d result, const ixVector3d v1, const ixVector3d v2)
void sub_Vec3_Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2)
static __inline f_t max_Vec3_X(const ixVector3 v)
f_t dot_Vec2_Vec2(const ixVector2 v1, const ixVector2 v2)
void mul_Mat2x2_Trans_Vec2x1(ixVector2 result, const ixMatrix2 m, const ixVector2 v)
void trans_MatMxN(f_t *result, const f_t *M, int m, int n)
#define recipNorm_Vec4(v)
void div_Vec3_X(ixVector3 result, const ixVector3 v, const f_t x)
void abs_Vec3d(ixVector3d result, const ixVector3d v)
#define recipNorm_Vec2(v)
static __inline void cpy_Vec3_Vec3d(ixVector3 result, const ixVector3d v)
static __inline void limit2_Vec3(ixVector3 v, f_t min, f_t max)
void mul_Mat3x3_Trans_Mat3x3(ixMatrix3 result, const ixMatrix3 m1, const ixMatrix3 m2)
void mul_Mat2x2_Vec2x1(ixVector2 result, const ixMatrix2 m, const ixVector2 v)
static __inline int isInf_array(f_t *a, int size)
void add_Vec3d_Vec3d(ixVector3d result, const ixVector3d v1, const ixVector3d v2)
static __inline void O1_LPF_Vec3(ixVector3 result, const ixVector3 input, ixVector3 c1, f_t alph, f_t beta, f_t dt)
#define max(a, b)
Takes the maximal value of a and b.
static __inline int isFinite_array(f_t *a, int size)
void mul_Mat3x3_Mat3x3_Trans_d(ixMatrix3d result, const ixMatrix3d m1, const ixMatrix3d m2)
bool add(const actionlib::TwoIntsGoal &req, actionlib::TwoIntsResult &res)
void mul_Mat4x4_Vec4x1(ixVector4 result, const ixMatrix4 m, const ixVector4 v)
void mul_Mat3x3_Mat3x3(ixMatrix3 result, const ixMatrix3 m1, const ixMatrix3 m2)
void eye_MatN(f_t *A, i_t n)
void mul_Vec3_X(ixVector3 result, const ixVector3 v, const f_t x)
void mul_Vec3d_X(ixVector3d result, const ixVector3d v, const double x)
f_t dot_Vec4_Vec4(const ixVector4 v1, const ixVector4 v2)
static __inline char is_zero(const f_t *f)
static __inline f_t min_Vec3_X(const ixVector3 v)
char inv_Mat4(ixMatrix4 result, const ixMatrix4 m)
void crossd_Vec3(ixVector3d result, const ixVector3 v1, const ixVector3 v2)
void add_Vec4_Vec4(ixVector4 result, const ixVector4 v1, const ixVector4 v2)
#define _LIMIT2(x, xmin, xmax)
void transpose_Mat2(ixMatrix2 result, const ixMatrix2 m)
static __inline int isNan_array(f_t *a, int size)
static __inline void min_Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2)
void div_Vec4d_X(ixVector4d result, const ixVector4d v, const double x)
static __inline void cpy_MatMxN(f_t *result, const f_t *M, i_t m, i_t n)
static __inline void normalize_Vec3(ixVector3 result, const ixVector3 v)
void abs_Vec2d(ixVector2d result, const ixVector2d v)
void LPFO0_init_Vec3(sLpfO0 *lpf, f_t dt, f_t cornerFreqHz, const ixVector3 initVal)
void mul_Mat3x3_Mat3x3_Trans(ixMatrix3 result, const ixMatrix3 m1, const ixMatrix3 m2)
void cpy_MatRxC_MatMxN(f_t *result, i_t r, i_t c, i_t r_offset, i_t c_offset, f_t *A, i_t m, i_t n)
static __inline void zero_Vec3d(ixVector3d v)
double dot_Vec3d_Vec3d(const ixVector3d v1, const ixVector3d v2)
static __inline int is_equal_Vec3(const ixVector3 v1, const ixVector3 v2)
static __inline void zero_VecN(f_t *v, i_t n)
static __inline int is_equal_Vec4(const ixVector4 v1, const ixVector4 v2)
void div_Vec3_Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2)
static __inline void cpy_Vec4d_Vec4d(ixVector4d result, const ixVector4d v)
static __inline void cpy_Vec4d_Vec4(ixVector4d result, const ixVector4 v)
void div_Vec4_Vec4(ixVector4 result, const ixVector4 v1, const ixVector4 v2)
void mul_Vec4_Vec4(ixVector4 result, const ixVector4 v1, const ixVector4 v2)
void mul_Vec4d_X(ixVector4d result, const ixVector4d v, const double x)
static __inline void zero_Vec4(ixVector4 v)
static __inline void limit_Vec3(ixVector3 v, f_t limit)
static __inline void normalize_Vec2(ixVector2 v)
static __inline void O0_LPF_Vec3(ixVector3 result, const ixVector3 input, f_t alph, f_t beta)
char inv_Mat3(ixMatrix3 result, const ixMatrix3 m)
void mul_Mat3x3_Trans_Mat3x3_d(ixMatrix3d result, const ixMatrix3d m1, const ixMatrix3d m2)
void transpose_Mat4(ixMatrix4 result, const ixMatrix4 m)
void sub_Vec4_Vec4(ixVector4 result, const ixVector4 v1, const ixVector4 v2)
void div_Vec4_X(ixVector4 result, const ixVector4 v, const f_t x)
char inv_Mat2(ixMatrix2 result, ixMatrix2 m)
void mul_Vec3_Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2)
void abs_Vec3(ixVector3 result, const ixVector3 v)
#define recipNorm_Vec3(v)
static __inline void cpy_Vec4_Vec4(ixVector4 result, const ixVector4 v)
void transpose_Mat3(ixMatrix3 result, const ixMatrix3 m)
void mul_Vec2_X(ixVector2 result, const ixVector2 v, const f_t x)
static __inline void zero_Vec3(ixVector3 v)
static __inline void max_Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2)
void sqrt_Vec4(ixVector4 result, const ixVector4 v)
static __inline void cpy_Vec4_Vec4d(ixVector4 result, const ixVector4d v)
static __inline void cpy_VecN_VecN(f_t *result, const f_t *v, i_t n)
static __inline int isNan_array_d(double *a, int size)
void add_Vec4d_Vec4d(ixVector4d result, const ixVector4d v1, const ixVector4d v2)
static __inline void zero_Vec4d(ixVector4d v)
void LPFO0_Vec3(sLpfO0 *lpf, const ixVector3 input)
void neg_Vec3(ixVector3 result, const ixVector3 v)
static __inline void normalize_Vec4d(ixVector4d result, const ixVector4d v)
void abs_Vec4d(ixVector4d result, const ixVector4d v)
char inv_MatN(f_t *result, const f_t *M, i_t n)
void cross_Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2)
void mul_Mat3x3_Vec3x1(ixVector3 result, const ixMatrix3 m, const ixVector3 v)
static __inline int isInf_array_d(double *a, int size)
void add_K1Vec3_K2Vec3(ixVector3 result, const ixVector3 v1, const ixVector3 v2, float k1, float k2)
static __inline void normalize_Vec4(ixVector4 result, const ixVector4 v)
void mul_Mat3x3_Mat3x3_d(ixMatrix3d result, const ixMatrix3d m1, const ixMatrix3d m2)
void neg_Mat3x3(ixMatrix3 result, const ixMatrix3 m)
f_t dot_Vec3_Vec3(const ixVector3 v1, const ixVector3 v2)
void sqrt_Vec3(ixVector3 result, const ixVector3 v)
static __inline void cpy_Vec3_Vec3(ixVector3 result, const ixVector3 v)
void mul_Vec3x1_Vec1x3(ixMatrix3 result, const ixVector3 v1, const ixVector3 v2)
void mul_MatMxN(void *result, const void *A_ptr, const void *B_ptr, i_t m, i_t n, i_t p, char transpose_B, char add)