[python][math] improve swig wrapping

This commit is contained in:
Felix Ruess
2015-01-08 19:14:28 +01:00
parent a6ce60069e
commit cebe398b56
4 changed files with 399 additions and 18 deletions
+129
View File
@@ -5,3 +5,132 @@
%}
%include "math/pprz_geodetic_double.h"
%extend EcefCoor_d {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"ECEF(%.3f, %.3f, %.3f)", $self->x,$self->y,$self->z);
return tmp;
}
EcefCoor_d(double x=0.0, double y=0.0, double z=0.0) {
struct EcefCoor_d *v = (struct EcefCoor_d *) malloc(sizeof(struct EcefCoor_d));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct EcefCoor_d __add__(struct EcefCoor_d *other) {
struct EcefCoor_d v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct EcefCoor_d __sub__(struct EcefCoor_d *other) {
struct EcefCoor_d v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend NedCoor_d {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"NED(% 3.3f,% 3.3f,% 3.3f)", $self->x,$self->y,$self->z);
return tmp;
}
NedCoor_d(double x=0.0, double y=0.0, double z=0.0) {
struct NedCoor_d *v = (struct NedCoor_d *) malloc(sizeof(struct NedCoor_d));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct NedCoor_d __add__(struct NedCoor_d *other) {
struct NedCoor_d v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct NedCoor_d __sub__(struct NedCoor_d *other) {
struct NedCoor_d v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend EnuCoor_d {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"ENU(% 3.3f,% 3.3f,% 3.3f)", $self->x,$self->y,$self->z);
return tmp;
}
EnuCoor_d(double x=0.0, double y=0.0, double z=0.0) {
struct EnuCoor_d *v = (struct EnuCoor_d *) malloc(sizeof(struct EnuCoor_d));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct EnuCoor_d __add__(struct EnuCoor_d *other) {
struct EnuCoor_d v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct EnuCoor_d __sub__(struct EnuCoor_d *other) {
struct EnuCoor_d v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend UtmCoor_d {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"UTM(north=%.3f, east=%.3f, alt=%g, zone=%d)", $self->north, $self->east, $self->alt, $self->zone);
return tmp;
}
UtmCoor_d(double north=0.0, double east=0.0, double alt=0.0, uint8_t zone=0) {
struct UtmCoor_d *v = (struct UtmCoor_d *) malloc(sizeof(struct UtmCoor_d));
v->north = north;
v->east = east;
v->alt = alt;
v->zone = zone;
return v;
}
};
%extend LlaCoor_d {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"LLA(lat=%.7f, lon=%.7f, alt=%g)", DegOfRad($self->lat), DegOfRad($self->lon), $self->alt);
return tmp;
}
LlaCoor_d(double lat=0.0, double lon=0.0, double alt=0.0) {
struct LlaCoor_d *v = (struct LlaCoor_d *) malloc(sizeof(struct LlaCoor_d));
v->lat = lat;
v->lon = lon;
v->alt = alt;
return v;
}
};
%extend LtpDef_d {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"LtpDef: ECEF(%.3f, %.3f, %.3f), LLA(lat=%.7f, lon=%.7f, alt=%g), hmsl=%g",
$self->ecef.x, $self->ecef.y, $self->ecef.z,
DegOfRad($self->lla.lat), DegOfRad($self->lla.lon), $self->lla.alt, $self->hmsl);
return tmp;
}
};
+128
View File
@@ -5,3 +5,131 @@
%}
%include "math/pprz_geodetic_float.h"
%extend EcefCoor_f {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"ECEF(%.3f, %.3f, %.3f)", $self->x,$self->y,$self->z);
return tmp;
}
EcefCoor_f(float x=0.0, float y=0.0, float z=0.0) {
struct EcefCoor_f *v = (struct EcefCoor_f *) malloc(sizeof(struct EcefCoor_f));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct EcefCoor_f __add__(struct EcefCoor_f *other) {
struct EcefCoor_f v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct EcefCoor_f __sub__(struct EcefCoor_f *other) {
struct EcefCoor_f v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend NedCoor_f {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"NED(% 3.3f,% 3.3f,% 3.3f)", $self->x,$self->y,$self->z);
return tmp;
}
NedCoor_f(float x=0.0, float y=0.0, float z=0.0) {
struct NedCoor_f *v = (struct NedCoor_f *) malloc(sizeof(struct NedCoor_f));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct NedCoor_f __add__(struct NedCoor_f *other) {
struct NedCoor_f v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct NedCoor_f __sub__(struct NedCoor_f *other) {
struct NedCoor_f v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend EnuCoor_f {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"ENU(% 3.3f,% 3.3f,% 3.3f)", $self->x,$self->y,$self->z);
return tmp;
}
EnuCoor_f(float x=0.0, float y=0.0, float z=0.0) {
struct EnuCoor_f *v = (struct EnuCoor_f *) malloc(sizeof(struct EnuCoor_f));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct EnuCoor_f __add__(struct EnuCoor_f *other) {
struct EnuCoor_f v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct EnuCoor_f __sub__(struct EnuCoor_f *other) {
struct EnuCoor_f v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend UtmCoor_f {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"UTM(north=%.3f, east=%.3f, alt=%g, zone=%d)", $self->north, $self->east, $self->alt, $self->zone);
return tmp;
}
UtmCoor_f(float north=0.0, float east=0.0, float alt=0.0, uint8_t zone=0) {
struct UtmCoor_f *v = (struct UtmCoor_f *) malloc(sizeof(struct UtmCoor_f));
v->north = north;
v->east = east;
v->alt = alt;
v->zone = zone;
return v;
}
};
%extend LlaCoor_f {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"LLA deg (lat=%.7f, lon=%.7f, alt=%g)", DegOfRad($self->lat), DegOfRad($self->lon), $self->alt);
return tmp;
}
LlaCoor_f(float lat=0.0, float lon=0.0, float alt=0.0) {
struct LlaCoor_f *v = (struct LlaCoor_f *) malloc(sizeof(struct LlaCoor_f));
v->lat = lat;
v->lon = lon;
v->alt = alt;
return v;
}
};
%extend LtpDef_f {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"LtpDef: ECEF(%.3f, %.3f, %.3f), LLA(lat=%.7f, lon=%.7f, alt=%g), hmsl=%g",
$self->ecef.x, $self->ecef.y, $self->ecef.z,
DegOfRad($self->lla.lat), DegOfRad($self->lla.lon), $self->lla.alt, $self->hmsl);
return tmp;
}
};
+129
View File
@@ -6,3 +6,132 @@
%}
%include "math/pprz_geodetic_int.h"
%extend EcefCoor_i {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"ECEF(%d, %d, %d)", $self->x,$self->y,$self->z);
return tmp;
}
EcefCoor_i(int32_t x=0, int32_t y=0, int32_t z=0) {
struct EcefCoor_i *v = (struct EcefCoor_i *) malloc(sizeof(struct EcefCoor_i));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct EcefCoor_i __add__(struct EcefCoor_i *other) {
struct EcefCoor_i v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct EcefCoor_i __sub__(struct EcefCoor_i *other) {
struct EcefCoor_i v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend NedCoor_i {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"NED(%d, %d, %d)", $self->x,$self->y,$self->z);
return tmp;
}
NedCoor_i(int32_t x=0, int32_t y=0, int32_t z=0) {
struct NedCoor_i *v = (struct NedCoor_i *) malloc(sizeof(struct NedCoor_i));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct NedCoor_i __add__(struct NedCoor_i *other) {
struct NedCoor_i v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct NedCoor_i __sub__(struct NedCoor_i *other) {
struct NedCoor_i v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend EnuCoor_i {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"ENU(%d, %d, %d)", $self->x,$self->y,$self->z);
return tmp;
}
EnuCoor_i(int32_t x=0, int32_t y=0, int32_t z=0) {
struct EnuCoor_i *v = (struct EnuCoor_i *) malloc(sizeof(struct EnuCoor_i));
v->x = x;
v->y = y;
v->z = z;
return v;
}
struct EnuCoor_i __add__(struct EnuCoor_i *other) {
struct EnuCoor_i v;
v.x = $self->x + other->x;
v.y = $self->y + other->y;
v.z = $self->z + other->z;
return v;
}
struct EnuCoor_i __sub__(struct EnuCoor_i *other) {
struct EnuCoor_i v;
v.x = $self->x - other->x;
v.y = $self->y - other->y;
v.z = $self->z - other->z;
return v;
}
};
%extend UtmCoor_i {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"UTM(north=%d, east=%d, alt=%d, zone=%d)", $self->north, $self->east, $self->alt, $self->zone);
return tmp;
}
UtmCoor_i(int32_t north=0, int32_t east=0, int32_t alt=0, uint8_t zone=0) {
struct UtmCoor_i *v = (struct UtmCoor_i *) malloc(sizeof(struct UtmCoor_i));
v->north = north;
v->east = east;
v->alt = alt;
v->zone = zone;
return v;
}
};
%extend LlaCoor_i {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"LLA(lat=%d, lon=%d, alt=%d)", $self->lat, $self->lon, $self->alt);
return tmp;
}
LlaCoor_i(int32_t lat=0, int32_t lon=0, int32_t alt=0) {
struct LlaCoor_i *v = (struct LlaCoor_i *) malloc(sizeof(struct LlaCoor_i));
v->lat = lat;
v->lon = lon;
v->alt = alt;
return v;
}
};
%extend LtpDef_i {
char *__str__() {
static char tmp[1024];
sprintf(tmp,"LtpDef: ECEF(%d, %d, %d), LLA(lat=%d, lon=%d, alt=%d), hmsl=%d",
$self->ecef.x, $self->ecef.y, $self->ecef.z,
$self->lla.lat, $self->lla.lon, $self->lla.alt, $self->hmsl);
return tmp;
}
};