Added Location::Distance(Location) functionality to the PythonAPI
This commit is contained in:
parent
b6a78cc810
commit
60c97c4c14
|
@ -7,6 +7,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "carla/geom/Vector3D.h"
|
||||
#include "carla/geom/Math.h"
|
||||
|
||||
#ifdef LIBCARLA_INCLUDED_FROM_UE4
|
||||
# include "Math/Vector.h"
|
||||
|
@ -74,6 +75,10 @@ namespace geom {
|
|||
return !(*this == rhs);
|
||||
}
|
||||
|
||||
double Distance(const Location &loc) const {
|
||||
return Math::Distance(Vector3D(this->x, this->y, this->z), loc);
|
||||
}
|
||||
|
||||
#ifdef LIBCARLA_INCLUDED_FROM_UE4
|
||||
|
||||
Location(const FVector &vector) // from centimeters to meters.
|
||||
|
|
|
@ -59,7 +59,7 @@ namespace geom {
|
|||
}
|
||||
|
||||
static double DistanceSquared(const Vector3D &a, const Vector3D &b) {
|
||||
return sqr(b.x - a.x) + sqr(b.y - a.y) + sqr(b.z - a.z);
|
||||
return sqr<double>(b.x - a.x) + sqr<double>(b.y - a.y) + sqr<double>(b.z - a.z);
|
||||
}
|
||||
|
||||
static double DistanceSquared2D(const Vector3D &a, const Vector3D &b) {
|
||||
|
|
|
@ -78,6 +78,7 @@ void export_geom() {
|
|||
.add_property("x", +[](const cg::Location &self) { return self.x; }, +[](cg::Location &self, float x) { self.x = x; })
|
||||
.add_property("y", +[](const cg::Location &self) { return self.y; }, +[](cg::Location &self, float y) { self.y = y; })
|
||||
.add_property("z", +[](const cg::Location &self) { return self.z; }, +[](cg::Location &self, float z) { self.z = z; })
|
||||
.def("distance", &cg::Location::Distance, (arg("location")))
|
||||
.def("__eq__", &cg::Location::operator==)
|
||||
.def("__ne__", &cg::Location::operator!=)
|
||||
.def(self += self)
|
||||
|
|
Loading…
Reference in New Issue