[python] minor updates to math wrappers

This commit is contained in:
Felix Ruess
2015-12-22 16:41:07 +01:00
parent 34e076e2f7
commit beeb698314
4 changed files with 44 additions and 9 deletions
@@ -37,6 +37,11 @@ struct FloatEulers {
float psi; ///< in radians
};
struct FloatRates {
float p; ///< in rad/s
float q; ///< in rad/s
float r; ///< in rad/s
};
%extend FloatVect2 {
char *__str__() {
@@ -265,3 +270,32 @@ struct FloatEulers {
return r;
}
};
%extend FloatRates {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"Rates(%g, %g, %g)", $self->p ,$self->q, $self->r);
return tmp;
}
FloatRates(float p=0.0, float q=0.0, float r=0.0) {
struct FloatRates *fr = (struct FloatRates *) malloc(sizeof(struct FloatRates));
fr->p = p;
fr->q = q;
fr->r = r;
return fr;
}
struct FloatRates __add__(struct FloatRates *other) {
struct FloatRates fr;
fr.p = $self->p + other->p;
fr.q = $self->q + other->q;
fr.r = $self->r + other->r;
return fr;
}
struct FloatRates __sub__(struct FloatRates *other) {
struct FloatRates fr;
fr.p = $self->p - other->p;
fr.q = $self->q - other->q;
fr.r = $self->r - other->r;
return fr;
}
};
+1 -1
View File
@@ -31,7 +31,7 @@ algebra_module = Extension('_algebra',
],
include_dirs=common_inc_dirs)
setup(name='geodetic',
setup(name='pprz_math',
version='0.1',
author="Felix Ruess",
description="""Pprz math wrappers""",