cube.h
Go to the documentation of this file.
1 // -*- mode: c++ -*-
2 /*********************************************************************
3  * Software License Agreement (BSD License)
4  *
5  * Copyright (c) 2014, JSK Lab
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above
15  * copyright notice, this list of conditions and the following
16  * disclaimer in the documentation and/o2r other materials provided
17  * with the distribution.
18  * * Neither the name of the JSK Lab nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33  * POSSIBILITY OF SUCH DAMAGE.
34  *********************************************************************/
35 
36 #ifndef JSK_RECOGNITION_UTILS_GEO_CUBE_H_
37 #define JSK_RECOGNITION_UTILS_GEO_CUBE_H_
38 
41 #include <jsk_recognition_msgs/BoundingBoxArray.h>
42 
43 namespace jsk_recognition_utils
44 {
45  class Cube
46  {
47  public:
49  Cube(const Eigen::Vector3f& pos, const Eigen::Quaternionf& rot);
50  Cube(const Eigen::Vector3f& pos, const Eigen::Quaternionf& rot,
51  const std::vector<double>& dimensions);
52  Cube(const Eigen::Vector3f& pos, const Eigen::Quaternionf& rot,
53  const Eigen::Vector3f& dimensions);
54  Cube(const Eigen::Vector3f& pos, // centroid
55  const Line& line_a, const Line& line_b, const Line& line_c);
56  Cube(const jsk_recognition_msgs::BoundingBox& box);
57  virtual ~Cube();
58  std::vector<Segment::Ptr> edges();
60  std::vector<double> getDimensions() const { return dimensions_; };
61  void setDimensions(const std::vector<double>& new_dimensions) {
62  dimensions_[0] = new_dimensions[0];
63  dimensions_[1] = new_dimensions[1];
64  dimensions_[2] = new_dimensions[2];
65  }
66  jsk_recognition_msgs::BoundingBox toROSMsg();
67 
76 
81  Vertices transformVertices(const Eigen::Affine3f& pose_offset);
82 
88  std::vector<Polygon::Ptr> faces();
89 
98  virtual Eigen::Vector3f nearestPoint(const Eigen::Vector3f& p,
99  double& distance);
100  protected:
101  Eigen::Vector3f pos_;
102  Eigen::Quaternionf rot_;
103  std::vector<double> dimensions_;
104 
109  virtual Polygon::Ptr buildFace(const Eigen::Vector3f v0,
110  const Eigen::Vector3f v1,
111  const Eigen::Vector3f v2,
112  const Eigen::Vector3f v3);
113 
118  virtual Eigen::Vector3f buildVertex(double i, double j, double k);
119 
120  private:
121 
122  };
123 }
124 
125 #endif
Vertices vertices()
returns vertices as an array of Eigen::Vectro3f. The order of the vertices is: [1, 1, 1], [-1, 1, 1], [-1, -1, 1], [1, -1, 1], [1, 1, -1], [-1, 1, -1], [-1, -1, -1], [1, -1, -1].
Definition: cube.cpp:219
Eigen::Quaternionf rot_
Definition: cube.h:102
std::vector< Segment::Ptr > edges()
Definition: cube.cpp:123
Vertices transformVertices(const Eigen::Affine3f &pose_offset)
returns vertices transformed by pose_offset.
Definition: cube.cpp:233
TFSIMD_FORCE_INLINE tfScalar distance(const Vector3 &v) const
ConvexPolygon::Ptr intersectConvexPolygon(Plane &plane)
Definition: cube.cpp:174
void setDimensions(const std::vector< double > &new_dimensions)
Definition: cube.h:61
virtual Polygon::Ptr buildFace(const Eigen::Vector3f v0, const Eigen::Vector3f v1, const Eigen::Vector3f v2, const Eigen::Vector3f v3)
A helper method to build polygon from 4 vertices.
Definition: cube.cpp:243
Cube(const Eigen::Vector3f &pos, const Eigen::Quaternionf &rot)
Definition: cube.cpp:42
std::vector< double > dimensions_
Definition: cube.h:103
virtual Eigen::Vector3f buildVertex(double i, double j, double k)
A helper method to build vertex from x-y-z relatiev coordinates.
Definition: cube.cpp:284
std::vector< double > getDimensions() const
Definition: cube.h:60
virtual Eigen::Vector3f nearestPoint(const Eigen::Vector3f &p, double &distance)
compute minimum distance from point p to cube surface.
Definition: cube.cpp:292
jsk_recognition_msgs::BoundingBox toROSMsg()
Definition: cube.cpp:203
std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > Vertices
Definition: types.h:48
std::vector< Polygon::Ptr > faces()
returns all the 6 faces as Polygon::Ptr. TODO: is it should be ConvexPolygon?
Definition: cube.cpp:256
p
Eigen::Vector3f pos_
Definition: cube.h:101
Class to represent 3-D straight line.
Definition: line.h:49
boost::shared_ptr< Cube > Ptr
Definition: cube.h:48


jsk_recognition_utils
Author(s):
autogenerated on Wed May 27 2020 03:59:48