1 /* 2 $License: 3 Copyright 2011 InvenSense, Inc. 4 5 Licensed under the Apache License, Version 2.0 (the "License"); 6 you may not use this file except in compliance with the License. 7 You may obtain a copy of the License at 8 9 http://www.apache.org/licenses/LICENSE-2.0 10 11 Unless required by applicable law or agreed to in writing, software 12 distributed under the License is distributed on an "AS IS" BASIS, 13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 See the License for the specific language governing permissions and 15 limitations under the License. 16 $ 17 */ 18 #ifndef INVENSENSE_INV_MATH_FUNC_H__ 19 #define INVENSENSE_INV_MATH_FUNC_H__ 20 #ifdef INV_INCLUDE_LEGACY_HEADERS 21 #include "mlMathFunc_legacy.h" 22 #endif 23 24 #define NUM_ROTATION_MATRIX_ELEMENTS (9) 25 #define ROT_MATRIX_SCALE_LONG (1073741824) 26 #define ROT_MATRIX_SCALE_FLOAT (1073741824.0f) 27 #define ROT_MATRIX_LONG_TO_FLOAT( longval ) \ 28 ((float) ((longval) / ROT_MATRIX_SCALE_FLOAT )) 29 #define SIGNM(k)((int)(k)&1?-1:1) 30 31 #ifdef __cplusplus 32 extern "C" { 33 #endif 34 struct filter_long { 35 int length; 36 const long *b; 37 const long *a; 38 long *x; 39 long *y; 40 }; 41 42 void inv_filter_long(struct filter_long *state, long x); 43 long inv_q29_mult(long a, long b); 44 long inv_q30_mult(long a, long b); 45 void inv_q_mult(const long *q1, const long *q2, long *qProd); 46 void inv_q_add(long *q1, long *q2, long *qSum); 47 void inv_q_normalize(long *q); 48 void inv_q_invert(const long *q, long *qInverted); 49 void inv_q_multf(const float *q1, const float *q2, float *qProd); 50 void inv_q_addf(float *q1, float *q2, float *qSum); 51 void inv_q_normalizef(float *q); 52 void inv_q_norm4(float *q); 53 void inv_q_invertf(const float *q, float *qInverted); 54 void inv_quaternion_to_rotation(const long *quat, long *rot); 55 unsigned char *inv_int32_to_big8(long x, unsigned char *big8); 56 long inv_big8_to_int32(const unsigned char *big8); 57 unsigned char *inv_int16_to_big8(short x, unsigned char *big8); 58 float inv_matrix_det(float *p, int *n); 59 void inv_matrix_det_inc(float *a, float *b, int *n, int x, int y); 60 double inv_matrix_detd(double *p, int *n); 61 void inv_matrix_det_incd(double *a, double *b, int *n, int x, int y); 62 float inv_wrap_angle(float ang); 63 float inv_angle_diff(float ang1, float ang2); 64 65 #ifdef __cplusplus 66 } 67 #endif 68 #endif // INVENSENSE_INV_MATH_FUNC_H__ 69