template<typename T>
werkzeugkiste::geometry::Line3d_ class

Represents a line/segment in 3d Euclidean space.

Public types

using vec_type = Vec<T, 3>

Constructors, destructors, conversion operators

Line3d_() defaulted
Default constructor yields an invalid line/segment.
Line3d_(vec_type from, vec_type to)
Construct a line from 2 real valued points. In case of a segment, these denote the start and end points.

Public functions

auto Reversed() const -> Line3d_
Returns a line with flipped direction vector.
auto From() const -> const vec_type&
For a segment, this returns the start point. For a line, it's simply one of the given points to construct the line in the first place.
void SetFrom(const vec_type& from)
Sets the first reference point (starting point of a line segment; or any point on a line).
auto To() const -> const vec_type&
For a segment, this returns the end point. For a line, it's simply one of the given points to construct the line in the first place.
void SetTo(const vec_type& to)
Sets the second reference point (end point of a line segment; or any point on a line).
auto Length() const -> double
Returns the length from the start to the end point. As such, it's only meaningful for a line segment.
auto Direction() const -> vec_type
Returns the non-normalized direction vector from the start point to the end point.
auto UnitDirection() const -> vec_type
Returns the unit direction vector from the start point to the end point.
auto MidPoint() const -> vec_type
Returns the point halfway between from and to.
auto IsValid() const -> bool
Returns true if the line object is valid, i.e. start and end points are not the same.
auto AngleRad(const vec_type& v) const -> double
Returns the angle between the line and the given directional vector. The angle will be between 0 and Pi.
auto AngleDeg(const vec_type& v) const -> double
Returns the angle between the line and the given directional vector. The angle will be between 0 and 180 degrees.
auto AngleRad(const Plane_<T>& plane) const -> double
Returns the angle between the line and the plane. The angle will be between -Pi/2 and Pi/2.
auto AngleDeg(const Plane_<T>& plane) const -> double
Returns the angle between the line and the plane. The angle will be between -90 and +90 degrees.
auto PointAtOffset(double offset_factor) const -> vec_type
Returns the point which is offset * Direction() away from the line's starting point, i.e. offset == 0 is the starting point, offset == 1 is the end point.
auto ClosestPointOnLine(const vec_type& point) const -> vec_type
Returns the closest point on the line, i.e. the projection of the given point onto this line.
auto ClosestPointOnSegment(const vec_type& point) const -> vec_type
Returns the point on this line segment(!) which is closest to the given point.
auto DistancePointToLine(const vec_type& point) const -> double
Returns the minimum distance between the point and this line.
auto DistancePointToSegment(const vec_type& point) const -> double
Returns the minimum distance between the point and this segment.

Friends

auto operator<<(std::ostream& stream, const Line3d_& line) -> std::ostream&
Overloaded output stream operator.