math_utils_gsl.c
Go to the documentation of this file.
1 #include "csm_all.h"
2 
3 void transform(const gsl_vector* p, const gsl_vector* x, gsl_vector*res) {
4  double theta = gvg(x,2);
5  double c = cos(theta); double s = sin(theta);
6  gsl_vector_set(res, 0, c * gvg(p,0) -s*gvg(p,1) + gvg(x,0));
7  gsl_vector_set(res, 1, s * gvg(p,0) +c*gvg(p,1) + gvg(x,1));
8 }
9 
10 void gsl_vector_set_nan(gsl_vector*v) {
11  gvs(v,0,GSL_NAN);
12  gvs(v,1,GSL_NAN);
13 }
14 
15 double norm(const gsl_vector*a){
16  double x = gvg(a,0);
17  double y = gvg(a,1);
18  return sqrt(x*x+y*y);
19 }
20 
21 gsl_vector * vector_from_array(unsigned int n, double *x) {
22  gsl_vector * v = gsl_vector_alloc(n);
23  unsigned int i;
24  for(i=0;i<n;i++)
25  gvs(v,i,x[i]);
26 
27  return v;
28 }
29 
30 void copy_from_array(gsl_vector*v, double*x) {
31  size_t i;
32  for(i=0;i<v->size;i++)
33  gsl_vector_set(v,i, x[i]);
34 }
35 
36 void vector_to_array(const gsl_vector*v, double*x){
37  size_t i;
38  for(i=0;i<v->size;i++)
39  x[i] = gvg(v,i);
40 }
41 
42 void oplus(const gsl_vector*x1,const gsl_vector*x2, gsl_vector*res) {
43  double c = cos(gvg(x1,2));
44  double s = sin(gvg(x1,2));
45  gvs(res,0, gvg(x1,0)+c*gvg(x2,0)-s*gvg(x2,1));
46  gvs(res,1, gvg(x1,1)+s*gvg(x2,0)+c*gvg(x2,1));
47  gvs(res,2, gvg(x1,2)+gvg(x2,2));
48 }
49 
50 void ominus(const gsl_vector*x, gsl_vector*res) {
51  double c = cos(gvg(x,2));
52  double s = sin(gvg(x,2));
53  gvs(res,0, -c*gvg(x,0)-s*gvg(x,1));
54  gvs(res,1, s*gvg(x,0)-c*gvg(x,1));
55  gvs(res,2, -gvg(x,2));
56 }
57 
58 void pose_diff(const gsl_vector*pose2,const gsl_vector*pose1,gsl_vector*res) {
59  gsl_vector* temp = gsl_vector_alloc(3);
60  ominus(pose1, temp);
61  oplus(temp, pose2, res);
62  gsl_vector_free(temp);
63 }
64 
65 const char* gsl_friendly_pose(gsl_vector*v) {
66  return friendly_pose(v->data);
67 }
68 
69 static char egsl_tmp_buf[1024];
70 const char* egsl_friendly_pose(val v) {
71  sprintf(egsl_tmp_buf, "(%4.2f mm, %4.2f mm, %4.4f deg)",
72  1000*egsl_atv(v,0),
73  1000*egsl_atv(v,1),
74  rad2deg(egsl_atv(v,2)));
75  return egsl_tmp_buf;
76 }
77 
78 const char* egsl_friendly_cov(val cov) {
79 
80  double limit_x = 2 * sqrt(egsl_atm(cov, 0, 0));
81  double limit_y = 2 * sqrt(egsl_atm(cov, 1, 1));
82  double limit_th = 2 * sqrt(egsl_atm(cov, 2, 2));
83 
84  sprintf(egsl_tmp_buf, "(+- %4.2f mm,+- %4.2f mm,+- %4.4f deg)",
85  1000*limit_x,
86  1000*limit_y,
87  rad2deg(limit_th));
88  return egsl_tmp_buf;
89 }
90 
91 
92 /*double distance(const gsl_vector* a, const gsl_vector* b) {
93  distance_counter++;
94  double x = gvg(a,0)-gvg(b,0);
95  double y = gvg(a,1)-gvg(b,1);
96  return sqrt(x*x+y*y);
97 }
98 
99 double distance_squared(const gsl_vector* a, const gsl_vector* b) {
100  distance_counter++;
101  double x = gvg(a,0)-gvg(b,0);
102  double y = gvg(a,1)-gvg(b,1);
103  return x*x+y*y;
104 }*/
gsl_vector * vector_from_array(unsigned int n, double *x)
void gsl_vector_set_nan(gsl_vector *v)
const char * egsl_friendly_cov(val cov)
#define gvg
Definition: math_utils_gsl.h:9
void ominus(const gsl_vector *x, gsl_vector *res)
#define gvs
Definition: egsl.h:12
const char * friendly_pose(const double *pose)
Definition: math_utils.c:266
void copy_from_array(gsl_vector *v, double *x)
double norm(const gsl_vector *a)
void oplus(const gsl_vector *x1, const gsl_vector *x2, gsl_vector *res)
double egsl_atm(val v1, size_t i, size_t j)
Definition: egsl.c:298
struct @0 p
void pose_diff(const gsl_vector *pose2, const gsl_vector *pose1, gsl_vector *res)
const char * gsl_friendly_pose(gsl_vector *v)
double egsl_atv(val v1, size_t i)
Definition: egsl.c:294
void transform(const gsl_vector *p, const gsl_vector *x, gsl_vector *res)
Definition: math_utils_gsl.c:3
static char egsl_tmp_buf[1024]
double rad2deg(double rad)
Definition: math_utils.c:79
const char * egsl_friendly_pose(val v)
void vector_to_array(const gsl_vector *v, double *x)


csm
Author(s): Andrea Censi
autogenerated on Tue May 11 2021 02:18:23