30 #include <Eigen/Geometry> 68 class Line3D :
protected Eigen::ParametrizedLine<double, 3> {
74 const Eigen::Vector3d& p1) {
75 return {p0, (p1 - p0).normalized()};
95 Line3D(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& direction);
103 const Eigen::Vector3d&
Origin()
const {
return m_origin; }
106 const Eigen::Vector3d&
Direction()
const {
return m_direction; }
111 return std::numeric_limits<double>::infinity();
115 virtual void Transform(
const Eigen::Transform<double, 3, Eigen::Affine>& t);
119 const Eigen::ParametrizedLine<double, 3>&
Line()
const {
return *
this; }
126 const Eigen::Hyperplane<double, 3>& plane)
const;
149 virtual Eigen::Vector3d
Projection(
const Eigen::Vector3d& point)
const;
209 const Line3D& other)
const;
232 Line3D(
const Eigen::Vector3d& origin,
233 const Eigen::Vector3d& direction,
263 static Ray3D Through(
const Eigen::Vector3d& p0,
const Eigen::Vector3d& p1) {
264 return {p0, (p1 - p0).normalized()};
268 Ray3D(
const Eigen::Vector3d& origin,
const Eigen::Vector3d& direction);
273 return std::numeric_limits<double>::infinity();
282 const Eigen::Hyperplane<double, 3>& plane)
const override;
313 return std::max(parameter, 0.);
321 return parameter >= 0;
345 const Eigen::Vector3d& p1) {
351 Segment3D(
const Eigen::Vector3d& start_point,
352 const Eigen::Vector3d& end_point);
356 explicit Segment3D(
const std::pair<Eigen::Vector3d, Eigen::Vector3d>& pair);
360 double Length()
const override {
return length_; }
363 Eigen::Vector3d
MidPoint()
const {
return 0.5 * (origin() + end_point_); }
366 const Eigen::Vector3d&
EndPoint()
const {
return end_point_; }
370 const Eigen::Transform<double, 3, Eigen::Affine>& t)
override;
381 const Eigen::Hyperplane<double, 3>& plane)
const override;
436 return std::max(std::min(parameter, length_), 0.);
444 return parameter >= 0 && parameter <= length_;
448 Eigen::Vector3d end_point_;
virtual void Transform(const Eigen::Transform< double, 3, Eigen::Affine > &t)
Transform the Line3D by the given matrix.
Definition: Line3D.cpp:29
std::pair< double, double > ClosestParameters(const Line3D &other) const
Computes the two corresponding parameters of the closest distance between two Line3D objects...
Definition: Line3D.cpp:164
A ray is a semantic interpretation of Eigen::ParametrizedLine which has an origin and a direction and...
Definition: Line3D.h:259
virtual ~Line3D()=default
virtual Eigen::Vector3d Projection(const Eigen::Vector3d &point) const
Calculates a point projected onto the line, taking into account special semantics.
Definition: Line3D.cpp:156
Lines extend infinitely in both directions.
bool IsParameterValid(double parameter) const override
Verifies that a given parameter value is valid for the semantics of the line object. For lines, any parameter is valid, for rays any positive parameter is valid, and for segments any parameter between 0 and the segment length is valid.
Definition: Line3D.h:320
A bounding box that is aligned along the coordinate axes.
Definition: BoundingVolume.h:149
double Length() const override
Get the scalar length of the segment as the distance between the start point (origin) and the end poi...
Definition: Line3D.h:360
std::pair< double, double > SlabAABBBase(const AxisAlignedBoundingBox &box) const
Calculates the common t_min and t_max values of the slab AABB intersection method. These values are computed identically for any semantic interpretation of the line, it's up to the derived classes to use them in conjunction with other information to determine what the intersection parameter is.
Definition: Line3D.cpp:33
bool IsParameterValid(double parameter) const override
Verifies that a given parameter value is valid for the semantics of the line object. For lines, any parameter is valid, for rays any positive parameter is valid, and for segments any parameter between 0 and the segment length is valid.
Definition: Line3D.h:443
const Eigen::Vector3d & EndPoint() const
Get the end point of the segment.
Definition: Line3D.h:366
virtual utility::optional< double > IntersectionParameter(const Eigen::Hyperplane< double, 3 > &plane) const
Calculates the intersection parameter between the line and a plane taking into account line semantics...
Definition: Line3D.cpp:146
Line3D(const Eigen::Vector3d &origin, const Eigen::Vector3d &direction)
Default user constructor.
Definition: Line3D.cpp:10
static Segment3D Through(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1)
Creates a Segment3D through two points. The origin will take the value of p0, and the endpoint be p1...
Definition: Line3D.h:344
static Line3D Through(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1)
Creates a line through two points. The line origin will take the value of p0, and the line direction ...
Definition: Line3D.h:73
double DistanceTo(const Line3D &other) const
Gets the closest distance between two Line3D objects, including derived types Ray3D and Segment3D...
Definition: Line3D.cpp:263
std::pair< Eigen::Vector3d, Eigen::Vector3d > ClosestPoints(const Line3D &other) const
Computes the two closest points between this Line3D object and the other, including of derived types ...
Definition: Line3D.cpp:253
virtual bool IsParameterValid(double parameter) const
Verifies that a given parameter value is valid for the semantics of the line object. For lines, any parameter is valid, for rays any positive parameter is valid, and for segments any parameter between 0 and the segment length is valid.
Definition: Line3D.h:227
const Eigen::ParametrizedLine< double, 3 > & Line() const
Returns a const reference to the underlying Eigen::ParametrizedLine object.
Definition: Line3D.h:119
virtual double Length() const
Gets the length of the line, which for lines and rays will return positive infinity, but for segments will return a finite positive value.
Definition: Line3D.h:110
static Ray3D Through(const Eigen::Vector3d &p0, const Eigen::Vector3d &p1)
Creates a Ray3D through two points. The ray origin will take the value of p0, and the direction will ...
Definition: Line3D.h:263
double ProjectionParameter(const Eigen::Vector3d &point) const
Calculates the parameter of a point projected onto the line taking into account special semantics...
Definition: Line3D.cpp:160
double Length() const override
Gets the length of the line, which for lines and rays will return positive infinity, but for segments will return a finite positive value.
Definition: Line3D.h:272
const Eigen::Vector3d & Origin() const
Gets the line's origin point.
Definition: Line3D.h:103
char type
Definition: FilePCD.cpp:60
Definition: Optional.h:54
double ClampParameter(double parameter) const override
Clamps/bounds a parameter value to the closest valid place where the entity exists. On a Line3D, the value will be unchanged, on a Ray3D a negative value will be made 0, and on a Segment3D a negative value will be made 0 and a positive value greater than Length() will take the value of Length()
Definition: Line3D.h:435
Definition: PinholeCameraIntrinsic.cpp:35
LineType
Specifies different semantic interpretations of 3d lines.
Definition: Line3D.h:81
double ClampParameter(double parameter) const override
Clamps/bounds a parameter value to the closest valid place where the entity exists. On a Line3D, the value will be unchanged, on a Ray3D a negative value will be made 0, and on a Segment3D a negative value will be made 0 and a positive value greater than Length() will take the value of Length()
Definition: Line3D.h:312
const Eigen::Vector3d & Direction() const
Gets the line's direction vector.
Definition: Line3D.h:106
virtual double ClampParameter(double parameter) const
Clamps/bounds a parameter value to the closest valid place where the entity exists. On a Line3D, the value will be unchanged, on a Ray3D a negative value will be made 0, and on a Segment3D a negative value will be made 0 and a positive value greater than Length() will take the value of Length()
Definition: Line3D.h:221
virtual utility::optional< double > SlabAABB(const AxisAlignedBoundingBox &box) const
Returns the lower intersection parameter for a line with an axis aligned bounding box or empty if no ...
Definition: Line3D.cpp:129
LineType GetLineType() const
Gets the semantic type of the line.
Definition: Line3D.h:100
virtual utility::optional< double > ExactAABB(const AxisAlignedBoundingBox &box) const
Returns the lower intersection parameter for a line with an axis aligned bounding box or empty if no ...
Definition: Line3D.cpp:65
Line3D is a class which derives from Eigen::ParametrizedLine<double, 3> in order to capture the seman...
Definition: Line3D.h:68
Eigen::Vector3d MidPoint() const
Calculates the midpoint of the segment.
Definition: Line3D.h:363
A segment is a semantic interpretation of Eigen::ParametrizedLine which has an origin and an endpoint...
Definition: Line3D.h:339