Line3

The Line3 class template represents a line in 3D space, with predefined typedefs for lines of type float and double.

There are also various utility functions that operate on Line3 objects defined in ImathLineAlgo.h and described in Line Functions.

Example:

#include <Imath/ImathLine.h>

void
line3_example()
{
    Imath::V3f   a (0.0f, 0.0f, 0.0f);
    Imath::V3f   b (1.0f, 1.0f, 1.0f);

    Imath::Line3f line (a, b);
  
    assert (line.pos == a);
    assert (line.dir == (b-a).normalized());
    
    Imath::V3f   c (0.5f, 0.5f, 0.5f);

    float f = line.distanceTo (c);
    assert (Imath::equalWithAbsError (f, 0.0f, 0.0001f));

    Imath::V3f p = line (0.5f); // midpoint, i.e. 0.5 units from a along (b-a)

    assert (p.equalWithAbsError (Imath::V3f (0.288675f, 0.288675f, 0.288675f), 0.0001f));
}
typedef Line3<float> Imath::Line3f

Line of type float.

typedef Line3<double> Imath::Line3d

Line of type double.

template <class T>
class Line3

The Line3 class represents a 3D line, defined by a point and a direction vector.

Direct access to member fields

Vec3<T> pos

A point on the line.

Vec3<T> dir

The direction of the line.

Constructors

constexpr Line3()

Uninitialized by default.

constexpr Line3(const Vec3<T> &point1, const Vec3<T> &point2)

Initialize with two points.

The direction is the difference between the points.

Manipulation

void set(const Vec3<T> &point1, const Vec3<T> &point2)

Set the line defined by two points.

The direction is the difference between the points.

Utility Methods

constexpr Vec3<T> operator()(T parameter) const

Return the point on the line at the given parameter value, e.g.

L(t)

constexpr T distanceTo(const Vec3<T> &point) const

Return the distance to the given point.

constexpr T distanceTo(const Line3<T> &line) const

Return the distance to the given line.

constexpr Vec3<T> closestPointTo(const Vec3<T> &point) const

Return the point on the line closest to the given point.

constexpr Vec3<T> closestPointTo(const Line3<T> &line) const

Return the point on the line closest to the given line.

Warning

doxygenfunction: Unable to resolve multiple matches for function “operator<<” with arguments (std::ostream& s, const Line3<T>& line) in doxygen xml output for project “Imath” from directory: doxyxml/. Potential matches:

- std::ostream &operator<<(std::ostream&, Imath::half)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Color4<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Euler<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Interval<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Line3<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Matrix22<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Matrix33<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Matrix44<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Plane3<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Quat<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Shear6<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Vec2<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Vec3<T>&)
- template <class T>
  std::ostream &Imath::operator<<(std::ostream&, const Vec4<T>&)