|
| 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...
|
|
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. More...
|
|
virtual void | Transform (const Eigen::Transform< double, 3, Eigen::Affine > &t) |
| Transform the Line3D by the given matrix. More...
|
|
const Eigen::ParametrizedLine< double, 3 > & | Line () const |
| Returns a const reference to the underlying Eigen::ParametrizedLine object. More...
|
|
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. Returns an empty result if there is no intersection. On a Line3D this returns the same result as .Line().intersectionParameter(plane) 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...
|
|
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 intersection. Uses the slab method, see warning below. More...
|
|
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 intersection. This method is about 20x slower than the slab method, see details to know when to use. 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...
|
|
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() More...
|
|
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. More...
|
|
Line3D is a class which derives from Eigen::ParametrizedLine<double, 3> in order to capture the semantic differences between a "line", "ray", and "line segment" for operations in which the difference is important, such as intersection and distance tests. The underlying Eigen object can always be retrieved with the .Line() method.
The taxonomy of the Line3D class and its derived classes, Ray3D and Segment3D, was created in order to find a compromise between the goals of providing an easy-to-use API, enforcing obvious correctness when dealing with operations in which line semantics are important, and maintaining reasonably high performance.
The underlying motivation is to enforce correctness when performing line operations based on Eigen::ParametrizedLine<double, 3> even as subtleties about how a line is represented begin to affect the outcomes of different operations. Some performance is sacrificed in the use of virtual functions for a clean API in cases where the compiler cannot determine at compile time which function will be called and cannot de-virtualize the call.
In such cases where performance is extremely important, avoid iterating through a list of derived objects stored as Line3D and calling virtual functions on them so that the compiler can hopefully remove the vtable lookup, or consider a hand implementation of your problem in which you carefully account for the semantics yourself.
Returns the lower intersection parameter for a line 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 line with an axis aligned bounding box. The intersection point can be recovered with .Line().pointAt(...). If the line does not intersect the box the return value will be empty. Also note that if the AABB is behind the line's origin point, the value returned will still be of the lower intersection, which is the first intersection in the direction of the line, not the intersection closer to the origin.
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 line is likely to lie exactly in one of the AABB planes and false negatives are unacceptable. Typically this will only happen when lines are axis-aligned and both lines 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 in open3d::geometry::Segment3D.
Returns the lower intersection parameter for a line 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 line with an axis aligned bounding box. The intersection point can be recovered with .Line().pointAt(...). If the line does not intersect the box the optional return value will be empty. Also note that if the AABB is behind the line's origin point, the value returned will still be of the lower intersection, which is the first intersection in the direction of the line, not the intersection closer to the origin.
This implementation is based off of Tavian Barnes' optimized branchless slab method. https://tavianator.com/2011/ray_box.html. It runs in roughly 5% of the time as the the naive exact method, but can degenerate in specific conditions where a line lies exactly in one of the AABB's planes.
- Warning
- A line that lies exactly in one of the AABB's planes within the double floating point precision will not intersect correctly by this method
Reimplemented in open3d::geometry::Segment3D, and open3d::geometry::Ray3D.