line.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_LINE_H_
37 #define JSK_RECOGNITION_UTILS_GEO_LINE_H_
38 
39 #include <Eigen/Geometry>
40 #include <boost/shared_ptr.hpp>
42 
43 namespace jsk_recognition_utils
44 {
49  class Line
50  {
51  public:
53 
61  Line(const Eigen::Vector3f& direction, const Eigen::Vector3f& origin);
62 
67  virtual void getDirection(Eigen::Vector3f& output) const;
68 
73  virtual Eigen::Vector3f getDirection() const;
74 
79  virtual void getOrigin(Eigen::Vector3f& output) const;
80 
85  virtual Eigen::Vector3f getOrigin() const;
86 
91  virtual double distanceToPoint(const Eigen::Vector3f& from) const;
92 
97  virtual double distanceToPoint(const Eigen::Vector3f& from,
98  Eigen::Vector3f& foot) const;
99 
104  virtual double distance(const Line& other) const;
105 
110  virtual void foot(const Eigen::Vector3f& point, Eigen::Vector3f& output) const;
111 
116  virtual double angle(const Line& other) const;
117 
123  virtual bool isParallel(const Line& other, double angle_threshold = 0.1) const;
124 
130  virtual bool isPerpendicular(const Line& other, double angle_threshold = 0.1) const;
131 
136  virtual Ptr midLine(const Line& other) const;
137 
143  virtual Ptr parallelLineOnAPoint(const Eigen::Vector3f& p) const;
144 
149  virtual PointPair findEndPoints(const Vertices& points) const;
150 
158  virtual double computeAlpha(const Point& p) const;
159 
164  virtual bool isSameDirection(const Line& other) const;
165 
170  virtual Line::Ptr flip();
171 
176  virtual void parallelLineNormal(const Line& other, Eigen::Vector3f& output) const;
177 
182  static Ptr fromCoefficients(const std::vector<float>& coefficients);
183 
188  virtual void print();
189 
194  virtual void point(double alpha, Eigen::Vector3f& ouptut);
195  protected:
196  Eigen::Vector3f direction_;
197  Eigen::Vector3f origin_;
198  private:
199  };
200 
201 }
202 
203 #endif
virtual Line::Ptr flip()
Definition: line.cpp:120
virtual double distance(const Line &other) const
compute a distance to line.
Definition: line.cpp:155
virtual void foot(const Eigen::Vector3f &point, Eigen::Vector3f &output) const
compute a point which gives perpendicular projection.
Definition: line.cpp:69
virtual double angle(const Line &other) const
compute angle between a given line.
Definition: line.cpp:88
virtual double computeAlpha(const Point &p) const
Definition: line.cpp:168
virtual void print()
Print Line information.
Definition: line.cpp:195
boost::shared_ptr< Line > Ptr
Definition: line.h:52
virtual void point(double alpha, Eigen::Vector3f &ouptut)
Compute a point on normal from alpha parameter.
Definition: line.cpp:201
virtual PointPair findEndPoints(const Vertices &points) const
Extract end points from the points on the lines.
Definition: line.cpp:173
Eigen::Vector3f direction_
Definition: line.h:196
virtual Ptr midLine(const Line &other) const
compute a middle line between given line.
Definition: line.cpp:126
virtual Eigen::Vector3f getOrigin() const
get origin of the line.
Definition: line.cpp:64
virtual bool isPerpendicular(const Line &other, double angle_threshold=0.1) const
return true if given line is perpendicular. angle_threshold is error tolerance.
Definition: line.cpp:110
virtual double distanceToPoint(const Eigen::Vector3f &from) const
compute a distance to a point
Definition: line.cpp:82
static Ptr fromCoefficients(const std::vector< float > &coefficients)
Instantiate Line from array of float.
Definition: line.cpp:143
std::vector< Eigen::Vector3f, Eigen::aligned_allocator< Eigen::Vector3f > > Vertices
Definition: types.h:48
virtual Ptr parallelLineOnAPoint(const Eigen::Vector3f &p) const
compute a line on a point, whose direction is same to the current line.
Definition: line.cpp:162
Line(const Eigen::Vector3f &direction, const Eigen::Vector3f &origin)
Construct a line from direction vector and a point on the line.
Definition: line.cpp:43
boost::tuple< Point, Point > PointPair
Definition: types.h:49
virtual bool isSameDirection(const Line &other) const
Definition: line.cpp:115
Eigen::Vector3f origin_
Definition: line.h:197
Eigen::Vector3f Point
Definition: types.h:45
virtual Eigen::Vector3f getDirection() const
get normalized direction vector of the line.
Definition: line.cpp:54
Class to represent 3-D straight line.
Definition: line.h:49
virtual bool isParallel(const Line &other, double angle_threshold=0.1) const
return true if given line is parallel. angle_threshold is error tolerance.
Definition: line.cpp:105
virtual void parallelLineNormal(const Line &other, Eigen::Vector3f &output) const
compute a perpendicular line of two lines from origin_
Definition: line.cpp:135


jsk_recognition_utils
Author(s):
autogenerated on Mon May 3 2021 03:03:03