36 #define BOOST_PARAMETER_MAX_ARITY 7 50 const std::vector<float>& coefficients):
57 const Eigen::Vector3f& p, Eigen::Vector3f& output)
63 const Eigen::Affine3f& pose, Eigen::Affine3f& output)
65 Eigen::Vector3f
p(pose.translation());
66 Eigen::Vector3f output_p;
72 Eigen::Quaternionf rot;
73 rot.setFromTwoVectors(pose.rotation() * Eigen::Vector3f::UnitZ(),
74 coordinates().rotation() * Eigen::Vector3f::UnitZ());
75 Eigen::Quaternionf coords_rot(
coordinates().rotation());
76 Eigen::Quaternionf pose_rot(pose.rotation());
88 output = Eigen::Affine3f(rot * pose.rotation());
89 output.pretranslate(output_p);
99 std::back_inserter(new_vertices));
100 std::vector<float> reversed_coefficients(4);
101 reversed_coefficients[0] = -
normal_[0];
102 reversed_coefficients[1] = -
normal_[1];
103 reversed_coefficients[2] = -
normal_[2];
104 reversed_coefficients[3] = -
d_;
111 Eigen::Vector3f point_on_plane;
115 output = point_on_plane;
119 double min_distance = DBL_MAX;
120 Eigen::Vector3f min_point;
121 for (
size_t i = 0; i <
vertices_.size() - 1; i++) {
123 Eigen::Vector3f foot;
125 if (distance < min_distance) {
136 Eigen::Vector3f output_f;
137 Eigen::Vector3f p_f(p[0], p[1], p[2]);
139 pointFromVectorToVector<Eigen::Vector3f, Eigen::Vector3d>(output_f, output);
144 Eigen::Vector3f p_f(p[0], p[1], p[2]);
150 Eigen::Vector3f output_f;
152 pointFromVectorToVector<Eigen::Vector3f, Eigen::Vector3d>(output_f, output);
158 Eigen::Vector3f ret(0, 0, 0);
159 for (
size_t i = 0; i <
vertices_.size(); i++) {
168 for (
size_t i = 0; i < polygon.points.size(); i++) {
170 pointFromXYZToVector<geometry_msgs::Point32, Eigen::Vector3f>(
171 polygon.points[i], p);
172 vertices.push_back(p);
180 for (
size_t i = 0; i < polygon.points.size(); i++) {
182 pointFromXYZToVector<geometry_msgs::Point32, Eigen::Vector3f>(
183 polygon.points[i], p);
184 vertices.push_back(p);
190 double distance_threshold)
192 double dummy_distance;
197 double distance_threshold,
198 double& output_distance)
202 if (plane_distance > distance_threshold) {
203 output_distance = plane_distance;
207 Eigen::Vector3f foot_point;
209 double convex_distance = (p - foot_point).norm();
210 output_distance = convex_distance;
211 return convex_distance < distance_threshold;
216 for (
size_t i = 0; i <
vertices_.size(); i++) {
218 Eigen::Vector3f p_k_1;
225 if ((p_k - p_k_1).norm() < thr) {
234 double min_distance = DBL_MAX;
235 for (
size_t i = 0; i <
vertices_.size(); i++) {
237 double d = (p - v).norm();
238 if (d < min_distance) {
250 for (
size_t i = 0; i <
vertices_.size(); i++) {
266 for (
size_t i = 0; i <
vertices_.size(); i++) {
267 new_vertices.push_back((
vertices_[i] - c) * scale_factor + c);
275 geometry_msgs::Polygon polygon;
276 for (
size_t i = 0; i <
vertices_.size(); i++) {
277 geometry_msgs::Point32 ros_point;
281 polygon.points.push_back(ros_point);
289 Eigen::Vector3f foot_point;
geometry_msgs::Polygon toROSMsg()
bool distanceSmallerThan(const Eigen::Vector3f &p, double distance_threshold)
static ConvexPolygon fromROSMsg(const geometry_msgs::Polygon &polygon)
virtual ConvexPolygon flipConvex()
virtual Ptr magnify(const double scale_factor)
double distance(const Eigen::Vector3f &point)
Compute distance between point and this polygon.
boost::shared_ptr< ConvexPolygon > Ptr
virtual void project(const Eigen::Vector3f &p, Eigen::Vector3f &output)
virtual Eigen::Affine3f coordinates()
Class to represent 3-D straight line which has finite length.
static ConvexPolygon::Ptr fromROSMsgPtr(const geometry_msgs::Polygon &polygon)
virtual Ptr magnifyByDistance(const double distance)
virtual Eigen::Vector3f getCentroid()
TFSIMD_FORCE_INLINE Vector3 normalized() const
double distanceFromVertices(const Eigen::Vector3f &p)
virtual void projectOnPlane(const Eigen::Vector3f &p, Eigen::Vector3f &output)
ConvexPolygon(const Vertices &vertices)
virtual bool isInside(const Eigen::Vector3f &p)
return true if p is inside of polygon. p should be in global coordinates.
virtual double distanceToPoint(const Eigen::Vector3f &from) const
compute a distance to a point
virtual void project(const Eigen::Vector3f &p, Eigen::Vector3f &output)
virtual bool isProjectableInside(const Eigen::Vector3f &p)
bool allEdgesLongerThan(double thr)
std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > Vertices
virtual double distanceToPoint(const Eigen::Vector4f p)
virtual Eigen::Vector3f centroid()