Simbody  3.6
SimTK::Geo::LineSeg_< P > Class Template Reference

A 3d line segment primitive represented by its end points in an unspecified frame, and a collection of line segment-related utility methods. More...

Public Member Functions

 LineSeg_ ()
 Construct an uninitialized LineSeg object; the end points will be garbage (NaN in Debug builds). More...
 
 LineSeg_ (const Vec3P &e0, const Vec3P &e1)
 Construct a LineSeg with the given end points. More...
 
LineSeg_setEndpoints (const Vec3P &e0, const Vec3P &e1)
 Change the end points of this line segment. More...
 
LineSeg_setEndpoint (int which, const Vec3P &p)
 Change one end point of this line segment. More...
 
bool isDegenerate (RealP tol=Geo::getDefaultTol< P >()) const
 Determine whether this line segment is degenerate to a given tolerance, meaning that its length is less than or equal to the tolerance. More...
 
const Vec3PgetEndpoint (int which) const
 Get the location of an end point. Order is the same as construction. More...
 
Vec3PupdEndpoint (int which)
 Get a writable reference to the location of an end point. Order is the same as construction. More...
 
const Vec3Poperator[] (int which) const
 Access an end point by indexing the line segment. More...
 
Vec3Poperator[] (int which)
 Get writable access to an end point by indexing the line segment. More...
 
RealP calcLength () const
 Calculate the length of this line segment (expensive). More...
 
RealP calcLengthSqr () const
 Calculate the square of the length of this line segment (cheap). More...
 
Vec3P findPoint (RealP t) const
 Return a point along the line segment given by its coordinate t, where t==0 gives end point 0, t==1 gives end point 1 and other values interpolate or extrapolate linearly. More...
 
Vec3P findMidpoint () const
 Return the center point of the line segment; this is the same as findPoint(1/2) but faster. More...
 
Sphere_< P > calcBoundingSphere () const
 Calculate a minimal bounding sphere for this line segment. More...
 
RealP findDistanceToPoint (const Vec3P &p2) const
 Find the distance between this line segment and a point expressed in the same frame. More...
 
RealP findDistanceToPointSqr (const Vec3P &p2) const
 Find the square of the distance between this line segment and a point expressed in the same frame. More...
 

Detailed Description

template<class P>
class SimTK::Geo::LineSeg_< P >

A 3d line segment primitive represented by its end points in an unspecified frame, and a collection of line segment-related utility methods.

We support a one-parameter t representation of the line segment, where t=0 gives the first end point and t=1 gives the second end point.

Constructor & Destructor Documentation

◆ LineSeg_() [1/2]

template<class P>
SimTK::Geo::LineSeg_< P >::LineSeg_ ( )
inline

Construct an uninitialized LineSeg object; the end points will be garbage (NaN in Debug builds).

◆ LineSeg_() [2/2]

template<class P>
SimTK::Geo::LineSeg_< P >::LineSeg_ ( const Vec3P e0,
const Vec3P e1 
)
inline

Construct a LineSeg with the given end points.

When an orientation is needed we define the line segment to go from e0 to e1.

Member Function Documentation

◆ setEndpoints()

template<class P>
LineSeg_& SimTK::Geo::LineSeg_< P >::setEndpoints ( const Vec3P e0,
const Vec3P e1 
)
inline

Change the end points of this line segment.

◆ setEndpoint()

template<class P>
LineSeg_& SimTK::Geo::LineSeg_< P >::setEndpoint ( int  which,
const Vec3P p 
)
inline

Change one end point of this line segment.

◆ isDegenerate()

template<class P>
bool SimTK::Geo::LineSeg_< P >::isDegenerate ( RealP  tol = Geo::getDefaultTol<P>()) const
inline

Determine whether this line segment is degenerate to a given tolerance, meaning that its length is less than or equal to the tolerance.

Use a tolerance of zero if you want to check only for exact degeneracy. By default the tolerance is SignificantReal for the precision in use, about 2e-14 in double, 9e-7 in float. Cost is 10 flops.

◆ getEndpoint()

template<class P>
const Vec3P& SimTK::Geo::LineSeg_< P >::getEndpoint ( int  which) const
inline

Get the location of an end point. Order is the same as construction.

You can use operator[] instead for a more compact notation.

◆ updEndpoint()

template<class P>
Vec3P& SimTK::Geo::LineSeg_< P >::updEndpoint ( int  which)
inline

Get a writable reference to the location of an end point. Order is the same as construction.

You can use operator[] instead for a more compact notation.

◆ operator[]() [1/2]

template<class P>
const Vec3P& SimTK::Geo::LineSeg_< P >::operator[] ( int  which) const
inline

Access an end point by indexing the line segment.

◆ operator[]() [2/2]

template<class P>
Vec3P& SimTK::Geo::LineSeg_< P >::operator[] ( int  which)
inline

Get writable access to an end point by indexing the line segment.

◆ calcLength()

template<class P>
RealP SimTK::Geo::LineSeg_< P >::calcLength ( ) const
inline

Calculate the length of this line segment (expensive).

Cost is about 40 flops.

◆ calcLengthSqr()

template<class P>
RealP SimTK::Geo::LineSeg_< P >::calcLengthSqr ( ) const
inline

Calculate the square of the length of this line segment (cheap).

Cost is 8 flops.

◆ findPoint()

template<class P>
Vec3P SimTK::Geo::LineSeg_< P >::findPoint ( RealP  t) const
inline

Return a point along the line segment given by its coordinate t, where t==0 gives end point 0, t==1 gives end point 1 and other values interpolate or extrapolate linearly.

Note that values outside the range [0,1] are not on the line segment. Cost is 10 flops.

◆ findMidpoint()

template<class P>
Vec3P SimTK::Geo::LineSeg_< P >::findMidpoint ( ) const
inline

Return the center point of the line segment; this is the same as findPoint(1/2) but faster.

Cost is 4 flops.

◆ calcBoundingSphere()

template<class P>
Sphere_<P> SimTK::Geo::LineSeg_< P >::calcBoundingSphere ( ) const
inline

Calculate a minimal bounding sphere for this line segment.

This is the sphere whose center is the segment midpoint and whose radius is half the segment length, plus a little slop. Cost is about 45 flops.

◆ findDistanceToPoint()

template<class P>
RealP SimTK::Geo::LineSeg_< P >::findDistanceToPoint ( const Vec3P p2) const
inline

Find the distance between this line segment and a point expressed in the same frame.

Cost is XXX flops.

◆ findDistanceToPointSqr()

template<class P>
RealP SimTK::Geo::LineSeg_< P >::findDistanceToPointSqr ( const Vec3P p2) const
inline

Find the square of the distance between this line segment and a point expressed in the same frame.

Cost is XXX flops.


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