Open3D (C++ API)  0.18.0+252c867
Public Member Functions | Static Public Member Functions
open3d::geometry::Segment3D Class Reference

A segment is a semantic interpretation of Eigen::ParametrizedLine which has an origin and an endpoint and exists finitely between them. More...

#include <Line3D.h>

Inheritance diagram for open3d::geometry::Segment3D:
open3d::geometry::Line3D

Public Member Functions

 Segment3D (const Eigen::Vector3d &start_point, const Eigen::Vector3d &end_point)
 Default constructor for Segment3D takes the start and end points of the segment start_point end_point. More...
 
 Segment3D (const std::pair< Eigen::Vector3d, Eigen::Vector3d > &pair)
 Takes a std::pair of points, the first to be used as the start point/origin and the second to be the end point. More...
 
double Length () const override
 Get the scalar length of the segment as the distance between the start point (origin) and the end point. More...
 
Eigen::Vector3d MidPoint () const
 Calculates the midpoint of the segment. More...
 
const Eigen::Vector3d & EndPoint () const
 Get the end point of the segment. More...
 
void Transform (const Eigen::Transform< double, 3, Eigen::Affine > &t) override
 Transform the segment by the given matrix. More...
 
AxisAlignedBoundingBox GetBoundingBox () const
 Get an axis-aligned bounding box representing the enclosed volume of the line segment. More...
 
utility::optional< double > IntersectionParameter (const Eigen::Hyperplane< double, 3 > &plane) const override
 Calculates the intersection parameter between the line and a plane taking into account segment semantics. Returns an empty result if there is no intersection. On a Segment3D this means that intersections behind the origin and beyond the endpoint are invalid. More...
 
utility::optional< double > SlabAABB (const AxisAlignedBoundingBox &box) const override
 Returns the lower intersection parameter for a segment with an axis aligned bounding box or empty if no intersection. Uses the slab method, see warning below. More...
 
utility::optional< double > ExactAABB (const AxisAlignedBoundingBox &box) const override
 Returns the lower intersection parameter for a segment with an axis aligned bounding box or empty if no intersection. This method is about 20x slower than the slab method, see details to know when to use. More...
 
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() More...
 
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. More...
 
- Public Member Functions inherited from open3d::geometry::Line3D
 Line3D (const Eigen::Vector3d &origin, const Eigen::Vector3d &direction)
 Default user constructor. More...
 
virtual ~Line3D ()=default
 
LineType GetLineType () const
 Gets the semantic type of the line. More...
 
const Eigen::Vector3d & Origin () const
 Gets the line's origin point. More...
 
const Eigen::Vector3d & Direction () const
 Gets the line's direction vector. More...
 
const Eigen::ParametrizedLine< double, 3 > & Line () const
 Returns a const reference to the underlying Eigen::ParametrizedLine object. More...
 
double ProjectionParameter (const Eigen::Vector3d &point) const
 Calculates the parameter of a point projected onto the line taking into account special semantics. More...
 
virtual Eigen::Vector3d Projection (const Eigen::Vector3d &point) const
 Calculates a point projected onto the line, taking into account special semantics. More...
 
std::pair< double, double > ClosestParameters (const Line3D &other) const
 Computes the two corresponding parameters of the closest distance between two Line3D objects, including derived types Ray3D and Segment3D, respecting the semantics of the line type. More...
 
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 Ray3D and Segment3D, respecting the semantics of the line types. More...
 
double DistanceTo (const Line3D &other) const
 Gets the closest distance between two Line3D objects, including derived types Ray3D and Segment3D, respecting the semantics of the line type. More...
 

Static Public Member Functions

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. The direction will be a normalized vector from p0 to p1. More...
 
- Static Public Member Functions inherited from open3d::geometry::Line3D
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 will be a normalized vector from p0 to p1. More...
 

Additional Inherited Members

- Public Types inherited from open3d::geometry::Line3D
enum class  LineType { Line = 0 , Ray = 1 , Segment = 2 }
 Specifies different semantic interpretations of 3d lines. More...
 
- Protected Member Functions inherited from open3d::geometry::Line3D
 Line3D (const Eigen::Vector3d &origin, const Eigen::Vector3d &direction, LineType type)
 Internal constructor for inherited classes that allows the setting of the LineType. More...
 
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. More...
 

Detailed Description

A segment is a semantic interpretation of Eigen::ParametrizedLine which has an origin and an endpoint and exists finitely between them.

One of the main motivations behind this class, and the Line3D taxonomy in general, is the ambiguity of the Eigen documentation with regards to the ParametrizedLine's direction. The documentation warns that the direction vector is expected to be normalized and makes no guarantees about behavior when this expectation is not met. However, ParametrizedLine does behave correctly when the direction vector is scaled. This class exists as a seam to ensure the correct behavior can be produced regardless of what happens in the underlying Eigen implementation without changing the api surface for client code.

Constructor & Destructor Documentation

◆ Segment3D() [1/2]

open3d::geometry::Segment3D::Segment3D ( const Eigen::Vector3d &  start_point,
const Eigen::Vector3d &  end_point 
)

Default constructor for Segment3D takes the start and end points of the segment start_point end_point.

◆ Segment3D() [2/2]

open3d::geometry::Segment3D::Segment3D ( const std::pair< Eigen::Vector3d, Eigen::Vector3d > &  pair)
explicit

Takes a std::pair of points, the first to be used as the start point/origin and the second to be the end point.

Member Function Documentation

◆ ClampParameter()

double open3d::geometry::Segment3D::ClampParameter ( double  parameter) const
inlineoverridevirtual

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()

Reimplemented from open3d::geometry::Line3D.

◆ EndPoint()

const Eigen::Vector3d& open3d::geometry::Segment3D::EndPoint ( ) const
inline

Get the end point of the segment.

◆ ExactAABB()

utility::optional< double > open3d::geometry::Segment3D::ExactAABB ( const AxisAlignedBoundingBox box) const
overridevirtual

Returns the lower intersection parameter for a segment with an axis aligned bounding box or empty if no intersection. This method is about 20x slower than the slab method, see details to know when to use.

Calculates the lower intersection parameter of a parameterized segment with an axis aligned bounding box. The intersection point can be recovered with .Line().pointAt(...). If the segment does not intersect the box the return value will be empty.

This implementation is a naive exact method that considers intersections with all six bounding box planes. It is not optimized for speed and should only be used when a problem is conditioned such that the slab method is unacceptable. Use this when a segment is likely to lie exactly in one of the AABB planes and false negatives are unacceptable. Typically this will only happen when segments are axis-aligned and both segments and bounding volumes are regularly spaced, and every intersection is important. In such cases if performance is important, a simple custom implementation based on the problem directionality will likely outperform even the slab method.

Reimplemented from open3d::geometry::Line3D.

◆ GetBoundingBox()

AxisAlignedBoundingBox open3d::geometry::Segment3D::GetBoundingBox ( ) const

Get an axis-aligned bounding box representing the enclosed volume of the line segment.

◆ IntersectionParameter()

utility::optional< double > open3d::geometry::Segment3D::IntersectionParameter ( const Eigen::Hyperplane< double, 3 > &  plane) const
overridevirtual

Calculates the intersection parameter between the line and a plane taking into account segment semantics. Returns an empty result if there is no intersection. On a Segment3D this means that intersections behind the origin and beyond the endpoint are invalid.

Reimplemented from open3d::geometry::Line3D.

◆ IsParameterValid()

bool open3d::geometry::Segment3D::IsParameterValid ( double  parameter) const
inlineoverridevirtual

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.

Reimplemented from open3d::geometry::Line3D.

◆ Length()

double open3d::geometry::Segment3D::Length ( ) const
inlineoverridevirtual

Get the scalar length of the segment as the distance between the start point (origin) and the end point.

Reimplemented from open3d::geometry::Line3D.

◆ MidPoint()

Eigen::Vector3d open3d::geometry::Segment3D::MidPoint ( ) const
inline

Calculates the midpoint of the segment.

◆ SlabAABB()

utility::optional< double > open3d::geometry::Segment3D::SlabAABB ( const AxisAlignedBoundingBox box) const
overridevirtual

Returns the lower intersection parameter for a segment with an axis aligned bounding box or empty if no intersection. Uses the slab method, see warning below.

Calculates the lower intersection parameter of a parameterized segment with an axis aligned bounding box. The intersection point can be recovered with .Line().pointAt(...). If the segment does not intersect the box the optional return value will be empty. No intersection behind the segment origin will be counted, and if the segment originates from within the bounding box the parameter value will be 0. No intersection beyond the endpoint of the segment will be considered either.

This implementation is based off of Tavian Barnes' optimized branchless slab method. https://tavianator.com/2011/segment_box.html. It runs in roughly 5% of the time as the the naive exact method, but can degenerate in specific conditions where a segment lies exactly in one of the AABB's planes.

Warning
A segment that lies exactly in one of the AABB's planes within the double floating point precision will not intersect correctly by this method

Reimplemented from open3d::geometry::Line3D.

◆ Through()

static Segment3D open3d::geometry::Segment3D::Through ( const Eigen::Vector3d &  p0,
const Eigen::Vector3d &  p1 
)
inlinestatic

Creates a Segment3D through two points. The origin will take the value of p0, and the endpoint be p1. The direction will be a normalized vector from p0 to p1.

◆ Transform()

void open3d::geometry::Segment3D::Transform ( const Eigen::Transform< double, 3, Eigen::Affine > &  t)
overridevirtual

Transform the segment by the given matrix.

Reimplemented from open3d::geometry::Line3D.


The documentation for this class was generated from the following files: